diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-07-21 19:46:15 -0230 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-07-21 19:46:15 -0230 |
commit | 4ac0aa8af83ee090cfb7526d27e4b70ce9cb96d9 (patch) | |
tree | e869354e1d884d86eabe418c99603f4f180ef0d3 | |
parent | ffeb40eb9a9e2263fcbeae8b3d606c9d98b86086 (diff) |
always symlink orig.tar.gz from tarball dir
ff it's there and --tarball-dir is being used
Closes: 490706
-rw-r--r-- | gbp/deb_utils.py | 20 | ||||
-rwxr-xr-x | git-buildpackage | 8 |
2 files changed, 19 insertions, 9 deletions
diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py index a96bb8ea..e1b47483 100644 --- a/gbp/deb_utils.py +++ b/gbp/deb_utils.py @@ -145,18 +145,28 @@ def has_orig(cp, dir): return False return True -def copy_orig(cp, orig_dir, output_dir): - """copy orig.tar.gz from orig_dir to output_dir""" +def symlink_orig(cp, orig_dir, output_dir, force=False): + """ + symlink orig.tar.gz from orig_dir to output_dir + @return: True if link was created or src == dst + False in case of errror or src doesn't exist + """ orig_dir = os.path.abspath(orig_dir) output_dir = os.path.abspath(output_dir) if orig_dir == output_dir: return True + src = os.path.join(orig_dir, orig_file(cp)) + dst = os.path.join(output_dir, orig_file(cp)) + if not os.access(src, os.F_OK): + return False try: - shutil.copyfile(os.path.join(orig_dir, orig_file(cp)), - os.path.join(output_dir, orig_file(cp))) - except IOError: + if os.access(dst, os.F_OK) and force: + os.unlink(dst) + print src, dst + os.symlink(src, dst) + except OSError: return False return True diff --git a/git-buildpackage b/git-buildpackage index 392827e2..fc3feba5 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -241,10 +241,10 @@ def main(argv): # Get/build the orig.tar.gz if necessary: if not du.is_native(cp): - # first look up if we have a tarball at tarball_dir - if options.tarball_dir and not du.has_orig(cp, output_dir): - print "Looking for orig tarball '%s' from '%s'" % (du.orig_file(cp), tarball_dir) - if not du.copy_orig(cp, tarball_dir, output_dir): + # look in tarball_dir first, if it's there even replace an existing orig.tar.gz + if options.tarball_dir: + print "Looking for orig tarball '%s' at '%s'" % (du.orig_file(cp), tarball_dir) + if not du.symlink_orig(cp, tarball_dir, output_dir): print "Orig tarball '%s' not found at '%s'" % (du.orig_file(cp), tarball_dir) else: print "Orig tarball '%s' found at '%s'" % (du.orig_file(cp), tarball_dir) |