Merge lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt2 into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 577
Merged at revision: 572
Proposed branch: lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt2
Merge into: lp:bzr-builddeb
Diff against target: 933 lines (+200/-157)
7 files modified
cmds.py (+5/-6)
dh_make.py (+1/-4)
import_dsc.py (+103/-76)
source_distiller.py (+3/-14)
tests/blackbox/test_merge_upstream.py (+7/-3)
tests/test_import_dsc.py (+58/-54)
util.py (+23/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt2
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers Pending
Review via email: mp+64626@code.launchpad.net

Description of the change

Step 2 of support for multiple upstream tarballs.

Pass lists of orig tarballs along in more places rather than a single upstream tarball and md5 sum.

To post a comment you must log in.
577. By Jelmer Vernooij

Factor out extracting of orig tarballs.

Revision history for this message
James Westby (james-w) wrote :

62 + db.import_upstream_tarball(tarball_filenames, version, parents)

Should this perhaps be import_upstream_tarballs now?

Thanks,

James

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmds.py'
--- cmds.py 2011-06-14 14:04:53 +0000
+++ cmds.py 2011-06-15 02:38:47 +0000
@@ -69,7 +69,6 @@
69 BuildFailedError,69 BuildFailedError,
70 DchError,70 DchError,
71 MissingChangelogError,71 MissingChangelogError,
72 MultipleUpstreamTarballsNotSupported,
73 NoPreviousUpload,72 NoPreviousUpload,
74 PackageVersionNotPresent,73 PackageVersionNotPresent,
75 StrictBuildFailed,74 StrictBuildFailed,
@@ -117,6 +116,7 @@
117 get_source_format,116 get_source_format,
118 guess_build_type,117 guess_build_type,
119 lookup_distribution,118 lookup_distribution,
119 md5sum_filename,
120 open_file,120 open_file,
121 open_file_via_transport,121 open_file_via_transport,
122 tarball_name,122 tarball_name,
@@ -560,9 +560,7 @@
560 db = DistributionBranch(tree.branch, None, tree=tree)560 db = DistributionBranch(tree.branch, None, tree=tree)
561 dbs = DistributionBranchSet()561 dbs = DistributionBranchSet()
562 dbs.add_branch(db)562 dbs.add_branch(db)
563 if len(tarball_filenames) > 1:563 conflicts = db.merge_upstream(tarball_filenames, package, version,
564 raise MultipleUpstreamTarballsNotSupported()
565 conflicts = db.merge_upstream(tarball_filenames[0], package, version,
566 current_version, upstream_branch=upstream_branch,564 current_version, upstream_branch=upstream_branch,
567 upstream_revision=upstream_revision,565 upstream_revision=upstream_revision,
568 merge_type=merge_type, force=force)566 merge_type=merge_type, force=force)
@@ -977,7 +975,8 @@
977 else:975 else:
978 raise BzrCommandError('bzr import-upstream --revision takes exactly'976 raise BzrCommandError('bzr import-upstream --revision takes exactly'
979 ' one revision specifier.')977 ' one revision specifier.')
980 tag_name, _ = db.import_upstream_tarball(location, version, parents,978 tarballs = [(location, md5sum_filename(location))]
979 tag_name, _ = db.import_upstream_tarball(tarballs, version, parents,
981 upstream_branch=upstream, upstream_revision=upstream_revid)980 upstream_branch=upstream, upstream_revision=upstream_revid)
982 self.outf.write('Imported %s as tag:%s.\n' % (location, tag_name))981 self.outf.write('Imported %s as tag:%s.\n' % (location, tag_name))
983982
@@ -1207,7 +1206,7 @@
12071206
1208 def run(self, package_name, version, tarball, bzr_only=None, v3=None):1207 def run(self, package_name, version, tarball, bzr_only=None, v3=None):
1209 tree = dh_make.import_upstream(tarball, package_name,1208 tree = dh_make.import_upstream(tarball, package_name,
1210 version.encode("utf-8"), use_v3=v3)1209 version.encode("utf-8"), use_v3=v3)
1211 if not bzr_only:1210 if not bzr_only:
1212 tree.lock_write()1211 tree.lock_write()
1213 try:1212 try:
12141213
=== modified file 'dh_make.py'
--- dh_make.py 2011-06-14 14:04:53 +0000
+++ dh_make.py 2011-06-15 02:38:47 +0000
@@ -87,10 +87,7 @@
87 upstream_tree=tree)87 upstream_tree=tree)
88 dbs = import_dsc.DistributionBranchSet()88 dbs = import_dsc.DistributionBranchSet()
89 dbs.add_branch(db)89 dbs.add_branch(db)
90 if len(tarball_filenames) > 1:90 db.import_upstream_tarball(tarball_filenames, version, parents)
91 raise errors.MultipleUpstreamTarballsNotSupported()
92 (tarball_filename, md5sum) = tarball_filenames[0]
93 db.import_upstream_tarball(tarball_filename, version, parents, md5sum=md5sum)
94 return tree91 return tree
9592
9693
9794
=== modified file 'import_dsc.py'
--- import_dsc.py 2011-06-09 21:43:07 +0000
+++ import_dsc.py 2011-06-15 02:38:47 +0000
@@ -27,7 +27,6 @@
2727
2828
29import os29import os
30import re
31import shutil30import shutil
32import stat31import stat
33import subprocess32import subprocess
@@ -63,14 +62,14 @@
63from bzrlib.plugins.builddeb.bzrtools_import import import_dir62from bzrlib.plugins.builddeb.bzrtools_import import import_dir
64from bzrlib.plugins.builddeb.errors import (63from bzrlib.plugins.builddeb.errors import (
65 MultipleUpstreamTarballsNotSupported,64 MultipleUpstreamTarballsNotSupported,
66 TarFailed,
67 UpstreamAlreadyImported,65 UpstreamAlreadyImported,
68 UpstreamBranchAlreadyMerged,66 UpstreamBranchAlreadyMerged,
69 )67 )
70from bzrlib.plugins.builddeb.util import (68from bzrlib.plugins.builddeb.util import (
69 FORMAT_1_0,
71 FORMAT_3_0_QUILT,70 FORMAT_3_0_QUILT,
72 FORMAT_3_0_NATIVE,71 FORMAT_3_0_NATIVE,
73 export,72 extract_orig_tarballs,
74 get_commit_info_from_changelog,73 get_commit_info_from_changelog,
75 md5sum_filename,74 md5sum_filename,
76 open_file_via_transport,75 open_file_via_transport,
@@ -301,6 +300,30 @@
301 pass300 pass
302 return False301 return False
303302
303 def _has_upstream_version(self, branch, tag_name, tarballs=None):
304 if branch.tags.has_tag(tag_name):
305 revid = branch.tags.lookup_tag(tag_name)
306 branch.lock_read()
307 try:
308 graph = branch.repository.get_graph()
309 if not graph.is_ancestor(revid, branch.last_revision()):
310 return False
311 finally:
312 branch.unlock()
313 if tarballs is None:
314 return True
315 if len(tarballs) != 1:
316 raise MultipleUpstreamTarballsNotSupported()
317 (filename, md5) = tarballs[0]
318 rev = branch.repository.get_revision(revid)
319 try:
320 return rev.properties['deb-md5'] == md5
321 except KeyError:
322 warning("tag %s present in branch, but there is no "
323 "associated 'deb-md5' property" % tag_name)
324 pass
325 return False
326
304 def has_version(self, version, md5=None):327 def has_version(self, version, md5=None):
305 """Whether this branch contains the package version specified.328 """Whether this branch contains the package version specified.
306329
@@ -326,7 +349,7 @@
326 return True349 return True
327 return False350 return False
328351
329 def has_upstream_version(self, version, md5=None):352 def has_upstream_version(self, version, tarballs=None):
330 """Whether this branch contains the upstream version specified.353 """Whether this branch contains the upstream version specified.
331354
332 The version must be judged present by having the appropriate tag355 The version must be judged present by having the appropriate tag
@@ -336,13 +359,13 @@
336359
337 :param version: a upstream version number to look for in the upstream 360 :param version: a upstream version number to look for in the upstream
338 branch.361 branch.
339 :param md5: a string with the md5sum that if not None must be362 :param tarballs: list of upstream tarballs that should be present,
340 associated with the revision.363 tuples of filename and md5sum
341 :return: True if the upstream branch contains the specified upstream364 :return: True if the upstream branch contains the specified upstream
342 version of the package. False otherwise.365 version of the package. False otherwise.
343 """366 """
344 for tag_name in self.pristine_tar_source.possible_tag_names(version):367 for tag_name in self.pristine_tar_source.possible_tag_names(version):
345 if self._has_version(self.upstream_branch, tag_name, md5=md5):368 if self._has_upstream_version(self.upstream_branch, tag_name, tarballs=tarballs):
346 return True369 return True
347 return False370 return False
348371
@@ -590,7 +613,7 @@
590 finally:613 finally:
591 self.branch.unlock()614 self.branch.unlock()
592615
593 def branch_to_pull_upstream_from(self, version, md5):616 def branch_to_pull_upstream_from(self, version, upstream_tarballs):
594 """Checks whether this upstream is a pull from a lesser branch.617 """Checks whether this upstream is a pull from a lesser branch.
595618
596 Looks in all the other upstream branches for the given619 Looks in all the other upstream branches for the given
@@ -603,20 +626,15 @@
603626
604 :param version: the upstream version to use when searching in the 627 :param version: the upstream version to use when searching in the
605 lesser branches.628 lesser branches.
606 :param md5: a String containing the md5 associateed with the
607 upstream version.
608 :return: a DistributionBranch object to pull the upstream from629 :return: a DistributionBranch object to pull the upstream from
609 if that is what should be done, otherwise None.630 if that is what should be done, otherwise None.
610 """631 """
611 assert isinstance(version, str)632 assert isinstance(version, str)
612 assert md5 is not None, \
613 ("It's not a good idea to use branch_to_pull_upstream_from with "
614 "md5 == None, as you may pull the wrong revision.")
615 up_branch = self.upstream_branch633 up_branch = self.upstream_branch
616 up_branch.lock_read()634 up_branch.lock_read()
617 try:635 try:
618 for branch in reversed(self.get_lesser_branches()):636 for branch in reversed(self.get_lesser_branches()):
619 if branch.has_upstream_version(version, md5=md5):637 if branch.has_upstream_version(version, tarballs=upstream_tarballs):
620 # Check that they haven't diverged638 # Check that they haven't diverged
621 other_up_branch = branch.upstream_branch639 other_up_branch = branch.upstream_branch
622 other_up_branch.lock_read()640 other_up_branch.lock_read()
@@ -629,7 +647,7 @@
629 finally:647 finally:
630 other_up_branch.unlock()648 other_up_branch.unlock()
631 for branch in self.get_greater_branches():649 for branch in self.get_greater_branches():
632 if branch.has_upstream_version(version, md5=md5):650 if branch.has_upstream_version(version, tarballs=upstream_tarballs):
633 # Check that they haven't diverged651 # Check that they haven't diverged
634 other_up_branch = branch.upstream_branch652 other_up_branch = branch.upstream_branch
635 other_up_branch.lock_read()653 other_up_branch.lock_read()
@@ -837,8 +855,8 @@
837 self.branch.fetch(self.upstream_branch, last_revision=revid)855 self.branch.fetch(self.upstream_branch, last_revision=revid)
838 self.upstream_branch.tags.merge_to(self.branch.tags)856 self.upstream_branch.tags.merge_to(self.branch.tags)
839857
840 def import_upstream(self, upstream_part, version, md5, upstream_parents,858 def import_upstream(self, upstream_part, version, upstream_parents,
841 upstream_tarball=None, upstream_branch=None,859 upstream_tarballs=None, upstream_branch=None,
842 upstream_revision=None, timestamp=None, author=None,860 upstream_revision=None, timestamp=None, author=None,
843 file_ids_from=None):861 file_ids_from=None):
844 """Import an upstream part on to the upstream branch.862 """Import an upstream part on to the upstream branch.
@@ -849,7 +867,6 @@
849 :param upstream_part: the path of a directory containing the867 :param upstream_part: the path of a directory containing the
850 unpacked upstream part of the source package.868 unpacked upstream part of the source package.
851 :param version: upstream version that is being imported869 :param version: upstream version that is being imported
852 :param md5: the md5 of the upstream part.
853 :param upstream_parents: the parents to give the upstream revision870 :param upstream_parents: the parents to give the upstream revision
854 :param timestamp: a tuple of (timestamp, timezone) to use for871 :param timestamp: a tuple of (timestamp, timezone) to use for
855 the commit, or None to use the current time.872 the commit, or None to use the current time.
@@ -901,8 +918,12 @@
901 finally:918 finally:
902 self_tree.unlock()919 self_tree.unlock()
903 self.upstream_tree.set_parent_ids(upstream_parents)920 self.upstream_tree.set_parent_ids(upstream_parents)
904 revprops = {"deb-md5": md5}921 revprops = {}
905 if upstream_tarball is not None:922 if upstream_tarballs is not None:
923 if len(upstream_tarballs) != 1:
924 raise MultipleUpstreamTarballsNotSupported()
925 (upstream_tarball, md5) = upstream_tarballs[0]
926 revprops["deb-md5"] = md5
906 delta_revprops = self.pristine_tar_source.create_delta_revprops(927 delta_revprops = self.pristine_tar_source.create_delta_revprops(
907 self.upstream_tree, upstream_tarball)928 self.upstream_tree, upstream_tarball)
908 revprops.update(delta_revprops)929 revprops.update(delta_revprops)
@@ -918,8 +939,8 @@
918 tag_name, _ = self.tag_upstream_version(version, revid=revid)939 tag_name, _ = self.tag_upstream_version(version, revid=revid)
919 return tag_name, revid940 return tag_name, revid
920941
921 def import_upstream_tarball(self, tarball_filename, version, parents,942 def import_upstream_tarball(self, tarballs, version, parents,
922 md5sum=None, upstream_branch=None, upstream_revision=None):943 upstream_branch=None, upstream_revision=None):
923 """Import an upstream part to the upstream branch.944 """Import an upstream part to the upstream branch.
924945
925 :param tarball_filename: The tarball to import.946 :param tarball_filename: The tarball to import.
@@ -933,12 +954,10 @@
933 :param md5sum: hex digest of the md5sum of the tarball, if known.954 :param md5sum: hex digest of the md5sum of the tarball, if known.
934 :return: (tag_name, revision_id) of the imported tarball.955 :return: (tag_name, revision_id) of the imported tarball.
935 """956 """
936 if not md5sum:957 tarball_dir = self._extract_tarballs_to_tempdir(tarballs)
937 md5sum = md5sum_filename(tarball_filename)
938 tarball_dir = self._extract_tarball_to_tempdir(tarball_filename)
939 try:958 try:
940 return self.import_upstream(tarball_dir, version, md5sum, parents,959 return self.import_upstream(tarball_dir, version, parents,
941 upstream_tarball=tarball_filename,960 tarballs,
942 upstream_branch=upstream_branch,961 upstream_branch=upstream_branch,
943 upstream_revision=upstream_revision)962 upstream_revision=upstream_revision)
944 finally:963 finally:
@@ -1132,16 +1151,28 @@
1132 cl.parse_changelog(open(cl_filename).read(), strict=False)1151 cl.parse_changelog(open(cl_filename).read(), strict=False)
1133 return cl1152 return cl
11341153
1135 def _do_import_package(self, version, versions, debian_part, md5,1154 def _import_normal_package(self, version, versions, debian_part, md5,
1136 upstream_part, upstream_md5, upstream_tarball=None,1155 upstream_part, upstream_tarballs, timestamp=None, author=None,
1137 timestamp=None, author=None, file_ids_from=None,1156 file_ids_from=None, pull_debian=True):
1138 pull_debian=True):1157 """Import a source package.
1158
1159 :param version: Full Debian version
1160 :param versions: Safe versions from changelog
1161 :param debian_part: Path to extracted directory with Debian changes
1162 :param unextracted_debian_md5: MD5 sum of unextracted Debian diff/tarball
1163 :param upstream_part: Extracted upstream directory
1164 :param upstream_tarballs: List of tuples with (upstream tarfile, md5sum)
1165 :param timestamp: Version timestamp according to changelog
1166 :param author: Author according to changelog
1167 :param file_ids_from: Sequence of trees to take file ids from
1168 :param pull_debian: Whether to pull from the Debian branch
1169 """
1139 pull_branch = None1170 pull_branch = None
1140 if pull_debian:1171 if pull_debian:
1141 pull_branch = self.branch_to_pull_version_from(version, md5)1172 pull_branch = self.branch_to_pull_version_from(version, md5)
1142 if pull_branch is not None:1173 if pull_branch is not None:
1143 if (self.branch_to_pull_upstream_from(version.upstream_version,1174 if (self.branch_to_pull_upstream_from(version.upstream_version,
1144 upstream_md5)1175 upstream_tarballs)
1145 is None):1176 is None):
1146 pull_branch = None1177 pull_branch = None
1147 if pull_branch is not None:1178 if pull_branch is not None:
@@ -1153,7 +1184,7 @@
1153 if not self.has_upstream_version(version.upstream_version):1184 if not self.has_upstream_version(version.upstream_version):
1154 up_pull_branch = \1185 up_pull_branch = \
1155 self.branch_to_pull_upstream_from(version.upstream_version,1186 self.branch_to_pull_upstream_from(version.upstream_version,
1156 upstream_md5)1187 upstream_tarballs)
1157 if up_pull_branch is not None:1188 if up_pull_branch is not None:
1158 self.pull_upstream_from_branch(up_pull_branch,1189 self.pull_upstream_from_branch(up_pull_branch,
1159 version.upstream_version)1190 version.upstream_version)
@@ -1165,8 +1196,8 @@
1165 version.upstream_version)1196 version.upstream_version)
1166 _, new_revid = self.import_upstream(upstream_part,1197 _, new_revid = self.import_upstream(upstream_part,
1167 version.upstream_version,1198 version.upstream_version,
1168 upstream_md5, upstream_parents,1199 upstream_parents,
1169 upstream_tarball=upstream_tarball,1200 upstream_tarballs=upstream_tarballs,
1170 timestamp=timestamp, author=author,1201 timestamp=timestamp, author=author,
1171 file_ids_from=file_ids_from)1202 file_ids_from=file_ids_from)
1172 self._fetch_upstream_to_branch(new_revid)1203 self._fetch_upstream_to_branch(new_revid)
@@ -1250,7 +1281,7 @@
1250 base_path = osutils.dirname(dsc_filename)1281 base_path = osutils.dirname(dsc_filename)
1251 dsc = deb822.Dsc(open(dsc_filename).read())1282 dsc = deb822.Dsc(open(dsc_filename).read())
1252 version = Version(dsc['Version'])1283 version = Version(dsc['Version'])
1253 format = dsc.get('Format', '1.0').strip()1284 format = dsc.get('Format', FORMAT_1_0).strip()
1254 extractor_cls = SOURCE_EXTRACTORS.get(format)1285 extractor_cls = SOURCE_EXTRACTORS.get(format)
1255 if extractor_cls is None:1286 if extractor_cls is None:
1256 raise AssertionError("Don't know how to import source format %s yet"1287 raise AssertionError("Don't know how to import source format %s yet"
@@ -1274,13 +1305,13 @@
1274 #TODO: check that the versions list is correctly ordered,1305 #TODO: check that the versions list is correctly ordered,
1275 # as some methods assume that, and it's not clear what1306 # as some methods assume that, and it's not clear what
1276 # should happen if it isn't.1307 # should happen if it isn't.
1308
1277 if extractor.extracted_upstream is not None:1309 if extractor.extracted_upstream is not None:
1278 self._do_import_package(version, versions,1310 self._import_normal_package(version, versions,
1279 extractor.extracted_debianised,1311 extractor.extracted_debianised,
1280 extractor.unextracted_debian_md5,1312 extractor.unextracted_debian_md5,
1281 extractor.extracted_upstream,1313 extractor.extracted_upstream,
1282 extractor.unextracted_upstream_md5,1314 extractor.upstream_tarballs,
1283 upstream_tarball=extractor.unextracted_upstream,
1284 timestamp=timestamp, author=author,1315 timestamp=timestamp, author=author,
1285 file_ids_from=file_ids_from,1316 file_ids_from=file_ids_from,
1286 pull_debian=pull_debian)1317 pull_debian=pull_debian)
@@ -1347,19 +1378,11 @@
1347 if root_id:1378 if root_id:
1348 self.upstream_tree.set_root_id(root_id)1379 self.upstream_tree.set_root_id(root_id)
13491380
1350 def _extract_tarball_to_tempdir(self, tarball_filename):1381 def _extract_tarballs_to_tempdir(self, tarballs):
1351 tempdir = tempfile.mkdtemp()1382 tempdir = tempfile.mkdtemp()
1352 if tarball_filename.endswith(".tar.bz2"):
1353 tar_args = 'xjf'
1354 else:
1355 tar_args = 'xzf'
1356 try:1383 try:
1357 proc = subprocess.Popen(["tar", tar_args, tarball_filename, "-C",1384 extract_orig_tarballs([fn for (fn, md5) in tarballs], tempdir,
1358 tempdir, "--strip-components", "1"],1385 strip_components=1)
1359 preexec_fn=subprocess_setup)
1360 proc.communicate()
1361 if proc.returncode != 0:
1362 raise TarFailed("extract", tarball_filename)
1363 return tempdir1386 return tempdir
1364 except:1387 except:
1365 shutil.rmtree(tempdir)1388 shutil.rmtree(tempdir)
@@ -1382,7 +1405,7 @@
1382 previous_version,1405 previous_version,
1383 self.pristine_tar_source.tag_name(previous_version)))1406 self.pristine_tar_source.tag_name(previous_version)))
13841407
1385 def merge_upstream(self, tarball_filename, package, version, previous_version,1408 def merge_upstream(self, tarball_filenames, package, version, previous_version,
1386 upstream_branch=None, upstream_revision=None, merge_type=None,1409 upstream_branch=None, upstream_revision=None, merge_type=None,
1387 force=False):1410 force=False):
1388 assert self.upstream_branch is None, \1411 assert self.upstream_branch is None, \
@@ -1412,17 +1435,17 @@
1412 if not force and graph.is_ancestor(upstream_revision,1435 if not force and graph.is_ancestor(upstream_revision,
1413 self.branch.last_revision()):1436 self.branch.last_revision()):
1414 raise UpstreamBranchAlreadyMerged1437 raise UpstreamBranchAlreadyMerged
1415 tarball_filename = os.path.abspath(tarball_filename)1438 upstream_tarballs = [
1416 md5sum = md5sum_filename(tarball_filename)1439 (os.path.abspath(fn), md5sum_filename(fn)) for fn in
1417 tarball_dir = self._extract_tarball_to_tempdir(tarball_filename)1440 tarball_filenames]
1441 tarball_dir = self._extract_tarballs_to_tempdir(upstream_tarballs)
1418 try:1442 try:
1419 # FIXME: should use upstream_parents()?1443 # FIXME: should use upstream_parents()?
1420 parents = []1444 parents = []
1421 if self.upstream_branch.last_revision() != NULL_REVISION:1445 if self.upstream_branch.last_revision() != NULL_REVISION:
1422 parents = [self.upstream_branch.last_revision()]1446 parents = [self.upstream_branch.last_revision()]
1423 _, new_revid = self.import_upstream(tarball_dir,1447 _, new_revid = self.import_upstream(tarball_dir,
1424 version,1448 version, parents, upstream_tarballs=upstream_tarballs,
1425 md5sum, parents, upstream_tarball=tarball_filename,
1426 upstream_branch=upstream_branch,1449 upstream_branch=upstream_branch,
1427 upstream_revision=upstream_revision)1450 upstream_revision=upstream_revision)
1428 self._fetch_upstream_to_branch(new_revid)1451 self._fetch_upstream_to_branch(new_revid)
@@ -1466,9 +1489,22 @@
1466 self.dsc = dsc1489 self.dsc = dsc
1467 self.extracted_upstream = None1490 self.extracted_upstream = None
1468 self.extracted_debianised = None1491 self.extracted_debianised = None
1469 self.unextracted_upstream = None
1470 self.unextracted_debian_md5 = None1492 self.unextracted_debian_md5 = None
1471 self.unextracted_upstream_md5 = None1493 self.upstream_tarballs = []
1494 self.tempdir = None
1495
1496 def extract(self):
1497 """Extract the package to a new temporary directory."""
1498 raise NotImplementedError(self.extract)
1499
1500 def cleanup(self):
1501 """Cleanup any extracted files."""
1502 if self.tempdir is not None and os.path.isdir(self.tempdir):
1503 shutil.rmtree(self.tempdir)
1504
1505
1506class OneZeroSourceExtractor(SourceExtractor):
1507 """Source extract for the "1.0" source format."""
14721508
1473 def extract(self):1509 def extract(self):
1474 """Extract the package to a new temporary directory."""1510 """Extract the package to a new temporary directory."""
@@ -1495,20 +1531,15 @@
1495 self.unextracted_debian_md5 = part['md5sum']1531 self.unextracted_debian_md5 = part['md5sum']
1496 else:1532 else:
1497 if part['name'].endswith(".orig.tar.gz"):1533 if part['name'].endswith(".orig.tar.gz"):
1498 assert self.unextracted_upstream is None, "Two .orig.tar.gz?"1534 self.upstream_tarballs.append((os.path.abspath(
1499 self.unextracted_upstream = os.path.abspath(
1500 os.path.join(osutils.dirname(self.dsc_path),1535 os.path.join(osutils.dirname(self.dsc_path),
1501 part['name']))1536 part['name'])), part['md5sum']))
1502 self.unextracted_upstream_md5 = part['md5sum']
1503 elif part['name'].endswith(".diff.gz"):1537 elif part['name'].endswith(".diff.gz"):
1504 self.unextracted_debian_md5 = part['md5sum']1538 self.unextracted_debian_md5 = part['md5sum']
15051539
1506 def cleanup(self):
1507 if os.path.exists(self.tempdir):
1508 shutil.rmtree(self.tempdir)
1509
15101540
1511class ThreeDotZeroNativeSourceExtractor(SourceExtractor):1541class ThreeDotZeroNativeSourceExtractor(SourceExtractor):
1542 """Source extractor for the "3.0 (native)" source format."""
15121543
1513 def extract(self):1544 def extract(self):
1514 self.tempdir = tempfile.mkdtemp()1545 self.tempdir = tempfile.mkdtemp()
@@ -1531,6 +1562,7 @@
15311562
15321563
1533class ThreeDotZeroQuiltSourceExtractor(SourceExtractor):1564class ThreeDotZeroQuiltSourceExtractor(SourceExtractor):
1565 """Source extractor for the "3.0 (quilt)" source format."""
15341566
1535 def extract(self):1567 def extract(self):
1536 self.tempdir = tempfile.mkdtemp()1568 self.tempdir = tempfile.mkdtemp()
@@ -1560,25 +1592,20 @@
1560 subprocess.call(["find", self.extracted_debianised, "-perm",1592 subprocess.call(["find", self.extracted_debianised, "-perm",
1561 "0000", "-exec", "chmod", "644", "{}", ";"])1593 "0000", "-exec", "chmod", "644", "{}", ";"])
1562 for part in self.dsc['files']:1594 for part in self.dsc['files']:
1563 if (re.search("\.orig-[^.]+\.tar\.(gz|bz2|lzma)$", part['name'])):1595 if part['name'].startswith("%s_%s.orig" % (name, str(version.upstream_version))):
1564 raise MultipleUpstreamTarballsNotSupported()1596 self.upstream_tarballs.append((os.path.abspath(
1565 if (part['name'].endswith(".orig.tar.gz")
1566 or part['name'].endswith(".orig.tar.bz2")):
1567 assert self.unextracted_upstream is None, "Two .orig.tar.(gz|bz2)?"
1568 self.unextracted_upstream = os.path.abspath(
1569 os.path.join(osutils.dirname(self.dsc_path),1597 os.path.join(osutils.dirname(self.dsc_path),
1570 part['name']))1598 part['name'])), part['md5sum']))
1571 self.unextracted_upstream_md5 = part['md5sum']
1572 elif (part['name'].endswith(".debian.tar.gz")1599 elif (part['name'].endswith(".debian.tar.gz")
1573 or part['name'].endswith(".debian.tar.bz2")):1600 or part['name'].endswith(".debian.tar.bz2")):
1574 self.unextracted_debian_md5 = part['md5sum']1601 self.unextracted_debian_md5 = part['md5sum']
1575 assert self.unextracted_upstream is not None, \1602 assert self.upstream_tarballs is not None, \
1576 "Can't handle non gz|bz2 tarballs yet"1603 "Can't handle non gz|bz2 tarballs yet"
1577 assert self.unextracted_debian_md5 is not None, \1604 assert self.unextracted_debian_md5 is not None, \
1578 "Can't handle non gz|bz2 tarballs yet"1605 "Can't handle non gz|bz2 tarballs yet"
15791606
15801607
1581SOURCE_EXTRACTORS = {}1608SOURCE_EXTRACTORS = {}
1582SOURCE_EXTRACTORS["1.0"] = SourceExtractor1609SOURCE_EXTRACTORS[FORMAT_1_0] = OneZeroSourceExtractor
1583SOURCE_EXTRACTORS[FORMAT_3_0_NATIVE] = ThreeDotZeroNativeSourceExtractor1610SOURCE_EXTRACTORS[FORMAT_3_0_NATIVE] = ThreeDotZeroNativeSourceExtractor
1584SOURCE_EXTRACTORS[FORMAT_3_0_QUILT] = ThreeDotZeroQuiltSourceExtractor1611SOURCE_EXTRACTORS[FORMAT_3_0_QUILT] = ThreeDotZeroQuiltSourceExtractor
15851612
=== modified file 'source_distiller.py'
--- source_distiller.py 2011-06-14 14:04:53 +0000
+++ source_distiller.py 2011-06-15 02:38:47 +0000
@@ -20,20 +20,15 @@
20import glob20import glob
21import os21import os
22import shutil22import shutil
23import subprocess
24import tempfile23import tempfile
2524
26from bzrlib import errors as bzr_errors25from bzrlib import errors as bzr_errors
2726
28from bzrlib.plugins.builddeb.errors import (
29 MultipleUpstreamTarballsNotSupported,
30 TarFailed,
31 )
32from bzrlib.plugins.builddeb.util import (27from bzrlib.plugins.builddeb.util import (
33 export,28 export,
29 extract_orig_tarballs,
34 get_parent_dir,30 get_parent_dir,
35 recursive_copy,31 recursive_copy,
36 subprocess_setup,
37 )32 )
3833
3934
@@ -123,16 +118,10 @@
123 os.makedirs(parent_dir)118 os.makedirs(parent_dir)
124 if not self.use_existing:119 if not self.use_existing:
125 tarballs = self.upstream_provider.provide(parent_dir)120 tarballs = self.upstream_provider.provide(parent_dir)
126 if len(tarballs) > 1:
127 raise MultipleUpstreamTarballsNotSupported()
128 tarball = tarballs[0]
129 # Extract it to the right place121 # Extract it to the right place
130 tempdir = tempfile.mkdtemp(prefix='builddeb-merge-')122 tempdir = tempfile.mkdtemp(prefix='builddeb-merge-')
131 try:123 try:
132 ret = subprocess.call(['tar', '-C', tempdir, '-xf', tarball],124 extract_orig_tarballs(tarballs, tempdir)
133 preexec_fn=subprocess_setup)
134 if ret != 0:
135 raise TarFailed("uncompress", tarball)
136 files = glob.glob(tempdir+'/*')125 files = glob.glob(tempdir+'/*')
137 # If everything is in a single dir then move everything up one126 # If everything is in a single dir then move everything up one
138 # level.127 # level.
@@ -151,7 +140,7 @@
151 tempdir = os.path.join(basetempdir,"export")140 tempdir = os.path.join(basetempdir,"export")
152 if self.larstiq:141 if self.larstiq:
153 os.makedirs(tempdir)142 os.makedirs(tempdir)
154 export_dir = os.path.join(tempdir,'debian')143 export_dir = os.path.join(tempdir, 'debian')
155 else:144 else:
156 export_dir = tempdir145 export_dir = tempdir
157 if self.is_working_tree:146 if self.is_working_tree:
158147
=== modified file 'tests/blackbox/test_merge_upstream.py'
--- tests/blackbox/test_merge_upstream.py 2011-06-13 23:01:14 +0000
+++ tests/blackbox/test_merge_upstream.py 2011-06-15 02:38:47 +0000
@@ -30,6 +30,9 @@
30 DistributionBranch,30 DistributionBranch,
31 DistributionBranchSet,31 DistributionBranchSet,
32 )32 )
33from bzrlib.plugins.builddeb.util import (
34 md5sum_filename,
35 )
3336
3437
35class Fixture(object):38class Fixture(object):
@@ -91,10 +94,11 @@
91 upstream_tree=tree)94 upstream_tree=tree)
92 dbs = DistributionBranchSet()95 dbs = DistributionBranchSet()
93 dbs.add_branch(db)96 dbs.add_branch(db)
94 db.import_upstream_tarball(self.tar.tarball, str(self.tar.version),97 db.import_upstream_tarball(
95 [tree.branch.last_revision()])98 [(self.tar.tarball, md5sum_filename(self.tar.tarball))], str(self.tar.version),
99 [tree.branch.last_revision()])
96 package_builder = SourcePackageBuilder("foo",100 package_builder = SourcePackageBuilder("foo",
97 str(self.tar.version)+"-1")101 str(self.tar.version)+"-1")
98 package_builder.add_default_control()102 package_builder.add_default_control()
99 package_builder.write_debian_files(branchpath)103 package_builder.write_debian_files(branchpath)
100 tree.smart_add([tree.basedir])104 tree.smart_add([tree.basedir])
101105
=== modified file 'tests/test_import_dsc.py'
--- tests/test_import_dsc.py 2011-06-10 11:47:25 +0000
+++ tests/test_import_dsc.py 2011-06-15 02:38:47 +0000
@@ -35,13 +35,10 @@
35 tests,35 tests,
36 )36 )
3737
38from bzrlib.plugins.builddeb.errors import (
39 MultipleUpstreamTarballsNotSupported,
40 )
41from bzrlib.plugins.builddeb.import_dsc import (38from bzrlib.plugins.builddeb.import_dsc import (
42 DistributionBranch,39 DistributionBranch,
43 DistributionBranchSet,40 DistributionBranchSet,
44 SourceExtractor,41 OneZeroSourceExtractor,
45 SOURCE_EXTRACTORS,42 SOURCE_EXTRACTORS,
46 ThreeDotZeroNativeSourceExtractor,43 ThreeDotZeroNativeSourceExtractor,
47 ThreeDotZeroQuiltSourceExtractor,44 ThreeDotZeroQuiltSourceExtractor,
@@ -50,6 +47,9 @@
50 BuilddebTestCase,47 BuilddebTestCase,
51 SourcePackageBuilder,48 SourcePackageBuilder,
52 )49 )
50from bzrlib.plugins.builddeb.util import (
51 md5sum_filename,
52 )
5353
5454
55class _PristineTarFeature(tests.Feature):55class _PristineTarFeature(tests.Feature):
@@ -175,20 +175,27 @@
175 db = self.db1175 db = self.db1
176 version = "0.1"176 version = "0.1"
177 self.assertFalse(db.has_upstream_version(version))177 self.assertFalse(db.has_upstream_version(version))
178 self.assertFalse(db.has_upstream_version(version, self.fake_md5_1))178 self.assertFalse(db.has_upstream_version(version,
179 [("foo.tar.gz", self.fake_md5_1)]))
179 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)180 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)
180 db.tag_upstream_version(version)181 db.tag_upstream_version(version)
181 self.assertTrue(db.has_upstream_version(version))182 self.assertTrue(db.has_upstream_version(version))
182 self.assertTrue(db.has_upstream_version(version, self.fake_md5_1))183 self.assertTrue(db.has_upstream_version(
183 self.assertFalse(db.has_upstream_version(version, self.fake_md5_2))184 version, [("foo.tar.gz", self.fake_md5_1)]))
185 self.assertFalse(db.has_upstream_version(version,
186 [("foo.tar.gz", self.fake_md5_2)]))
184 version = "0.1"187 version = "0.1"
185 self.assertTrue(db.has_upstream_version(version))188 self.assertTrue(db.has_upstream_version(version))
186 self.assertTrue(db.has_upstream_version(version, self.fake_md5_1))189 self.assertTrue(db.has_upstream_version(version,
187 self.assertFalse(db.has_upstream_version(version, self.fake_md5_2))190 [("foo.tar.gz", self.fake_md5_1)]))
191 self.assertFalse(db.has_upstream_version(version,
192 [("foo.tar.gz", self.fake_md5_2)]))
188 version = "0.2"193 version = "0.2"
189 self.assertFalse(db.has_upstream_version(version))194 self.assertFalse(db.has_upstream_version(version))
190 self.assertFalse(db.has_upstream_version(version, self.fake_md5_1))195 self.assertFalse(db.has_upstream_version(version,
191 self.assertFalse(db.has_upstream_version(version, self.fake_md5_2))196 [("foo.tar.gz", self.fake_md5_1)]))
197 self.assertFalse(db.has_upstream_version(version,
198 [("foo.tar.gz", self.fake_md5_2)]))
192199
193 def test_revid_of_version(self):200 def test_revid_of_version(self):
194 db = self.db1201 db = self.db1
@@ -633,46 +640,46 @@
633 version2 = Version("0.2-1")640 version2 = Version("0.2-1")
634 # With no versions tagged everything is None641 # With no versions tagged everything is None
635 branch = self.db2.branch_to_pull_upstream_from(642 branch = self.db2.branch_to_pull_upstream_from(
636 version1.upstream_version, self.fake_md5_1)643 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
637 self.assertEqual(branch, None)644 self.assertEqual(branch, None)
638 branch = self.db2.branch_to_pull_upstream_from(645 branch = self.db2.branch_to_pull_upstream_from(
639 version1.upstream_version, self.fake_md5_2)646 version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)])
640 self.assertEqual(branch, None)647 self.assertEqual(branch, None)
641 branch = self.db1.branch_to_pull_upstream_from(648 branch = self.db1.branch_to_pull_upstream_from(
642 version1.upstream_version, self.fake_md5_1)649 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
643 self.assertEqual(branch, None)650 self.assertEqual(branch, None)
644 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)651 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)
645 self.db1.tag_upstream_version(version1.upstream_version)652 self.db1.tag_upstream_version(version1.upstream_version)
646 # Version and md5 available, so we get the correct branch.653 # Version and md5 available, so we get the correct branch.
647 branch = self.db2.branch_to_pull_upstream_from(654 branch = self.db2.branch_to_pull_upstream_from(
648 version1.upstream_version, self.fake_md5_1)655 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
649 self.assertEqual(branch, self.db1)656 self.assertEqual(branch, self.db1)
650 # Otherwise (different version or md5) then we get None657 # Otherwise (different version or md5) then we get None
651 branch = self.db2.branch_to_pull_upstream_from(658 branch = self.db2.branch_to_pull_upstream_from(
652 version1.upstream_version, self.fake_md5_2)659 version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)])
653 self.assertEqual(branch, None)660 self.assertEqual(branch, None)
654 branch = self.db2.branch_to_pull_upstream_from(version2.upstream_version,661 branch = self.db2.branch_to_pull_upstream_from(version2.upstream_version,
655 self.fake_md5_1)662 [("foo.tar.gz", self.fake_md5_1)])
656 self.assertEqual(branch, None)663 self.assertEqual(branch, None)
657 branch = self.db2.branch_to_pull_upstream_from(version2.upstream_version,664 branch = self.db2.branch_to_pull_upstream_from(version2.upstream_version,
658 self.fake_md5_2)665 [("foo.tar.gz", self.fake_md5_2)])
659 self.assertEqual(branch, None)666 self.assertEqual(branch, None)
660 # And we don't get a branch for the one that already has667 # And we don't get a branch for the one that already has
661 # the version668 # the version
662 branch = self.db1.branch_to_pull_upstream_from(669 branch = self.db1.branch_to_pull_upstream_from(
663 version1.upstream_version, self.fake_md5_1)670 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
664 self.assertEqual(branch, None)671 self.assertEqual(branch, None)
665 self.up_tree2.pull(self.up_tree1.branch)672 self.up_tree2.pull(self.up_tree1.branch)
666 self.db2.tag_upstream_version(version1.upstream_version)673 self.db2.tag_upstream_version(version1.upstream_version)
667 # And we get the greatest branch when two lesser branches674 # And we get the greatest branch when two lesser branches
668 # have what we are looking for.675 # have what we are looking for.
669 branch = self.db3.branch_to_pull_upstream_from(676 branch = self.db3.branch_to_pull_upstream_from(
670 version1.upstream_version, self.fake_md5_1)677 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
671 self.assertEqual(branch, self.db2)678 self.assertEqual(branch, self.db2)
672 # If the branches have diverged then we don't get a branch.679 # If the branches have diverged then we don't get a branch.
673 self.up_tree3.commit("three")680 self.up_tree3.commit("three")
674 branch = self.db3.branch_to_pull_upstream_from(681 branch = self.db3.branch_to_pull_upstream_from(
675 version1.upstream_version, self.fake_md5_1)682 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])
676 self.assertEqual(branch, None)683 self.assertEqual(branch, None)
677684
678 def test_pull_from_lesser_branch_no_upstream(self):685 def test_pull_from_lesser_branch_no_upstream(self):
@@ -764,8 +771,7 @@
764 contents = [(basedir + '/' + element[0],) + element[1:] for771 contents = [(basedir + '/' + element[0],) + element[1:] for
765 element in contents]772 element in contents]
766 self.build_tree_contents(contents)773 self.build_tree_contents(contents)
767 self.db1.import_upstream(basedir, version.upstream_version, 774 self.db1.import_upstream(basedir, version.upstream_version, [])
768 self.fake_md5_1, [])
769 return version775 return version
770776
771 def test_import_upstream(self):777 def test_import_upstream(self):
@@ -779,7 +785,7 @@
779 rev = branch.repository.get_revision(rh[0])785 rev = branch.repository.get_revision(rh[0])
780 self.assertEqual(rev.message,786 self.assertEqual(rev.message,
781 "Import upstream version %s" % str(version.upstream_version))787 "Import upstream version %s" % str(version.upstream_version))
782 self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1)788 self.assertEqual(rev.properties.get('deb-md5'), None)
783789
784 def test_import_upstream_preserves_dot_bzrignore(self):790 def test_import_upstream_preserves_dot_bzrignore(self):
785 self.import_a_tree([('',), ('.bzrignore', '')])791 self.import_a_tree([('',), ('.bzrignore', '')])
@@ -799,15 +805,13 @@
799 write_to_file(os.path.join(basedir, "README"), "Hi\n")805 write_to_file(os.path.join(basedir, "README"), "Hi\n")
800 write_to_file(os.path.join(basedir, "BUGS"), "")806 write_to_file(os.path.join(basedir, "BUGS"), "")
801 write_to_file(os.path.join(basedir, "COPYING"), "")807 write_to_file(os.path.join(basedir, "COPYING"), "")
802 self.db1.import_upstream(basedir, version1.upstream_version,808 self.db1.import_upstream(basedir, version1.upstream_version, [])
803 self.fake_md5_1, [])
804 basedir = name + "-" + str(version2.upstream_version)809 basedir = name + "-" + str(version2.upstream_version)
805 os.mkdir(basedir)810 os.mkdir(basedir)
806 write_to_file(os.path.join(basedir, "README"), "Now even better\n")811 write_to_file(os.path.join(basedir, "README"), "Now even better\n")
807 write_to_file(os.path.join(basedir, "BUGS"), "")812 write_to_file(os.path.join(basedir, "BUGS"), "")
808 write_to_file(os.path.join(basedir, "NEWS"), "")813 write_to_file(os.path.join(basedir, "NEWS"), "")
809 self.db1.import_upstream(basedir, version2.upstream_version, 814 self.db1.import_upstream(basedir, version2.upstream_version,
810 self.fake_md5_2,
811 [self.up_tree1.branch.last_revision()])815 [self.up_tree1.branch.last_revision()])
812 tree = self.up_tree1816 tree = self.up_tree1
813 branch = tree.branch817 branch = tree.branch
@@ -817,7 +821,7 @@
817 rev = branch.repository.get_revision(rh[1])821 rev = branch.repository.get_revision(rh[1])
818 self.assertEqual(rev.message,822 self.assertEqual(rev.message,
819 "Import upstream version %s" % str(version2.upstream_version))823 "Import upstream version %s" % str(version2.upstream_version))
820 self.assertEqual(rev.properties['deb-md5'], self.fake_md5_2)824 self.assertIs(rev.properties.get('deb-md5'), None)
821 rev_tree1 = branch.repository.revision_tree(rh[0])825 rev_tree1 = branch.repository.revision_tree(rh[0])
822 rev_tree2 = branch.repository.revision_tree(rh[1])826 rev_tree2 = branch.repository.revision_tree(rh[1])
823 changes = rev_tree2.changes_from(rev_tree1)827 changes = rev_tree2.changes_from(rev_tree1)
@@ -838,8 +842,8 @@
838 tf.add(basedir)842 tf.add(basedir)
839 finally:843 finally:
840 tf.close()844 tf.close()
841 self.db1.import_upstream(basedir, version.upstream_version, 845 self.db1.import_upstream(basedir, version.upstream_version, [],
842 self.fake_md5_1, [], upstream_tarball=os.path.abspath(tar_path))846 upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)])
843 tree = self.up_tree1847 tree = self.up_tree1
844 branch = tree.branch848 branch = tree.branch
845 rh = branch.revision_history()849 rh = branch.revision_history()
@@ -866,8 +870,8 @@
866 tf.add(basedir)870 tf.add(basedir)
867 finally:871 finally:
868 tf.close()872 tf.close()
869 self.db1.import_upstream(basedir, version.upstream_version, 873 self.db1.import_upstream(basedir, version.upstream_version,
870 self.fake_md5_1, [], upstream_tarball=os.path.abspath(tar_path))874 [], upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)])
871 tree = self.up_tree1875 tree = self.up_tree1
872 branch = tree.branch876 branch = tree.branch
873 rh = branch.revision_history()877 rh = branch.revision_history()
@@ -1496,7 +1500,7 @@
1496 tf.add("a")1500 tf.add("a")
1497 finally:1501 finally:
1498 tf.close()1502 tf.close()
1499 conflicts = db.merge_upstream(tarball_filename, "foo", "0.2", "0.1")1503 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1")
1500 self.assertEqual(0, conflicts)1504 self.assertEqual(0, conflicts)
15011505
1502 def test_merge_upstream_initial_with_branch(self):1506 def test_merge_upstream_initial_with_branch(self):
@@ -1533,7 +1537,7 @@
1533 tf.add("a")1537 tf.add("a")
1534 finally:1538 finally:
1535 tf.close()1539 tf.close()
1536 conflicts = db.merge_upstream(tarball_filename, "foo", "0.2", "0.1",1540 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1",
1537 upstream_branch=upstream_tree.branch,1541 upstream_branch=upstream_tree.branch,
1538 upstream_revision=upstream_rev)1542 upstream_revision=upstream_rev)
1539 self.assertEqual(0, conflicts)1543 self.assertEqual(0, conflicts)
@@ -1573,7 +1577,7 @@
1573 tf.add("a")1577 tf.add("a")
1574 finally:1578 finally:
1575 tf.close()1579 tf.close()
1576 conflicts = db.merge_upstream(tarball_filename, "foo", "0.2", "0.1",1580 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1",
1577 upstream_branch=upstream_tree.branch,1581 upstream_branch=upstream_tree.branch,
1578 upstream_revision=upstream_rev)1582 upstream_revision=upstream_rev)
1579 # ./debian conflicts.1583 # ./debian conflicts.
@@ -1614,7 +1618,7 @@
1614 dbs.add_branch(db)1618 dbs.add_branch(db)
1615 tree.lock_write()1619 tree.lock_write()
1616 self.addCleanup(tree.unlock)1620 self.addCleanup(tree.unlock)
1617 db.merge_upstream(builder.tar_name(), "package", str(version2),1621 db.merge_upstream([builder.tar_name()], "package", str(version2),
1618 version1.upstream_version,1622 version1.upstream_version,
1619 upstream_branch=upstream_tree.branch,1623 upstream_branch=upstream_tree.branch,
1620 upstream_revision=upstream_rev)1624 upstream_revision=upstream_rev)
@@ -1653,7 +1657,7 @@
1653 tf.add("a")1657 tf.add("a")
1654 finally:1658 finally:
1655 tf.close()1659 tf.close()
1656 conflicts = db.merge_upstream(tarball_filename, "package", "0.2-1",1660 conflicts = db.merge_upstream([tarball_filename], "package", "0.2-1",
1657 "0.1")1661 "0.1")
1658 # Check that we tagged wiht the dash version1662 # Check that we tagged wiht the dash version
1659 self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1'))1663 self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1'))
@@ -1692,7 +1696,7 @@
1692 # We don't add the new file upstream, as the new file id would1696 # We don't add the new file upstream, as the new file id would
1693 # be picked up from there.1697 # be picked up from there.
1694 upstream_rev2 = upstream_tree.commit("two")1698 upstream_rev2 = upstream_tree.commit("two")
1695 db.merge_upstream(builder.tar_name(), "package",1699 db.merge_upstream([builder.tar_name()], "package",
1696 version2.upstream_version,1700 version2.upstream_version,
1697 version1.upstream_version,1701 version1.upstream_version,
1698 upstream_branch=upstream_tree.branch,1702 upstream_branch=upstream_tree.branch,
@@ -1729,7 +1733,7 @@
1729 # We don't add the new file upstream, as the new file id would1733 # We don't add the new file upstream, as the new file id would
1730 # be picked up from there.1734 # be picked up from there.
1731 upstream_rev2 = upstream_tree.commit("two")1735 upstream_rev2 = upstream_tree.commit("two")
1732 db.merge_upstream(builder.tar_name(), "package",1736 db.merge_upstream([builder.tar_name()], "package",
1733 version2.upstream_version,1737 version2.upstream_version,
1734 version1.upstream_version,1738 version1.upstream_version,
1735 upstream_branch=upstream_tree.branch,1739 upstream_branch=upstream_tree.branch,
@@ -1762,7 +1766,7 @@
1762 builder.add_upstream_file("a", "New a")1766 builder.add_upstream_file("a", "New a")
1763 builder.add_upstream_file("b", "Renamed a")1767 builder.add_upstream_file("b", "Renamed a")
1764 builder.build()1768 builder.build()
1765 db.merge_upstream(builder.tar_name(), "packaging",1769 db.merge_upstream([builder.tar_name()], "packaging",
1766 version2.upstream_version, version1.upstream_version)1770 version2.upstream_version, version1.upstream_version)
1767 self.assertEqual("a-id", packaging_tree.path2id("b"))1771 self.assertEqual("a-id", packaging_tree.path2id("b"))
1768 self.assertEqual("other-a-id", packaging_tree.path2id("a"))1772 self.assertEqual("other-a-id", packaging_tree.path2id("a"))
@@ -1778,7 +1782,7 @@
1778 self.db1.import_package(builder.dsc_name())1782 self.db1.import_package(builder.dsc_name())
17791783
17801784
1781class SourceExtractorTests(tests.TestCaseInTempDir):1785class OneZeroSourceExtractorTests(tests.TestCaseInTempDir):
17821786
1783 def test_extract_format1(self):1787 def test_extract_format1(self):
1784 version = Version("0.1-1")1788 version = Version("0.1-1")
@@ -1789,8 +1793,8 @@
1789 builder.add_default_control()1793 builder.add_default_control()
1790 builder.build()1794 builder.build()
1791 dsc = deb822.Dsc(open(builder.dsc_name()).read())1795 dsc = deb822.Dsc(open(builder.dsc_name()).read())
1792 self.assertEqual(SourceExtractor, SOURCE_EXTRACTORS[dsc['Format']])1796 self.assertEqual(OneZeroSourceExtractor, SOURCE_EXTRACTORS[dsc['Format']])
1793 extractor = SourceExtractor(builder.dsc_name(), dsc)1797 extractor = OneZeroSourceExtractor(builder.dsc_name(), dsc)
1794 try:1798 try:
1795 extractor.extract()1799 extractor.extract()
1796 unpacked_dir = extractor.extracted_debianised1800 unpacked_dir = extractor.extracted_debianised
@@ -1805,7 +1809,7 @@
1805 "README")))1809 "README")))
1806 self.assertFalse(os.path.exists(os.path.join(orig_dir,1810 self.assertFalse(os.path.exists(os.path.join(orig_dir,
1807 "debian", "control")))1811 "debian", "control")))
1808 self.assertTrue(os.path.exists(extractor.unextracted_upstream))1812 self.assertTrue(os.path.exists(extractor.upstream_tarballs[0][0]))
1809 finally:1813 finally:
1810 extractor.cleanup()1814 extractor.cleanup()
18111815
@@ -1818,8 +1822,8 @@
1818 builder.add_default_control()1822 builder.add_default_control()
1819 builder.build()1823 builder.build()
1820 dsc = deb822.Dsc(open(builder.dsc_name()).read())1824 dsc = deb822.Dsc(open(builder.dsc_name()).read())
1821 self.assertEqual(SourceExtractor, SOURCE_EXTRACTORS[dsc['Format']])1825 self.assertEqual(OneZeroSourceExtractor, SOURCE_EXTRACTORS[dsc['Format']])
1822 extractor = SourceExtractor(builder.dsc_name(), dsc)1826 extractor = OneZeroSourceExtractor(builder.dsc_name(), dsc)
1823 try:1827 try:
1824 extractor.extract()1828 extractor.extract()
1825 unpacked_dir = extractor.extracted_debianised1829 unpacked_dir = extractor.extracted_debianised
@@ -1886,7 +1890,7 @@
1886 "README")))1890 "README")))
1887 self.assertFalse(os.path.exists(os.path.join(orig_dir,1891 self.assertFalse(os.path.exists(os.path.join(orig_dir,
1888 "debian", "control")))1892 "debian", "control")))
1889 self.assertTrue(os.path.exists(extractor.unextracted_upstream))1893 self.assertTrue(os.path.exists(extractor.upstream_tarballs[0][0]))
1890 finally:1894 finally:
1891 extractor.cleanup()1895 extractor.cleanup()
18921896
@@ -1916,7 +1920,7 @@
1916 "README")))1920 "README")))
1917 self.assertFalse(os.path.exists(os.path.join(orig_dir,1921 self.assertFalse(os.path.exists(os.path.join(orig_dir,
1918 "debian", "control")))1922 "debian", "control")))
1919 self.assertTrue(os.path.exists(extractor.unextracted_upstream))1923 self.assertTrue(os.path.exists(extractor.upstream_tarballs[0][0]))
1920 finally:1924 finally:
1921 extractor.cleanup()1925 extractor.cleanup()
19221926
@@ -1936,4 +1940,4 @@
1936 SOURCE_EXTRACTORS[dsc['Format']])1940 SOURCE_EXTRACTORS[dsc['Format']])
1937 extractor = ThreeDotZeroQuiltSourceExtractor(builder.dsc_name(), dsc)1941 extractor = ThreeDotZeroQuiltSourceExtractor(builder.dsc_name(), dsc)
1938 self.addCleanup(extractor.cleanup)1942 self.addCleanup(extractor.cleanup)
1939 self.assertRaises(MultipleUpstreamTarballsNotSupported, extractor.extract)1943 self.assertEquals([], extractor.upstream_tarballs)
19401944
=== modified file 'util.py'
--- util.py 2011-06-09 12:13:13 +0000
+++ util.py 2011-06-15 02:38:47 +0000
@@ -24,6 +24,7 @@
24 import md524 import md5
25import signal25import signal
26import shutil26import shutil
27import subprocess
27import tempfile28import tempfile
28import os29import os
29import re30import re
@@ -65,7 +66,9 @@
65 MissingChangelogError,66 MissingChangelogError,
66 AddChangelogError,67 AddChangelogError,
67 InconsistentSourceFormatError,68 InconsistentSourceFormatError,
69 MultipleUpstreamTarballsNotSupported,
68 NoPreviousUpload,70 NoPreviousUpload,
71 TarFailed,
69 UnableToFindPreviousUpload,72 UnableToFindPreviousUpload,
70 UnparseableChangelog,73 UnparseableChangelog,
71 )74 )
@@ -682,4 +685,24 @@
682 return BUILD_TYPE_NORMAL685 return BUILD_TYPE_NORMAL
683686
684687
688def extract_orig_tarballs(tarballs, target, strip_components=None):
689 """Extract orig tarballs to a directory.
685690
691 :param tarballs: List of tarball filenames
692 :param target: Target directory (must already exist)
693 """
694 if len(tarballs) != 1:
695 raise MultipleUpstreamTarballsNotSupported()
696 tarball_filename = tarballs[0]
697 tar_args = ["tar"]
698 if tarball_filename.endswith(".tar.bz2"):
699 tar_args.append('xjf')
700 else:
701 tar_args.append('xzf')
702 tar_args.extend([tarball_filename, "-C", target])
703 if strip_components is not None:
704 tar_args.extend(["--strip-components", "1"])
705 proc = subprocess.Popen(tar_args, preexec_fn=subprocess_setup)
706 proc.communicate()
707 if proc.returncode != 0:
708 raise TarFailed("extract", tarball_filename)

Subscribers

People subscribed via source and target branches