diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-08-27 14:35:31 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2019-10-27 11:34:43 +0100 |
commit | ff9ff7e2b54785acc733da2ca78d0da15bb5d681 (patch) | |
tree | e5e361b463db0bf29fdd9b0bb10283e549a146be /gbp/scripts/import_orig.py | |
parent | 62485247b61090f8bd41a8bf419872db36fa12dc (diff) |
Use UpstreamSource for additional tarballs as well
This will help on upstream tarball signatures as well as
improving additional tarball handling.
Diffstat (limited to 'gbp/scripts/import_orig.py')
-rw-r--r-- | gbp/scripts/import_orig.py | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 6d5c147b..26eb3c79 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,8 @@ 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, + DebianAdditionalTarball) from gbp.deb.uscan import (Uscan, UscanError) from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.git import GitRepositoryError @@ -275,20 +276,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): @@ -430,19 +435,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 +453,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 +474,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 +482,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 +492,12 @@ 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 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 +529,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 +545,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 |