diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-07-03 15:34:27 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-07-03 16:00:34 +0200 |
commit | 2bc3801a5f4ffacce4d8b34cdf2e22f6291401e2 (patch) | |
tree | bf7a991e08e8b7c749965e8d359af9f0f76b59b5 | |
parent | b1e2b96dee730e92e6db3ff96d42677f6b7383e6 (diff) |
import_dsc: don't assume component tarballs have the correct name
The tarball needs to be unpacked into component/ regardless how
the toplevel directory in the tarball itself is named.
Closes: #829458
-rw-r--r-- | gbp/deb/upstreamsource.py | 26 | ||||
-rw-r--r-- | gbp/scripts/import_dsc.py | 9 | ||||
m--------- | tests/component/deb/data | 0 |
3 files changed, 30 insertions, 5 deletions
diff --git a/gbp/deb/upstreamsource.py b/gbp/deb/upstreamsource.py index ca235ef..76f85b4 100644 --- a/gbp/deb/upstreamsource.py +++ b/gbp/deb/upstreamsource.py @@ -1,6 +1,7 @@ # vim: set fileencoding=utf-8 : # # (C) 2013 Intel Corporation <markus.lehtonen@linux.intel.com> +# (C) 2016 Guido Guenther <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 @@ -18,6 +19,11 @@ from gbp.pkg import UpstreamSource from gbp.deb.policy import DebianPkgPolicy +import gbp.command_wrappers + +import os +import shutil +import tempfile class DebianUpstreamSource(UpstreamSource): @@ -26,3 +32,23 @@ class DebianUpstreamSource(UpstreamSource): super(DebianUpstreamSource, self).__init__(name, unpacked, DebianPkgPolicy) + + +def unpack_subtarball(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) + + dest = os.path.join(dest, component) + shutil.move(source.unpacked, dest) + finally: + os.chdir(olddir) + if tmpdir is not None: + gbp.command_wrappers.RemoveTree(tmpdir)() diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index 4bd726c..4cbf8d5 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006, 2007, 2011, 2012, 2015 Guido Guenther <agx@sigxcpu.org> +# (C) 2006, 2007, 2011, 2012, 2015, 2016 Guido Guenther <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 @@ -27,7 +27,7 @@ import pipes import time import gbp.command_wrappers as gbpc from gbp.deb.dscfile import DscFile -from gbp.deb.upstreamsource import DebianUpstreamSource +from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_subtarball from gbp.deb.git import (DebianGitRepository, GitRepositoryError) from gbp.deb.changelog import ChangeLog from gbp.git import rfc822_date_to_git @@ -346,10 +346,9 @@ def main(argv): dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..')) upstream = DebianUpstreamSource(src.tgz) upstream.unpack(dirs['tmp'], options.filters) - for tarball in src.additional_tarballs.values(): + for (component, tarball) in src.additional_tarballs.items(): gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball)) - subtarball = DebianUpstreamSource(tarball) - subtarball.unpack(upstream.unpacked, options.filters) + unpack_subtarball(upstream.unpacked, component, tarball, options.filters) format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native] tag = repo.version_to_tag(format[0], src.upstream_version) diff --git a/tests/component/deb/data b/tests/component/deb/data -Subproject b53e6ec2a785e1d9df3fbb2590f8fe974362910 +Subproject 748f13d484359942aa0d7b7ca631325d5e8fe0e |