aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/import_orig.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-01-11 19:00:48 +0100
committerGuido Günther <agx@sigxcpu.org>2017-01-11 19:01:10 +0100
commit4a41d496a8006fdc05e4eb0faf762d6ad043a96e (patch)
treeda46f0f9038b537ac224fbb72aebaf8812b37049 /gbp/scripts/import_orig.py
parent734143b4e0a53a044a20a569ed41632cc90ff360 (diff)
import-orig: Move orig.tar.gz with filter-pristine-tar
If we filter a tarball and use filter-pristine-tar we want pristine-tar to see the correct file name. If a file already exists at that location move it. If we wouldn't move the existing tarball but rather e.g. create the symlink in a temp directory we risk gbp buildpackage picking up the unfiltered tarball later. Closes: #558777
Diffstat (limited to 'gbp/scripts/import_orig.py')
-rw-r--r--gbp/scripts/import_orig.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 5c948276..df2b0cb6 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -18,8 +18,10 @@
"""Import a new upstream version into a Git repository"""
import os
+import shutil
import sys
import tempfile
+import time
import gbp.command_wrappers as gbpc
from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
@@ -197,6 +199,10 @@ def prepare_pristine_tar(archive, pkg, version):
if os.path.basename(archive) != os.path.basename(link):
try:
if not is_link_target(archive, link):
+ if os.path.exists(link):
+ backup = "%s.%d" % (link, time.time())
+ gbp.log.info("%s already exists, moving to %s" % (link, backup))
+ shutil.move(link, backup)
os.symlink(os.path.abspath(archive), link)
linked = True
except OSError as err: