[Pkg-bazaar-commits] ./bzr-builddeb/trunk r344: Fix import-dsc when there is a symlink.
James Westby
james.westby at canonical.com
Sat Jul 4 20:45:01 UTC 2009
------------------------------------------------------------
revno: 344
committer: James Westby <james.westby at canonical.com>
branch nick: trunk
timestamp: Sat 2009-07-04 16:45:01 -0400
message:
Fix import-dsc when there is a symlink.
Also add the workaround for exporting working trees when grabbing the
pristine-tar information during import-dsc.
modified:
import_dsc.py
tests/__init__.py
tests/test_import_dsc.py
-------------- next part --------------
=== modified file 'import_dsc.py'
--- a/import_dsc.py 2009-07-04 20:30:40 +0000
+++ b/import_dsc.py 2009-07-04 20:45:01 +0000
@@ -1714,7 +1714,13 @@
tmpdir = tempfile.mkdtemp(prefix="builddeb-pristine-")
try:
dest = os.path.join(tmpdir, "orig")
- export(tree, dest, format='dir')
+ tree.lock_read()
+ try:
+ for (dp, ie) in tree.inventory.iter_entries():
+ ie._read_tree_state(dp, tree)
+ export(tree, dest, format='dir')
+ finally:
+ tree.unlock()
command = ["/usr/bin/pristine-tar", "gendelta", tarball_path, "-"]
info(" ".join(command))
proc = Popen(command, stdout=PIPE, cwd=dest)
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2009-05-06 16:57:26 +0000
+++ b/tests/__init__.py 2009-07-04 20:45:01 +0000
@@ -240,6 +240,7 @@
def __init__(self, name, version, native=False):
self.upstream_files = {}
+ self.upstream_symlinks = {}
self.debian_files = {}
self.name = name
self.native = native
@@ -253,6 +254,9 @@
for new_file in files:
self.upstream_files[new_file[0]] = new_file[1]
+ def add_upstream_symlink(self, name, target):
+ self.upstream_symlinks[name] = target
+
def remove_upstream_file(self, filename):
del self.upstream_files[filename]
@@ -312,6 +316,14 @@
finally:
f.close()
+ def _make_symlinks(self, files_list, basedir):
+ for (path, target) in files_list.items():
+ dirname = os.path.dirname(path)
+ if dirname is not None and dirname != "":
+ if not os.path.exists(os.path.join(basedir, dirname)):
+ os.makedirs(os.path.join(basedir, dirname))
+ os.symlink(target, os.path.join(basedir, path))
+
def basedir(self):
return self.name + "-" + str(self._cl.version.upstream_version)
@@ -319,13 +331,14 @@
basedir = self.basedir()
os.mkdir(basedir)
self._make_files(self.upstream_files, basedir)
+ self._make_symlinks(self.upstream_symlinks, basedir)
return basedir
def build(self):
basedir = self._make_base()
if not self.native:
orig_basedir = basedir + ".orig"
- shutil.copytree(basedir, orig_basedir)
+ shutil.copytree(basedir, orig_basedir, symlinks=True)
cmd = "dpkg-source -sa -b %s" % (basedir)
if os.path.exists("%s_%s.orig.tar.gz"
% (self.name, self._cl.version.upstream_version)):
=== modified file 'tests/test_import_dsc.py'
--- a/tests/test_import_dsc.py 2009-06-09 15:29:56 +0000
+++ b/tests/test_import_dsc.py 2009-07-04 20:45:01 +0000
@@ -1392,3 +1392,12 @@
self.assertEqual(up_rh1[-1], up_revtree.get_parent_ids()[1])
self.assertEqual(up_rh2[-1],
self.tree2.branch.tags.lookup_tag("upstream-1.2"))
+
+ def test_import_symlink(self):
+ version = Version("1.0-1")
+ self.requireFeature(tests.SymlinkFeature)
+ builder = SourcePackageBuilder("package", version)
+ builder.add_default_control()
+ builder.add_upstream_symlink("a", "b")
+ builder.build()
+ self.db1.import_package(builder.dsc_name())
More information about the Pkg-bazaar-commits
mailing list