aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml9
-rw-r--r--debian/changelog31
-rw-r--r--debian/control6
-rw-r--r--docs/manpages/gbp-import-orig.xml15
-rw-r--r--gbp/config.py3
-rw-r--r--gbp/deb/git.py22
-rw-r--r--gbp/deb/upstreamsource.py64
-rw-r--r--gbp/pkg/upstreamsource.py7
-rwxr-xr-xgbp/scripts/buildpackage.py13
-rw-r--r--gbp/scripts/common/__init__.py4
-rw-r--r--gbp/scripts/common/import_orig.py7
-rwxr-xr-xgbp/scripts/export_orig.py11
-rw-r--r--gbp/scripts/import_dsc.py30
-rw-r--r--gbp/scripts/import_orig.py116
-rw-r--r--gbp/scripts/pristine_tar.py23
-rw-r--r--packaging/git-buildpackage.spec2
-rw-r--r--tests/05_test_detection.py5
-rw-r--r--tests/24_test_gbp_import_orig.py44
m---------tests/component/deb/data0
-rw-r--r--tests/component/deb/test_import_dsc.py17
-rw-r--r--tests/component/deb/test_import_orig.py49
-rw-r--r--tests/component/deb/test_pristine_tar.py2
22 files changed, 348 insertions, 132 deletions
diff --git a/.travis.yml b/.travis.yml
index 9eee95c..90584be 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,16 +4,11 @@ language: python
services:
- docker
+dist: bionic
python:
- - "3.4"
- - "3.5"
- "3.6"
-matrix:
- include:
- - python: 3.7
- dist: xenial
- sudo: true
+ - 3.7
before_install:
- sudo apt-get -qq update
diff --git a/debian/changelog b/debian/changelog
index 472c6b8..9019ffc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,34 @@
+git-buildpackage (0.9.17) unstable; urgency=medium
+
+ * [6248524] export_orig: Don't fail without a repository.
+ This is a valid use case in overlay mode
+ Thanks to Thomas Koch for the report
+ * [ff9ff7e] Use UpstreamSource for additional tarballs as well.
+ This will help on upstream tarball signatures as well as
+ improving additional tarball handling.
+ * [16781c8] import-orig: Handle tarball signature when using pristine-tar
+ * [4a97a1c] import-dsc: Import signature if present in dsc
+ * [e541f35] Recommend and build depend on pristine-tar 1.41
+ since only this version has signature support.
+ * [12ed9fb] travis-ci: Switch to bionic.
+ Need to drop python 3.4 for that since it's not available on bionic.
+
+ -- Guido Günther <agx@sigxcpu.org> Thu, 31 Oct 2019 19:15:14 +0100
+
+git-buildpackage (0.9.16) unstable; urgency=medium
+
+ * [fef81e2] pq: Don't bubble up FileNotFoundException (Closes: #940043)
+ * [fb26fd9] docs: Fix wrong argument order of branch rename.
+ Thanks to Jens Reyer (Closes: #941110)
+ * [11f9f31] export-orig: Check 'origin/pristine-tar' as well for compression
+ type (Closes: #941894)
+ * [916f538] docs: Fix typos.
+ Thanks to lintian
+ * [6cf1f7e] d/control: Bump standards version
+ no changes needed
+
+ -- Guido Günther <agx@sigxcpu.org> Tue, 22 Oct 2019 17:36:46 +0200
+
git-buildpackage (0.9.15) unstable; urgency=medium
[ Guido Günther ]
diff --git a/debian/control b/debian/control
index 37d5732..c59f5cf 100644
--- a/debian/control
+++ b/debian/control
@@ -27,14 +27,14 @@ Build-Depends:
cpio <!nocheck>,
devscripts (>= 2.17.7~) <!nocheck>,
git (>= 1:1.7.9.1-1~) <!nocheck>,
- pristine-tar <!nocheck>,
+ pristine-tar (>= 1.14) <!nocheck>,
rpm <!nocheck>,
unzip <!nocheck>,
zipmerge <!nocheck>,
# For the network tests
curl <!nocheck>,
python3-requests <!nocheck>,
-Standards-Version: 4.1.3
+Standards-Version: 4.4.0
Vcs-Git: https://git.sigxcpu.org/cgit/git-buildpackage/
Vcs-Browser: https://git.sigxcpu.org/cgit/git-buildpackage/
Homepage: https://honk.sigxcpu.org/piki/projects/git-buildpackage/
@@ -51,7 +51,7 @@ Depends: ${python3:Depends},
python3-dateutil,
python3-pkg-resources,
sensible-utils,
-Recommends: pristine-tar (>= 0.5),
+Recommends: pristine-tar (>= 1.41),
cowbuilder | pbuilder | sbuild,
python3-requests
Suggests: python3-notify2, unzip, sudo
diff --git a/docs/manpages/gbp-import-orig.xml b/docs/manpages/gbp-import-orig.xml
index 7b040a1..0ff2787 100644
--- a/docs/manpages/gbp-import-orig.xml
+++ b/docs/manpages/gbp-import-orig.xml
@@ -39,6 +39,7 @@
<arg><option>--postunpack=cmd</option></arg>
<arg><option>--[no-]interactive</option></arg>
<arg><option>--[no-]rollback</option></arg>
+ <arg><option>--upstream-signatures=</option>[auto|on|off]</arg>
<group choice="plain">
<arg choice="plain"><replaceable>filename</replaceable></arg>
<arg choice="plain"><replaceable>url</replaceable></arg>
@@ -382,6 +383,20 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--upstream-signatures=</option>[auto|on|off]</term>
+ <listitem>
+ <para>
+ Whether upstream signatures should be imported as well (when
+ using pristine-tar). <emphasis>no</emphasis> turns this
+ off completely while <emphasis>yes</emphasis> always tries to
+ import a signature (which can be useful if you want to fail if
+ e.g. &uscan; did not fetch a signature). The default
+ <emphasis>auto</emphasis> means to import a signature file if
+ present but do nothing otherwise.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/gbp/config.py b/gbp/config.py
index cef355a..495ec63 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -181,6 +181,7 @@ class GbpOptionParser(OptionParser):
'submodules': 'False',
'symlink-orig': 'True',
'tarball-dir': '',
+ 'upstream-signatures': 'auto',
'template-dir': '',
'time-machine': 1,
'track': 'True',
@@ -327,6 +328,8 @@ class GbpOptionParser(OptionParser):
"default is '%(postimport)s'",
'hooks':
"Enable running all hooks, default is %(hooks)s",
+ 'upstream-signatures':
+ "Whether to import/export upstream tarball signatures",
'time-machine':
"don't try to apply patch queue to head commit only. "
"Try at most TIME_MACHINE commits back, "
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index 12ad34d..3584f6f 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -282,28 +282,28 @@ class DebianGitRepository(PkgGitRepository):
"""
return True if self.has_branch(self.pristine_tar_branch) else False
- def create_pristine_tar_commits(self, upstream_tree, tarball, component_tarballs):
+ def create_pristine_tar_commits(self, upstream_tree, sources):
"""
Create pristine-tar commits for a package with main tarball
and (optional) component tarballs based on upstream_tree
- @param tarball: path to main tarball
- @param component_tarballs: C{list} of C{tuple}s of component
- name and path to additional tarball
@param upstream_tree: the treeish in the git repo to create the commits against
+ @param soures: C{list} of tarball as I{UpstreamSource}. First one being the main
+ tarball the other ones additional tarballs.
"""
- components = [c for (c, t) in component_tarballs]
+ components = [t.component for t in sources[1:]]
main_tree = self.tree_drop_dirs(upstream_tree, components)
try:
- for component, name in component_tarballs:
- subtree = self.tree_get_dir(upstream_tree, component)
+ for source in sources[1:]:
+ subtree = self.tree_get_dir(upstream_tree, source.component)
if not subtree:
raise GitRepositoryError("No tree for '%s' found in '%s' to create "
- "pristine tar commit from" % (component, upstream_tree))
- gbp.log.debug("Creating pristine tar commit '%s' from '%s'" % (component, subtree))
- self.pristine_tar.commit(name, subtree, quiet=True)
- self.pristine_tar.commit(tarball, main_tree, quiet=True)
+ "pristine tar commit from" % (source.component,
+ upstream_tree))
+ gbp.log.debug("Creating pristine tar commit '%s' from '%s'" % (source.path, subtree))
+ self.pristine_tar.commit(source.path, subtree, signaturefile=source.signaturefile, quiet=True)
+ self.pristine_tar.commit(sources[0].path, main_tree, signaturefile=sources[0].signaturefile, quiet=True)
except CommandExecFailed as e:
raise GitRepositoryError(str(e))
diff --git a/gbp/deb/upstreamsource.py b/gbp/deb/upstreamsource.py
index 04c3774..cead62c 100644
--- a/gbp/deb/upstreamsource.py
+++ b/gbp/deb/upstreamsource.py
@@ -28,29 +28,43 @@ import tempfile
class DebianUpstreamSource(UpstreamSource):
"""Upstream source class for Debian"""
- def __init__(self, name, unpacked=None):
+ def __init__(self, name, unpacked=None, sig=None):
super(DebianUpstreamSource, self).__init__(name,
- unpacked,
- DebianPkgPolicy)
-
-
-def unpack_component_tarball(dest, component, tarball, filters):
- """
- Unpack the tarball I{tarball} into dest naming it I{component}.
- Apply filters during unpack.
- """
- olddir = os.path.abspath(os.path.curdir)
- tmpdir = None
- try:
- tmpdir = os.path.abspath(tempfile.mkdtemp(dir=os.path.join(dest, '..')))
- source = DebianUpstreamSource(tarball)
- source.unpack(tmpdir, filters)
-
- newdest = os.path.join(dest, component)
- if os.path.exists(newdest):
- shutil.rmtree(newdest)
- shutil.move(source.unpacked, newdest)
- finally:
- os.chdir(olddir)
- if tmpdir is not None:
- gbp.command_wrappers.RemoveTree(tmpdir)()
+ unpacked=unpacked,
+ sig=sig,
+ pkg_policy=DebianPkgPolicy)
+
+
+class DebianAdditionalTarball(DebianUpstreamSource):
+ """Upstream source class for additional tarballs"""
+ def __init__(self, name, component, unpacked=None, sig=None):
+ self.component = component
+ super(DebianAdditionalTarball, self).__init__(name,
+ unpacked=unpacked,
+ sig=sig)
+
+ def unpack(self, dest, filters):
+ """
+ Unpack the additional tarball into {dir} naming it
+ I{component}. Apply filters during unpack.
+
+ @param dir: the main tarball dir
+ @param filters: filters to apply
+
+ We can't simply use unpack since we need to remove any preexisting dirs and
+ name the target directory after the component name.
+ """
+ olddir = os.path.abspath(os.path.curdir)
+ tmpdir = None
+ try:
+ tmpdir = os.path.abspath(tempfile.mkdtemp(dir=os.path.join(dest, '..')))
+ super(DebianAdditionalTarball, self).unpack(tmpdir, filters)
+
+ newdest = os.path.join(dest, self.component)
+ if os.path.exists(newdest):
+ shutil.rmtree(newdest)
+ shutil.move(self.unpacked, newdest)
+ finally:
+ os.chdir(olddir)
+ if tmpdir is not None:
+ gbp.command_wrappers.RemoveTree(tmpdir)()
diff --git a/gbp/pkg/upstreamsource.py b/gbp/pkg/upstreamsource.py
index ab9e61d..a312c3b 100644
--- a/gbp/pkg/upstreamsource.py
+++ b/gbp/pkg/upstreamsource.py
@@ -39,11 +39,12 @@ class UpstreamSource(object):
@cvar _unpacked: path to the unpacked source tree
@type _unpacked: string
"""
- def __init__(self, name, unpacked=None, pkg_policy=PkgPolicy):
+ def __init__(self, name, unpacked=None, pkg_policy=PkgPolicy, sig=None):
self._orig = False
self._pkg_policy = pkg_policy
self._path = name
self.unpacked = unpacked
+ self._sig = sig
self._check_orig()
if self.is_dir():
@@ -93,6 +94,10 @@ class UpstreamSource(object):
def path(self):
return self._path.rstrip('/')
+ @property
+ def signaturefile(self):
+ return self._sig
+
def unpack(self, dir, filters=None):
"""
Unpack packed upstream sources into a given directory
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 2114ed0..2aca53d 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -33,7 +33,7 @@ from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
from gbp.deb.source import DebianSource, DebianSourceError, FileVfs
from gbp.deb.format import DebianSourceFormat
from gbp.git.vfs import GitVfs
-from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
+from gbp.deb.upstreamsource import DebianUpstreamSource, DebianAdditionalTarball
from gbp.errors import GbpError
import gbp.log
import gbp.notifications
@@ -139,10 +139,13 @@ def overlay_extract_origs(source, tarball_dir, dest_dir, options):
# Unpack additional tarballs
for c in options.components:
- tarball = os.path.join(tarball_dir, source.upstream_tarball_name(
- comp_type, component=c))
- gbp.log.info("Extracting '%s' to '%s/%s'" % (os.path.basename(tarball), dest_dir, c))
- unpack_component_tarball(dest_dir, c, tarball, [])
+ tarball = DebianAdditionalTarball(os.path.join(tarball_dir,
+ source.upstream_tarball_name(
+ comp_type, component=c)),
+ component=c)
+ gbp.log.info("Extracting '%s' to '%s/%s'" % (os.path.basename(tarball.path),
+ dest_dir, c))
+ tarball.unpack(dest_dir, [])
def source_vfs(repo, options, tree):
diff --git a/gbp/scripts/common/__init__.py b/gbp/scripts/common/__init__.py
index 023d2b8..b67e44c 100644
--- a/gbp/scripts/common/__init__.py
+++ b/gbp/scripts/common/__init__.py
@@ -22,6 +22,7 @@ import traceback
from gbp.errors import GbpError
from gbp.deb import DebianPkgPolicy
from gbp.pkg import Archive
+from gbp.deb.upstreamsource import DebianAdditionalTarball
class ExitCodes(object):
@@ -51,6 +52,7 @@ def is_download(args):
return False
+# FIXME: this could become a method of DebianUpstreamSource
def get_component_tarballs(name, version, tarball, components):
"""
Figure out the paths to the component tarballs based on the main
@@ -64,7 +66,7 @@ def get_component_tarballs(name, version, tarball, components):
comp_type,
os.path.dirname(tarball),
component)
- tarballs.append((component, cname))
+ tarballs.append(DebianAdditionalTarball(cname, component))
if not os.path.exists(cname):
raise GbpError("Can not find component tarball %s" % cname)
return tarballs
diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py
index d31bab9..f6f3206 100644
--- a/gbp/scripts/common/import_orig.py
+++ b/gbp/scripts/common/import_orig.py
@@ -176,4 +176,9 @@ def download_orig(url):
os.unlink(target)
raise GbpError("Failed to download %s: %s" % (url, e))
- return DebianUpstreamSource(target)
+ sig = '{}.asc'.format(target)
+ if os.path.exists(sig):
+ gbp.log.debug("Signature {} found for {}".format(target, sig))
+ else:
+ sig = None
+ return DebianUpstreamSource(target, sig=sig)
diff --git a/gbp/scripts/export_orig.py b/gbp/scripts/export_orig.py
index c288501..13be4f9 100755
--- a/gbp/scripts/export_orig.py
+++ b/gbp/scripts/export_orig.py
@@ -236,12 +236,13 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
if comp_type == 'auto':
branch = None
- if repo.has_branch('pristine-tar'):
- branch = 'pristine-tar'
- elif repo.has_branch('origin/pristine-tar', remote=True):
- branch = 'origin/pristine-tar'
+ if repo:
+ if repo.has_branch('pristine-tar'):
+ branch = 'pristine-tar'
+ elif repo.has_branch('origin/pristine-tar', remote=True):
+ branch = 'origin/pristine-tar'
- if branch:
+ if branch is not None:
regex = r'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
commits = repo.grep_log(regex, branch, merges=False)
if commits:
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index 7d6e491..d24ffa2 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -26,7 +26,8 @@ import pipes
import time
import gbp.command_wrappers as gbpc
from gbp.deb.dscfile import DscFile
-from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
+from gbp.deb.upstreamsource import (DebianUpstreamSource,
+ DebianAdditionalTarball)
from gbp.deb.git import (DebianGitRepository, GitRepositoryError)
from gbp.deb.changelog import ChangeLog
from gbp.git import rfc822_date_to_git
@@ -487,11 +488,17 @@ def main(argv):
# unpack
dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
- source = DebianUpstreamSource(dsc.tgz)
- source.unpack(dirs['tmp'], options.filters)
- for (component, tarball) in dsc.additional_tarballs.items():
- gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
- unpack_component_tarball(source.unpacked, component, tarball, options.filters)
+ sigfile = '{}.asc'.format(dsc.tgz)
+ sigfile = sigfile if sigfile in dsc.sigs else None
+ sources = [DebianUpstreamSource(dsc.tgz, sig=sigfile)]
+ for component, tarball in dsc.additional_tarballs.items():
+ sigfile = '{}.asc'.format(tarball)
+ sigfile = sigfile if sigfile in dsc.sigs else None
+ sources.append(DebianAdditionalTarball(tarball, component))
+ sources[0].unpack(dirs['tmp'], options.filters)
+ for tarball in sources[1:]:
+ gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball.path))
+ tarball.unpack(sources[0].unpacked, options.filters)
if repo.find_version(options.debian_tag, dsc.version):
gbp.log.warn("Version %s already imported." % dsc.version)
@@ -503,12 +510,12 @@ def main(argv):
# import
if dsc.native:
- import_native(repo, source, dsc, options)
+ import_native(repo, sources[0], dsc, options)
else:
imported = False
commit = repo.find_version(options.upstream_tag, dsc.upstream_version)
if not repo.find_version(options.upstream_tag, dsc.upstream_version):
- commit = import_upstream(repo, source, dsc, options)
+ commit = import_upstream(repo, sources[0], dsc, options)
imported = True
if not repo.has_branch(options.debian_branch):
@@ -519,15 +526,12 @@ def main(argv):
options.debian_branch)
if dsc.diff or dsc.deb_tgz:
- apply_debian_patch(repo, source, dsc, commit, options)
+ apply_debian_patch(repo, sources[0], dsc, commit, options)
else:
gbp.log.warn("Didn't find a diff to apply.")
if imported and options.pristine_tar:
- repo.create_pristine_tar_commits(commit,
- dsc.tgz,
- dsc.additional_tarballs.items())
-
+ repo.create_pristine_tar_commits(commit, sources)
if repo.get_branch() == options.debian_branch or repo.empty:
# Update HEAD if we modified the checked out branch
repo.force_head(options.debian_branch, hard=True)
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 6d5c147..6c40ea0 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2006, 2007, 2009, 2011, 2015, 2016 Guido Günther <agx@sigxcpu.org>
+# (C) 2006, 2007, 2009, 2011, 2015, 2016, 2019 Guido Günther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -25,7 +25,7 @@ import time
import gbp.command_wrappers as gbpc
from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
from gbp.deb.format import DebianSourceFormat
-from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
+from gbp.deb.upstreamsource import DebianUpstreamSource
from gbp.deb.uscan import (Uscan, UscanError)
from gbp.deb.changelog import ChangeLog, NoChangeLogError
from gbp.deb.git import GitRepositoryError
@@ -42,6 +42,22 @@ from gbp.scripts.common.hook import Hook
from gbp.deb.rollbackgit import RollbackDebianGitRepository
+def maybe_link(orig, link):
+ """
+ Create a symlink named link pointing to orig if
+ that is not the case already.
+ """
+ if is_link_target(orig, link):
+ return False
+
+ if os.path.exists(link):
+ backup = "%s.%d" % (link, time.time())
+ gbp.log.info("%s already exists, moving to %s" % (link, backup))
+ shutil.move(link, backup)
+ os.symlink(os.path.abspath(orig), link)
+ return True
+
+
def prepare_pristine_tar(archive, pkg, version):
"""
Prepare the upstream source for pristine tar import.
@@ -49,7 +65,7 @@ def prepare_pristine_tar(archive, pkg, version):
This checks if the upstream source is actually a tarball
and creates a symlink from I{archive}
to I{<pkg>_<version>.orig.tar.<ext>} so pristine-tar will
- see the correct basename.
+ see the correct basename. Same goes for an optional signature.
@param archive: the upstream source's name
@type archive: C{str}
@@ -61,25 +77,21 @@ def prepare_pristine_tar(archive, pkg, version):
"""
linked = False
if os.path.isdir(archive):
- return None, None
+ return None, False
ext = os.path.splitext(archive)[1]
if ext in ['.tgz', '.tbz2', '.tlz', '.txz']:
ext = ".%s" % ext[2:]
link = "../%s_%s.orig.tar%s" % (pkg, version, ext)
-
if os.path.basename(archive) != os.path.basename(link):
try:
- if not is_link_target(archive, link):
- if os.path.exists(link):
- backup = "%s.%d" % (link, time.time())
- gbp.log.info("%s already exists, moving to %s" % (link, backup))
- shutil.move(link, backup)
- os.symlink(os.path.abspath(archive), link)
- linked = True
+ linked = maybe_link(archive, link)
+ archive_sig = '{}.asc'.format(archive)
+ if os.path.exists(archive_sig):
+ maybe_link(archive_sig, '{}.asc'.format(link))
except OSError as err:
- raise GbpError("Cannot symlink '%s' to '%s': %s" % (archive, link, err[1]))
+ raise GbpError("Cannot symlink '%s' to '%s': %s" % (archive, link, err))
return (link, linked)
else:
return (archive, linked)
@@ -177,7 +189,12 @@ def find_upstream(use_uscan, args, version=None):
elif len(args) == 0:
raise GbpError("No archive to import specified. Try --help.")
else:
- return DebianUpstreamSource(args[0])
+ sig = '{}.asc'.format(args[0])
+ if os.path.exists(sig):
+ gbp.log.debug("Signature {} found for {}".format(args[0], sig))
+ else:
+ sig = None
+ return DebianUpstreamSource(args[0], sig=sig)
def debian_branch_merge(repo, tag, version, options):
@@ -275,20 +292,24 @@ def debian_branch_merge_by_merge(repo, tag, version, options):
repo.set_branch(branch)
-def unpack_tarballs(sourcepackage, source, version, component_tarballs, options):
+def unpack_tarballs(name, sources, version, options):
tmpdir = tempfile.mkdtemp(dir='../')
- if not source.is_dir(): # Unpack main tarball
- source.unpack(tmpdir, options.filters)
- gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
+ if not sources[0].is_dir(): # Unpack main tarball
+ sources[0].unpack(tmpdir, options.filters)
+ gbp.log.debug("Unpacked '%s' to '%s'" % (sources[0].path, sources[0].unpacked))
- if orig_needs_repack(source, options):
- gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
- (source, tmpdir) = repack_upstream(source, sourcepackage, version, tmpdir, options.filters)
+ if orig_needs_repack(sources[0], options):
+ gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (sources[0].path,
+ sources[0].unpacked))
+ # FIXME: we should repack the other tarballs here too (See #860457)
+ # for that we better move around sources instead of source[0]
+ (source, tmpdir) = repack_upstream(sources[0], name, version, tmpdir, options.filters)
+ sources[0] = source
- if not source.is_dir(): # Unpack component tarballs
- for (component, tarball) in component_tarballs:
- unpack_component_tarball(source.unpacked, component, tarball, options.filters)
- return (source, tmpdir)
+ if not sources[0].is_dir(): # Unpack component tarballs
+ for s in sources[1:]:
+ s.unpack(sources[0].unpacked, options.filters)
+ return (sources, tmpdir)
def set_bare_repo_options(options):
@@ -361,6 +382,9 @@ def build_parser(name):
dest="symlink_orig")
import_group.add_config_file_option("component", action="append", metavar='COMPONENT',
dest="components")
+ import_group.add_config_file_option(option_name="upstream-signatures",
+ dest="upstream_signatures",
+ type='tristate')
cmd_group.add_config_file_option(option_name="postimport", dest="postimport")
cmd_group.add_config_file_option(option_name="postunpack", dest="postunpack")
@@ -430,19 +454,16 @@ def main(argv):
# Download the main tarball
if options.download:
- upstream = download_orig(args[0])
+ sources = [download_orig(args[0])]
else:
- upstream = find_upstream(options.uscan, args, options.version)
- if not upstream:
+ sources = [find_upstream(options.uscan, args, options.version)]
+ if not sources[0]:
return ExitCodes.uscan_up_to_date
# The main tarball
- (name, version) = detect_name_and_version(repo, upstream, options)
+ (name, version) = detect_name_and_version(repo, sources[0], options)
# Additional tarballs we expect to exist
- component_tarballs = get_component_tarballs(name,
- version,
- upstream.path,
- options.components)
+ sources += get_component_tarballs(name, version, sources[0].path, options.components)
tag = repo.version_to_tag(options.upstream_tag, version)
if repo.has_tag(tag):
@@ -451,19 +472,19 @@ def main(argv):
if repo.bare:
set_bare_repo_options(options)
- upstream, tmpdir = unpack_tarballs(name, upstream, version, component_tarballs, options)
+ sources, tmpdir = unpack_tarballs(name, sources, version, options)
try:
postunpack_hook(repo, tmpdir, options)
except gbpc.CommandExecFailed:
raise GbpError() # The hook already printed an error message
- (pristine_orig, linked) = prepare_pristine_tar(upstream.path,
+ (pristine_orig, linked) = prepare_pristine_tar(sources[0].path,
name,
version)
# Don't mess up our repo with git metadata from an upstream tarball
try:
- if os.path.isdir(os.path.join(upstream.unpacked, '.git/')):
+ if os.path.isdir(os.path.join(sources[0].unpacked, '.git/')):
raise GbpError("The orig tarball contains .git metadata - giving up.")
except OSError:
pass
@@ -472,7 +493,7 @@ def main(argv):
import_branch = options.upstream_branch
filter_msg = ["", " (filtering out %s)"
% options.filters][len(options.filters) > 0]
- gbp.log.info("Importing '%s' to branch '%s'%s..." % (upstream.path,
+ gbp.log.info("Importing '%s' to branch '%s'%s..." % (sources[0].path,
import_branch,
filter_msg))
gbp.log.info("Source package is %s" % name)
@@ -480,7 +501,7 @@ def main(argv):
msg = upstream_import_commit_msg(options, version)
- commit = repo.commit_dir(upstream.unpacked,
+ commit = repo.commit_dir(sources[0].unpacked,
msg=msg,
branch=import_branch,
other_parents=repo.vcs_tag_parent(options.vcs_tag, version),
@@ -490,11 +511,16 @@ def main(argv):
if options.pristine_tar:
if pristine_orig:
repo.rrr_branch('pristine-tar')
- repo.create_pristine_tar_commits(import_branch,
- pristine_orig,
- component_tarballs)
+ for source in sources:
+ # Enforce signature file exists with --upstream-signatures=on
+ if options.upstream_signatures.is_on() and not source.signaturefile:
+ raise GbpError("%s does not have a signature file" % source.path)
+ # For all practical purposes we're interested in pristine_orig's path
+ if pristine_orig != sources[0].path:
+ sources[0]._path = pristine_orig
+ repo.create_pristine_tar_commits(import_branch, sources)
else:
- gbp.log.warn("'%s' not an archive, skipping pristine-tar" % upstream.path)
+ gbp.log.warn("'%s' not an archive, skipping pristine-tar" % sources[0].path)
repo.create_tag(name=tag,
msg="Upstream version %s" % version,
@@ -526,9 +552,9 @@ def main(argv):
postimport_hook(repo, tag, version, options)
except (gbpc.CommandExecFailed, GitRepositoryError) as err:
msg = str(err) or 'Unknown error, please report a bug'
- raise GbpError("Import of %s failed: %s" % (upstream.path, msg))
+ raise GbpError("Import of %s failed: %s" % (sources[0].path, msg))
except KeyboardInterrupt:
- raise GbpError("Import of %s failed: aborted by user" % (upstream.path))
+ raise GbpError("Import of %s failed: aborted by user" % (sources[0].path))
except GbpError as err:
if str(err):
gbp.log.err(err)
@@ -542,7 +568,7 @@ def main(argv):
cleanup_tmp_tree(tmpdir)
if not ret:
- gbp.log.info("Successfully imported version %s of %s" % (version, upstream.path))
+ gbp.log.info("Successfully imported version %s of %s" % (version, sources[0].path))
return ret
diff --git a/gbp/scripts/pristine_tar.py b/gbp/scripts/pristine_tar.py
index 792bcab..e9a556a 100644
--- a/gbp/scripts/pristine_tar.py
+++ b/gbp/scripts/pristine_tar.py
@@ -24,6 +24,7 @@ from gbp.command_wrappers import CommandExecFailed
from gbp.config import GbpOptionParserDebian
from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
from gbp.deb.source import DebianSource
+from gbp.deb.upstreamsource import DebianUpstreamSource
from gbp.errors import GbpError
from gbp.scripts.common import ExitCodes, get_component_tarballs
@@ -90,16 +91,16 @@ def main(argv):
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
- source = DebianSource('.')
- component_tarballs = get_component_tarballs(source.sourcepkg,
- source.upstream_version,
- tarball,
- options.components)
+ debsource = DebianSource('.')
+ # FIXME: this should be a single call
+ sources = [DebianUpstreamSource(tarball)]
+ sources += get_component_tarballs(debsource.sourcepkg,
+ debsource.upstream_version,
+ sources[0].path,
+ options.components)
upstream_tag = repo.version_to_tag(options.upstream_tag,
- source.upstream_version)
- repo.create_pristine_tar_commits(upstream_tag,
- tarball,
- component_tarballs)
+ debsource.upstream_version)
+ repo.create_pristine_tar_commits(upstream_tag, sources)
ret = 0
except (GitRepositoryError, GbpError, CommandExecFailed) as err:
if str(err):
@@ -109,8 +110,8 @@ def main(argv):
if not ret:
comp_msg = (' with additional tarballs for %s'
- % ", ".join([os.path.basename(t[1]) for t in component_tarballs])) if component_tarballs else ''
- gbp.log.info("Successfully committed pristine-tar data for version %s of %s%s" % (source.upstream_version,
+ % ", ".join([os.path.basename(t.path) for t in sources[1:]])) if sources[1:] else ''
+ gbp.log.info("Successfully committed pristine-tar data for version %s of %s%s" % (debsource.version,
tarball,
comp_msg))
return ret
diff --git a/packaging/git-buildpackage.spec b/packaging/git-buildpackage.spec
index 73c2ac9..d6f08a7 100644
--- a/packaging/git-buildpackage.spec
+++ b/packaging/git-buildpackage.spec
@@ -3,7 +3,7 @@
Name: git-buildpackage
Summary: Build packages from git
-Version: 0.9.15
+Version: 0.9.16
Release: 0
Group: Development/Tools/Building
License: GPLv2
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index d632233..c4831fb 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -139,3 +139,8 @@ class TestDetection(unittest.TestCase):
guessed = export_orig.guess_comp_type(
'gz', self.source, repo, None)
self.assertEqual("gzip", guessed)
+
+ def test_guess_comp_type_no_repo(self):
+ guessed = export_orig.guess_comp_type(
+ 'auto', self.source, None, str(self.tmpdir))
+ self.assertEqual('gzip', guessed)
diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py
index fadff28..0f36820 100644
--- a/tests/24_test_gbp_import_orig.py
+++ b/tests/24_test_gbp_import_orig.py
@@ -8,10 +8,15 @@ from collections import namedtuple
from gbp.scripts.import_orig import (debian_branch_merge_by_replace,
GbpError,
- is_30_quilt)
+ is_30_quilt,
+ prepare_pristine_tar)
+
from gbp.scripts.common.import_orig import download_orig
from . testutils import DebianGitTestRepo
+import shutil
+import tempfile
+
@unittest.skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
class TestImportOrigDownload(DebianGitTestRepo):
@@ -88,3 +93,40 @@ class TestMergeModeReplace(DebianGitTestRepo):
self.assertTrue(os.path.exists("upstream_file"))
# … but upsream's debian dir must not
self.assertFalse(os.path.exists("debian/changelog"))
+
+
+class TestGbpBuildpackagePreparePristineTar(unittest.TestCase):
+ def setUp(self):
+ self._cwd = os.getcwd()
+ self._tmpdir = os.path.abspath(tempfile.mkdtemp(prefix='gbp_', dir='.'))
+ # we need to change into a temp subdir since the link is
+ # create in '..'
+ d = os.path.join(self._tmpdir, 'd')
+ os.mkdir(d)
+ os.chdir(d)
+
+ def tearDown(self):
+ if not os.getenv("GBP_TESTS_NOCLEAN"):
+ shutil.rmtree(self._tmpdir)
+ os.chdir(self._cwd)
+
+ def test_dir(self):
+ ret = prepare_pristine_tar(self._tmpdir, 'foo', '1.0')
+ self.assertEquals(ret, (None, False))
+
+ def test_tar(self):
+ archive = '{}/foo.tgz'.format(self._tmpdir)
+ ret = prepare_pristine_tar(archive, 'foo', '1.0')
+ self.assertEquals(ret, ('../foo_1.0.orig.tar.gz', True))
+ self.assertTrue(os.path.islink(
+ os.path.join(self._tmpdir, 'foo_1.0.orig.tar.gz')))
+
+ def test_signature(self):
+ archive = '{}/foo.tgz'.format(self._tmpdir)
+ signature = '{}.asc'.format(archive)
+ with open(signature, 'w') as f:
+ f.write('')
+ ret = prepare_pristine_tar(archive, 'foo', '1.0')
+ self.assertEquals(ret, ('../foo_1.0.orig.tar.gz', True))
+ self.assertTrue(os.path.islink(
+ os.path.join(self._tmpdir, 'foo_1.0.orig.tar.gz.asc')))
diff --git a/tests/component/deb/data b/tests/component/deb/data
-Subproject 3a3a327e39e186437c8d1da64ba94536d87343a
+Subproject 30f0a164b914cb19ec038e6f9675878fa58b639
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index a3b0aea..3cdd283 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -367,3 +367,20 @@ class TestImportDsc(ComponentTestBase):
ok_(os.path.exists("./configure.ac"))
ok_(not os.path.exists("./debian/patches/series"))
ok_(not os.path.exists("./debian/patches/AUTHORS"))
+
+ def test_import_signature(self):
+ dscfile = self._dsc30('2.8-1')
+ assert import_dsc(['arg0',
+ '--verbose',
+ '--pristine-tar',
+ '--debian-branch=master',
+ '--upstream-branch=upstream',
+ dscfile]) == 0
+ repo = ComponentTestGitRepository('hello-debhelper')
+ self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
+ commits, expected = len(repo.get_commits()), 2
+ commits, expected = len(repo.get_commits(until='pristine-tar')), 1
+ ok_(commits == expected, "Found %d pristine-tar commits instead of %d" % (commits, expected))
+ eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.delta',
+ b'hello-debhelper_2.8.orig.tar.gz.id',
+ b'hello-debhelper_2.8.orig.tar.gz.asc'})
diff --git a/tests/component/deb/test_import_orig.py b/tests/component/deb/test_import_orig.py
index d713682..b95b874 100644
--- a/tests/component/deb/test_import_orig.py
+++ b/tests/component/deb/test_import_orig.py
@@ -22,7 +22,7 @@ import tarfile
from mock import patch, DEFAULT
-from tests.component import (ComponentTestBase, skipUnless)
+from tests.component import (ComponentTestBase, ComponentTestGitRepository, skipUnless)
from tests.component.deb import DEB_TEST_DATA_DIR, DEB_TEST_DOWNLOAD_URL
from tests.component.deb.fixtures import RepoFixtures
@@ -354,3 +354,50 @@ class TestImportOrig(ComponentTestBase):
orig = self._orig('2.8')
submodule.create_branch('upstream', 'origin/upstream')
ok_(import_orig(['arg0', '--no-interactive', orig]) == 0)
+
+ def test_with_signaturefile(self):
+ """
+ Test that importing a new version with a signature file works
+ """
+ repo = ComponentTestGitRepository.create(self.pkg)
+ os.chdir(self.pkg)
+ orig = self._orig('2.8')
+ ok_(import_orig(['arg0',
+ '--postimport=printenv > ../postimport.out',
+ '--postunpack=printenv > ../postunpack.out',
+ '--no-interactive', '--pristine-tar',
+ '--upstream-signatures=on', orig]) == 0)
+ self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
+ tags=['upstream/2.8'])
+ ok_(os.path.exists('../postimport.out'))
+ eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.id',
+ b'hello-debhelper_2.8.orig.tar.gz.delta',
+ b'hello-debhelper_2.8.orig.tar.gz.asc'})
+ self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"),
+ ("GBP_TAG", "upstream/2.8"),
+ ("GBP_UPSTREAM_VERSION", "2.8"),
+ ("GBP_DEBIAN_VERSION", "2.8-1")])
+
+ def test_with_auto_signaturefile(self):
+ """
+ Test that importing a new version with a signature file works
+ when using auto mode.
+ """
+ repo = ComponentTestGitRepository.create(self.pkg)
+ os.chdir(self.pkg)
+ orig = self._orig('2.8')
+ ok_(import_orig(['arg0',
+ '--postimport=printenv > ../postimport.out',
+ '--postunpack=printenv > ../postunpack.out',
+ '--no-interactive', '--pristine-tar',
+ '--upstream-signatures=auto', orig]) == 0)
+ self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
+ tags=['upstream/2.8'])
+ ok_(os.path.exists('../postimport.out'))
+ eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.id',
+ b'hello-debhelper_2.8.orig.tar.gz.delta',
+ b'hello-debhelper_2.8.orig.tar.gz.asc'})
+ self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"),
+ ("GBP_TAG", "upstream/2.8"),
+ ("GBP_UPSTREAM_VERSION", "2.8"),
+ ("GBP_DEBIAN_VERSION", "2.8-1")])
diff --git a/tests/component/deb/test_pristine_tar.py b/tests/component/deb/test_pristine_tar.py
index 68148c6..d6ecb6e 100644
--- a/tests/component/deb/test_pristine_tar.py
+++ b/tests/component/deb/test_pristine_tar.py
@@ -47,7 +47,7 @@ class TestPristineTar(ComponentTestBase):
@RepoFixtures.quilt30(DEFAULT_DSC, opts=['--no-pristine-tar'])
def test_run(self, repo):
"""
- Test that adding pristine-tar commit wotks
+ Test that adding pristine-tar commit works
"""
orig = self._orig('2.6')
ok_(pristine_tar(['arg0', 'commit', orig]) == 0)