aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2008-04-18 09:38:58 +0200
committerGuido Guenther <agx@sigxcpu.org>2008-04-18 09:38:58 +0200
commit9966730523c8a283ed9753e0398753ac29f0f85f (patch)
tree701e318de1a9b56a8aed1fd4c44912dc23602d3a
parent45f8fb666d264b8ea45d0ec9122d8882f10b96ae (diff)
create a symlink archive -> <package>_<version>.tar.gz
this makes sure pristine_tar uses the correct filename for the orig.tar.gz. Closes: #475316
-rwxr-xr-xgit-import-orig33
1 files changed, 31 insertions, 2 deletions
diff --git a/git-import-orig b/git-import-orig
index 5885b0b..975e95f 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 <pkg>_<version>.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)