From 9966730523c8a283ed9753e0398753ac29f0f85f Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Fri, 18 Apr 2008 09:38:58 +0200 Subject: create a symlink archive -> _.tar.gz this makes sure pristine_tar uses the correct filename for the orig.tar.gz. Closes: #475316 --- git-import-orig | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/git-import-orig b/git-import-orig index 5885b0b0..975e95f5 100755 --- a/git-import-orig +++ b/git-import-orig @@ -25,7 +25,7 @@ import re import glob import subprocess import gbp.command_wrappers as gbpc -from gbp.deb_utils import unpack_orig +from gbp.deb_utils import parse_changelog, unpack_orig, NoChangelogError from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag, replace_source_tree) from gbp.config import GbpOptionParser from gbp.errors import GbpError @@ -39,6 +39,26 @@ def cleanup_tmp_tree(tree): print >>sys.stderr, "Removal of tmptree %s failed." % tree +def symlink_orig(archive, pkg, version): + """ + create a symlink _.orig.tar.gz so pristine-tar will see the + correct basename + @return: archive path to be used by pristine tar + """ + if os.path.isdir(archive): + return None + ext = os.path.splitext(archive)[1] + dst = "../%s_%s.orig.tar%s" % (pkg, version, ext) + if os.path.basename(archive) != os.path.basename(dst): + try: + os.symlink(archive, dst) + except OSError, err: + raise GbpError, err + return dst + else: + return archive + + def import_upstream_tree(repo, src_dir, version, filters, verbose): """import the source uptream tree to the current branch""" try: @@ -71,6 +91,7 @@ def guess_version(archive, version_regex=r''): def main(argv): ret = 0 tmpdir = '' + pristine_orig = None parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', usage='%prog [-u version] /path/to/upstream-version.tar.gz') @@ -164,6 +185,11 @@ on howto create it otherwise use --upstream-branch to specify it. # archive content not in a subdir else: orig_dir = tmpdir + try: + cp = parse_changelog('debian/changelog') + pristine_orig = symlink_orig(archive, cp['Source'], version) + except NoChangelogError: + pristine_orig = archive try: filter_msg = ["", " (filtering out %s)" % options.filters][len(options.filters) > 0] @@ -176,7 +202,10 @@ on howto create it otherwise use --upstream-branch to specify it. import_upstream_tree(repo, orig_dir, version, options.filters, verbose=not is_empty) if options.pristine_tar: upstream_branch = [ options.upstream_branch, 'master' ][is_empty] - gbpc.PristineTar().commit(archive, upstream_branch) + if pristine_orig: + gbpc.PristineTar().commit(pristine_orig, upstream_branch) + else: + print >>sys.stderr, "Warning: '%s' not an archive, skipping pristine-tar" % archive gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version), msg="Upstream version %s" % version) -- cgit v1.2.3