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

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 595
Merged at revision: 576
Proposed branch: lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt4
Merge into: lp:bzr-builddeb
Diff against target: 905 lines (+255/-142)
12 files modified
__init__.py (+0/-1)
cmds.py (+16/-7)
dh_make.py (+4/-3)
import_dsc.py (+42/-63)
source_distiller.py (+5/-5)
tests/blackbox/test_merge_upstream.py (+3/-1)
tests/test_import_dsc.py (+41/-39)
tests/test_upstream.py (+5/-1)
tests/test_util.py (+38/-9)
upstream/__init__.py (+5/-2)
upstream/pristinetar.py (+47/-1)
util.py (+49/-10)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt4
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+65738@code.launchpad.net

Description of the change

Part 4 on the way to support multiple upstream tarballs.

* Move the main code for importing a single upstream tarballs to PristineTarSource.
* Make various methods that call import_upstream{,_tarballs} cope with it returning a list of (component, tag_name, revid) tuples rather than a single tag and revision id

Next is actually supporting non-base tarball imports in PristineTarSource.import_component_tarball.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

This looks fine.

What's your plan for representing the multiple upstream tarballs in
the tree and revision history?

Thanks,

James

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 06/24/2011 02:17 AM, James Westby wrote:
> Review: Approve
> Hi,
>
> This looks fine.
Appreciated, as always :)
>
> What's your plan for representing the multiple upstream tarballs in
> the tree and revision history?

Basically importing each upstream component tarball as a separate
revision with its own history and tagging them appropriately:

  * "upstream-1.0" for bar_1.0.orig.tar.bz2
  * "upstream-1.0/bla" for bar_1.0.orig-bla.tar.bz2

... and then having the package branch take these revisions as parents,
making the components look like by-value nested trees. If an upstream
component tarball hasn't changed between upstream releases we just retag
it.

Does that sounds reasonable?

I'm also wondering if we should add a "deb-components" revision property
so that we don't accidentally forget to export component tarballs if the
appropriate tags are missing. What do you think?

Cheers,

Jelmer

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

On Fri, 24 Jun 2011 02:39:45 +0200, Jelmer Vernooij <email address hidden> wrote:
> Basically importing each upstream component tarball as a separate
> revision with its own history and tagging them appropriately:
>
> * "upstream-1.0" for bar_1.0.orig.tar.bz2
> * "upstream-1.0/bla" for bar_1.0.orig-bla.tar.bz2
>
> ... and then having the package branch take these revisions as parents,
> making the components look like by-value nested trees. If an upstream
> component tarball hasn't changed between upstream releases we just retag
> it.

That sounds pretty good to me.

I wonder what the merge-upstream command line will look like to do all
this :-)

> I'm also wondering if we should add a "deb-components" revision property
> so that we don't accidentally forget to export component tarballs if the
> appropriate tags are missing. What do you think?

That sounds like a good idea, but I don't know if we'll be able to set
it in all circumstances. I think if it can be set then we should and
should use it.

Thanks,

James

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 24/06/11 03:12, James Westby wrote:
> On Fri, 24 Jun 2011 02:39:45 +0200, Jelmer Vernooij<email address hidden> wrote:
>> Basically importing each upstream component tarball as a separate
>> revision with its own history and tagging them appropriately:
>>
>> * "upstream-1.0" for bar_1.0.orig.tar.bz2
>> * "upstream-1.0/bla" for bar_1.0.orig-bla.tar.bz2
>>
>> ... and then having the package branch take these revisions as parents,
>> making the components look like by-value nested trees. If an upstream
>> component tarball hasn't changed between upstream releases we just retag
>> it.
> That sounds pretty good to me.
>
> I wonder what the merge-upstream command line will look like to do all
> this :-)
Yeah, that will be nasty. :-( Doing it as part of import-dsc (and udd)
is a lot easier as we can just read everything from the .dsc file.

Like the merge-upstream command-line, we'll have to update the
configuration file to support multiple upstream branches and multiple
upstream tag schemes.

>> I'm also wondering if we should add a "deb-components" revision property
>> so that we don't accidentally forget to export component tarballs if the
>> appropriate tags are missing. What do you think?
> That sounds like a good idea, but I don't know if we'll be able to set
> it in all circumstances. I think if it can be set then we should and
> should use it.
Cool, I'll add it.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2011-06-03 14:42:26 +0000
+++ __init__.py 2011-06-23 21:47:20 +0000
@@ -24,7 +24,6 @@
24"""bzr-builddeb - manage packages in a Bazaar branch."""24"""bzr-builddeb - manage packages in a Bazaar branch."""
2525
26import os26import os
27import re
2827
29import bzrlib28import bzrlib
30from bzrlib.commands import plugin_cmds29from bzrlib.commands import plugin_cmds
3130
=== modified file 'cmds.py'
--- cmds.py 2011-06-21 20:55:13 +0000
+++ cmds.py 2011-06-23 21:47:20 +0000
@@ -108,6 +108,7 @@
108from bzrlib.plugins.builddeb.util import (108from bzrlib.plugins.builddeb.util import (
109 FORMAT_3_0_QUILT,109 FORMAT_3_0_QUILT,
110 FORMAT_3_0_NATIVE,110 FORMAT_3_0_NATIVE,
111 component_from_orig_tarball,
111 debuild_config,112 debuild_config,
112 dget_changes,113 dget_changes,
113 find_changelog,114 find_changelog,
@@ -560,7 +561,9 @@
560 db = DistributionBranch(tree.branch, tree.branch, tree=tree)561 db = DistributionBranch(tree.branch, tree.branch, tree=tree)
561 dbs = DistributionBranchSet()562 dbs = DistributionBranchSet()
562 dbs.add_branch(db)563 dbs.add_branch(db)
563 conflicts = db.merge_upstream(tarball_filenames, package, version,564 tarballs = [(p, component_from_orig_tarball(p, package, version)) for p
565 in tarball_filenames]
566 conflicts = db.merge_upstream(tarballs, package, version,
564 current_version, upstream_branch=upstream_branch,567 current_version, upstream_branch=upstream_branch,
565 upstream_revision=upstream_revision,568 upstream_revision=upstream_revision,
566 merge_type=merge_type, force=force)569 merge_type=merge_type, force=force)
@@ -588,7 +591,7 @@
588 ret.append(tarball_filename)591 ret.append(tarball_filename)
589 return ret592 return ret
590593
591 def _get_tarball(self, config, tree, package, version, upstream_branch,594 def _get_tarballs(self, config, tree, package, version, upstream_branch,
592 upstream_revision, v3, locations):595 upstream_revision, v3, locations):
593 orig_dir = config.orig_dir or default_orig_dir596 orig_dir = config.orig_dir or default_orig_dir
594 orig_dir = os.path.join(tree.basedir, orig_dir)597 orig_dir = os.path.join(tree.basedir, orig_dir)
@@ -747,7 +750,7 @@
747 source_format = get_source_format(tree)750 source_format = get_source_format(tree)
748 v3 = (source_format in [751 v3 = (source_format in [
749 FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE])752 FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE])
750 tarball_filenames = self._get_tarball(config, tree, package,753 tarball_filenames = self._get_tarballs(config, tree, package,
751 version, upstream_branch, upstream_revision, v3,754 version, upstream_branch, upstream_revision, v3,
752 locations)755 locations)
753 conflicts = self._do_merge(tree, tarball_filenames, package,756 conflicts = self._do_merge(tree, tarball_filenames, package,
@@ -977,10 +980,16 @@
977 else:980 else:
978 raise BzrCommandError('bzr import-upstream --revision takes exactly'981 raise BzrCommandError('bzr import-upstream --revision takes exactly'
979 ' one revision specifier.')982 ' one revision specifier.')
980 tarballs = [(location, md5sum_filename(location))]983 tarballs = [(location, None, md5sum_filename(location))]
981 tag_name, _ = db.import_upstream_tarballs(tarballs, version, parents,984 for (component, tag_name, revid) in db.import_upstream_tarballs(
982 upstream_branch=upstream, upstream_revision=upstream_revid)985 tarballs, None, version, parents, upstream_branch=upstream,
983 self.outf.write('Imported %s as tag:%s.\n' % (location, tag_name))986 upstream_revision=upstream_revid):
987 if component is None:
988 self.outf.write('Imported %s as tag:%s.\n' % (
989 location, tag_name))
990 else:
991 self.outf.write('Imported %s (%s) as tag:%s.\n' % (
992 location, component, tag_name))
984993
985994
986class cmd_bd_do(Command):995class cmd_bd_do(Command):
987996
=== modified file 'dh_make.py'
--- dh_make.py 2011-06-15 16:35:46 +0000
+++ dh_make.py 2011-06-23 21:47:20 +0000
@@ -70,8 +70,8 @@
70 orig_dir, [])70 orig_dir, [])
71 orig_files = provider.provide(os.path.join(tree.basedir, ".."))71 orig_files = provider.provide(os.path.join(tree.basedir, ".."))
72 ret = []72 ret = []
73 for filename in orig_files:73 for filename, component in orig_files:
74 ret.append((filename, util.md5sum_filename(filename)))74 ret.append((filename, component, util.md5sum_filename(filename)))
75 return ret75 return ret
7676
7777
@@ -87,7 +87,8 @@
87 pristine_upstream_tree=tree)87 pristine_upstream_tree=tree)
88 dbs = import_dsc.DistributionBranchSet()88 dbs = import_dsc.DistributionBranchSet()
89 dbs.add_branch(db)89 dbs.add_branch(db)
90 db.import_upstream_tarballs(tarball_filenames, version, parents)90 db.import_upstream_tarballs(tarball_filenames, package_name, version,
91 parents)
91 return tree92 return tree
9293
9394
9495
=== modified file 'import_dsc.py'
--- import_dsc.py 2011-06-15 16:35:46 +0000
+++ import_dsc.py 2011-06-23 21:47:20 +0000
@@ -49,7 +49,6 @@
49 AlreadyBranchError,49 AlreadyBranchError,
50 BzrCommandError,50 BzrCommandError,
51 NotBranchError,51 NotBranchError,
52 NoSuchRevision,
53 NoWorkingTree,52 NoWorkingTree,
54 UnrelatedBranches,53 UnrelatedBranches,
55 )54 )
@@ -61,7 +60,6 @@
6160
62from bzrlib.plugins.builddeb.bzrtools_import import import_dir61from bzrlib.plugins.builddeb.bzrtools_import import import_dir
63from bzrlib.plugins.builddeb.errors import (62from bzrlib.plugins.builddeb.errors import (
64 MultipleUpstreamTarballsNotSupported,
65 UpstreamAlreadyImported,63 UpstreamAlreadyImported,
66 UpstreamBranchAlreadyMerged,64 UpstreamBranchAlreadyMerged,
67 )65 )
@@ -69,6 +67,7 @@
69 FORMAT_1_0,67 FORMAT_1_0,
70 FORMAT_3_0_QUILT,68 FORMAT_3_0_QUILT,
71 FORMAT_3_0_NATIVE,69 FORMAT_3_0_NATIVE,
70 component_from_orig_tarball,
72 extract_orig_tarballs,71 extract_orig_tarballs,
73 get_commit_info_from_changelog,72 get_commit_info_from_changelog,
74 md5sum_filename,73 md5sum_filename,
@@ -77,9 +76,6 @@
77 safe_decode,76 safe_decode,
78 subprocess_setup,77 subprocess_setup,
79 )78 )
80from bzrlib.plugins.builddeb.upstream.branch import (
81 UpstreamBranchSource,
82 )
83from bzrlib.plugins.builddeb.upstream.pristinetar import (79from bzrlib.plugins.builddeb.upstream.pristinetar import (
84 PristineTarSource,80 PristineTarSource,
85 )81 )
@@ -475,13 +471,8 @@
475 tag_name = self.pristine_upstream_source.tag_name(version)471 tag_name = self.pristine_upstream_source.tag_name(version)
476 if revid is None:472 if revid is None:
477 revid = self.pristine_upstream_branch.last_revision()473 revid = self.pristine_upstream_branch.last_revision()
478 self.pristine_upstream_branch.tags.set_tag(tag_name, revid)474 self.pristine_upstream_source.tag_version(version, revid)
479 try:475 self.branch.fetch(self.pristine_upstream_branch)
480 self.branch.repository.fetch(self.pristine_upstream_branch.repository,
481 revision_id=revid)
482 except NoSuchRevision:
483 # See bug lp:574223
484 pass
485 self.branch.tags.set_tag(tag_name, revid)476 self.branch.tags.set_tag(tag_name, revid)
486 return tag_name, revid477 return tag_name, revid
487478
@@ -724,7 +715,7 @@
724 "Can't pull upstream with no tree"715 "Can't pull upstream with no tree"
725 self.pristine_upstream_tree.pull(up_pull_branch,716 self.pristine_upstream_tree.pull(up_pull_branch,
726 stop_revision=pull_revision)717 stop_revision=pull_revision)
727 self.tag_upstream_version(version, revid=pull_revision)718 self.pristine_upstream_source.tag_version(version, pull_revision)
728 self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision)719 self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision)
729 self.pristine_upstream_branch.tags.merge_to(self.branch.tags)720 self.pristine_upstream_branch.tags.merge_to(self.branch.tags)
730721
@@ -828,8 +819,8 @@
828 self.branch.fetch(self.pristine_upstream_branch, last_revision=revid)819 self.branch.fetch(self.pristine_upstream_branch, last_revision=revid)
829 self.pristine_upstream_branch.tags.merge_to(self.branch.tags)820 self.pristine_upstream_branch.tags.merge_to(self.branch.tags)
830821
831 def import_upstream(self, upstream_part, version, upstream_parents,822 def import_upstream(self, upstream_part, package, version, upstream_parents,
832 upstream_tarballs=None, upstream_branch=None,823 upstream_tarballs, upstream_branch=None,
833 upstream_revision=None, timestamp=None, author=None,824 upstream_revision=None, timestamp=None, author=None,
834 file_ids_from=None):825 file_ids_from=None):
835 """Import an upstream part on to the upstream branch.826 """Import an upstream part on to the upstream branch.
@@ -843,7 +834,7 @@
843 :param upstream_parents: the parents to give the upstream revision834 :param upstream_parents: the parents to give the upstream revision
844 :param timestamp: a tuple of (timestamp, timezone) to use for835 :param timestamp: a tuple of (timestamp, timezone) to use for
845 the commit, or None to use the current time.836 the commit, or None to use the current time.
846 :return: (tag_name, revision_id) of the imported tarball.837 :return: list with (component, tag, revid) tuples
847 """838 """
848 # Should we just dump the upstream part on whatever is currently839 # Should we just dump the upstream part on whatever is currently
849 # there, or try and pull all of the other upstream versions840 # there, or try and pull all of the other upstream versions
@@ -859,12 +850,10 @@
859 parent_revid = upstream_parents[0]850 parent_revid = upstream_parents[0]
860 else:851 else:
861 parent_revid = NULL_REVISION852 parent_revid = NULL_REVISION
862 self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch, overwrite=True,853 self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch,
863 stop_revision=parent_revid)854 overwrite=True, stop_revision=parent_revid)
864 other_branches = self.get_other_branches()855 other_branches = self.get_other_branches()
865 def get_last_revision_tree(br):856 upstream_trees = [o.pristine_upstream_branch.basis_tree()
866 return br.repository.revision_tree(br.last_revision())
867 upstream_trees = [get_last_revision_tree(o.pristine_upstream_branch)
868 for o in other_branches]857 for o in other_branches]
869 target_tree = None858 target_tree = None
870 if upstream_branch is not None:859 if upstream_branch is not None:
@@ -890,33 +879,23 @@
890 target_tree=target_tree)879 target_tree=target_tree)
891 finally:880 finally:
892 self_tree.unlock()881 self_tree.unlock()
893 self.pristine_upstream_tree.set_parent_ids(upstream_parents)
894 revprops = {}882 revprops = {}
895 if upstream_tarballs is not None:883 ret = []
896 if len(upstream_tarballs) != 1:884 for (tarball, component, md5) in upstream_tarballs:
897 raise MultipleUpstreamTarballsNotSupported()885 (tag, revid) = self.pristine_upstream_source.import_component_tarball(
898 (upstream_tarball, md5) = upstream_tarballs[0]886 package, version, self.pristine_upstream_tree, component,
899 revprops["deb-md5"] = md5887 md5, tarball, author=author, timestamp=timestamp,
900 delta_revprops = self.pristine_upstream_source.create_delta_revprops(888 parent_ids=upstream_parents)
901 self.pristine_upstream_tree, upstream_tarball)889 ret.append((component, tag, revid))
902 revprops.update(delta_revprops)890 self.branch.fetch(self.pristine_upstream_branch)
903 if author is not None:891 self.branch.tags.set_tag(tag, revid)
904 revprops['authors'] = author892 return ret
905 timezone = None
906 if timestamp is not None:
907 timezone = timestamp[1]
908 timestamp = timestamp[0]
909 revid = self.pristine_upstream_tree.commit("Import upstream version %s" \
910 % (version,),
911 revprops=revprops, timestamp=timestamp, timezone=timezone)
912 tag_name, _ = self.tag_upstream_version(version, revid=revid)
913 return tag_name, revid
914893
915 def import_upstream_tarballs(self, tarballs, version, parents,894 def import_upstream_tarballs(self, tarballs, package, version, parents,
916 upstream_branch=None, upstream_revision=None):895 upstream_branch=None, upstream_revision=None):
917 """Import an upstream part to the upstream branch.896 """Import an upstream part to the upstream branch.
918897
919 :param tarball_filename: The tarball to import.898 :param tarballs: List of tarballs / components to extract
920 :param version: The upstream version to import.899 :param version: The upstream version to import.
921 :param parents: The tarball-branch parents to use for the import.900 :param parents: The tarball-branch parents to use for the import.
922 If an upstream branch is supplied, its automatically added to901 If an upstream branch is supplied, its automatically added to
@@ -925,11 +904,11 @@
925 tarball.904 tarball.
926 :param upstream_revision: Upstream revision id905 :param upstream_revision: Upstream revision id
927 :param md5sum: hex digest of the md5sum of the tarball, if known.906 :param md5sum: hex digest of the md5sum of the tarball, if known.
928 :return: (tag_name, revision_id) of the imported tarball.907 :return: list with (component, tag, revid) tuples
929 """908 """
930 tarball_dir = self._extract_tarballs_to_tempdir(tarballs)909 tarball_dir = self._extract_tarballs_to_tempdir(tarballs)
931 try:910 try:
932 return self.import_upstream(tarball_dir, version, parents,911 return self.import_upstream(tarball_dir, package, version, parents,
933 tarballs,912 tarballs,
934 upstream_branch=upstream_branch,913 upstream_branch=upstream_branch,
935 upstream_revision=upstream_revision)914 upstream_revision=upstream_revision)
@@ -944,8 +923,7 @@
944 poss_native_tree = self.get_branch_tip_revtree()923 poss_native_tree = self.get_branch_tip_revtree()
945 current_native = self._is_tree_native(poss_native_tree)924 current_native = self._is_tree_native(poss_native_tree)
946 current_config = self._default_config_for_tree(poss_native_tree)925 current_config = self._default_config_for_tree(poss_native_tree)
947 dirname = os.path.join(self.tree.basedir,926 dirname = os.path.join(self.tree.basedir, '.bzr-builddeb')
948 '.bzr-builddeb')
949 if current_config is not None:927 if current_config is not None:
950 # Add that back to the current tree928 # Add that back to the current tree
951 if not os.path.exists(dirname):929 if not os.path.exists(dirname):
@@ -1022,10 +1000,7 @@
1022 "as the single parent")1000 "as the single parent")
1023 parents = [self.branch.last_revision()]1001 parents = [self.branch.last_revision()]
1024 other_branches = self.get_other_branches()1002 other_branches = self.get_other_branches()
1025 def get_last_revision_tree(br):1003 debian_trees = [o.branch.basis_tree() for o in other_branches]
1026 return br.repository.revision_tree(br.last_revision())
1027 debian_trees = [get_last_revision_tree(o.branch)
1028 for o in other_branches]
1029 parent_trees = []1004 parent_trees = []
1030 if file_ids_from is not None:1005 if file_ids_from is not None:
1031 parent_trees = file_ids_from[:]1006 parent_trees = file_ids_from[:]
@@ -1169,13 +1144,13 @@
1169 # from another branch:1144 # from another branch:
1170 upstream_parents = self.upstream_parents(package, versions,1145 upstream_parents = self.upstream_parents(package, versions,
1171 version.upstream_version)1146 version.upstream_version)
1172 _, new_revid = self.import_upstream(upstream_part,1147 for (component, tag, revid) in self.import_upstream(upstream_part,
1173 version.upstream_version,1148 package, version.upstream_version,
1174 upstream_parents,1149 upstream_parents,
1175 upstream_tarballs=upstream_tarballs,1150 upstream_tarballs=upstream_tarballs,
1176 timestamp=timestamp, author=author,1151 timestamp=timestamp, author=author,
1177 file_ids_from=file_ids_from)1152 file_ids_from=file_ids_from):
1178 self._fetch_upstream_to_branch(new_revid)1153 self._fetch_upstream_to_branch(revid)
1179 else:1154 else:
1180 mutter("We already have the needed upstream part")1155 mutter("We already have the needed upstream part")
1181 parents = self.get_parents_with_upstream(package, version, versions,1156 parents = self.get_parents_with_upstream(package, version, versions,
@@ -1356,8 +1331,9 @@
1356 def _extract_tarballs_to_tempdir(self, tarballs):1331 def _extract_tarballs_to_tempdir(self, tarballs):
1357 tempdir = tempfile.mkdtemp()1332 tempdir = tempfile.mkdtemp()
1358 try:1333 try:
1359 extract_orig_tarballs([fn for (fn, md5) in tarballs], tempdir,1334 extract_orig_tarballs(
1360 strip_components=1)1335 [(fn, component) for (fn, component, md5) in tarballs],
1336 tempdir, strip_components=1)
1361 return tempdir1337 return tempdir
1362 except:1338 except:
1363 shutil.rmtree(tempdir)1339 shutil.rmtree(tempdir)
@@ -1405,7 +1381,8 @@
1405 self.branch.last_revision()):1381 self.branch.last_revision()):
1406 raise UpstreamBranchAlreadyMerged1382 raise UpstreamBranchAlreadyMerged
1407 upstream_tarballs = [1383 upstream_tarballs = [
1408 (os.path.abspath(fn), md5sum_filename(fn)) for fn in1384 (os.path.abspath(fn), component, md5sum_filename(fn)) for
1385 (fn, component) in
1409 tarball_filenames]1386 tarball_filenames]
1410 tarball_dir = self._extract_tarballs_to_tempdir(upstream_tarballs)1387 tarball_dir = self._extract_tarballs_to_tempdir(upstream_tarballs)
1411 try:1388 try:
@@ -1413,11 +1390,11 @@
1413 parents = []1390 parents = []
1414 if self.pristine_upstream_branch.last_revision() != NULL_REVISION:1391 if self.pristine_upstream_branch.last_revision() != NULL_REVISION:
1415 parents = [self.pristine_upstream_branch.last_revision()]1392 parents = [self.pristine_upstream_branch.last_revision()]
1416 _, new_revid = self.import_upstream(tarball_dir,1393 for (component, tag, revid) in self.import_upstream(tarball_dir,
1417 version, parents, upstream_tarballs=upstream_tarballs,1394 package, version, parents, upstream_tarballs=upstream_tarballs,
1418 upstream_branch=upstream_branch,1395 upstream_branch=upstream_branch,
1419 upstream_revision=upstream_revision)1396 upstream_revision=upstream_revision):
1420 self._fetch_upstream_to_branch(new_revid)1397 self._fetch_upstream_to_branch(revid)
1421 finally:1398 finally:
1422 shutil.rmtree(tarball_dir)1399 shutil.rmtree(tarball_dir)
1423 if self.branch.last_revision() != NULL_REVISION:1400 if self.branch.last_revision() != NULL_REVISION:
@@ -1502,7 +1479,9 @@
1502 if part['name'].endswith(".orig.tar.gz"):1479 if part['name'].endswith(".orig.tar.gz"):
1503 self.upstream_tarballs.append((os.path.abspath(1480 self.upstream_tarballs.append((os.path.abspath(
1504 os.path.join(osutils.dirname(self.dsc_path),1481 os.path.join(osutils.dirname(self.dsc_path),
1505 part['name'])), part['md5sum']))1482 part['name'])),
1483 component_from_orig_tarball(part['name'], name, str(version.upstream_version)),
1484 part['md5sum']))
1506 elif part['name'].endswith(".diff.gz"):1485 elif part['name'].endswith(".diff.gz"):
1507 self.unextracted_debian_md5 = part['md5sum']1486 self.unextracted_debian_md5 = part['md5sum']
15081487
15091488
=== modified file 'source_distiller.py'
--- source_distiller.py 2011-06-15 01:28:19 +0000
+++ source_distiller.py 2011-06-23 21:47:20 +0000
@@ -25,11 +25,11 @@
25from bzrlib import errors as bzr_errors25from bzrlib import errors as bzr_errors
2626
27from bzrlib.plugins.builddeb.util import (27from bzrlib.plugins.builddeb.util import (
28 export,28 export,
29 extract_orig_tarballs,29 extract_orig_tarballs,
30 get_parent_dir,30 get_parent_dir,
31 recursive_copy,31 recursive_copy,
32 )32 )
3333
3434
35class SourceDistiller(object):35class SourceDistiller(object):
3636
=== modified file 'tests/blackbox/test_merge_upstream.py'
--- tests/blackbox/test_merge_upstream.py 2011-06-15 16:35:46 +0000
+++ tests/blackbox/test_merge_upstream.py 2011-06-23 21:47:20 +0000
@@ -95,7 +95,9 @@
95 dbs = DistributionBranchSet()95 dbs = DistributionBranchSet()
96 dbs.add_branch(db)96 dbs.add_branch(db)
97 db.import_upstream_tarballs(97 db.import_upstream_tarballs(
98 [(self.tar.tarball, md5sum_filename(self.tar.tarball))], str(self.tar.version),98 [(self.tar.tarball, None, md5sum_filename(self.tar.tarball))],
99 "foo",
100 str(self.tar.version),
99 [tree.branch.last_revision()])101 [tree.branch.last_revision()])
100 package_builder = SourcePackageBuilder("foo",102 package_builder = SourcePackageBuilder("foo",
101 str(self.tar.version)+"-1")103 str(self.tar.version)+"-1")
102104
=== modified file 'tests/test_import_dsc.py'
--- tests/test_import_dsc.py 2011-06-15 16:35:46 +0000
+++ tests/test_import_dsc.py 2011-06-23 21:47:20 +0000
@@ -173,26 +173,26 @@
173 version = "0.1"173 version = "0.1"
174 self.assertFalse(db.has_upstream_version("package", version))174 self.assertFalse(db.has_upstream_version("package", version))
175 self.assertFalse(db.has_upstream_version("package", version,175 self.assertFalse(db.has_upstream_version("package", version,
176 [("foo.tar.gz", self.fake_md5_1)]))176 [("foo.tar.gz", None, self.fake_md5_1)]))
177 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)177 self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1)
178 db.tag_upstream_version(version)178 db.tag_upstream_version(version)
179 self.assertTrue(db.has_upstream_version("package", version))179 self.assertTrue(db.has_upstream_version("package", version))
180 self.assertTrue(db.has_upstream_version("package",180 self.assertTrue(db.has_upstream_version("package",
181 version, [("foo.tar.gz", self.fake_md5_1)]))181 version, [("foo.tar.gz", None, self.fake_md5_1)]))
182 self.assertFalse(db.has_upstream_version("package", version,182 self.assertFalse(db.has_upstream_version("package", version,
183 [("foo.tar.gz", self.fake_md5_2)]))183 [("foo.tar.gz", None, self.fake_md5_2)]))
184 version = "0.1"184 version = "0.1"
185 self.assertTrue(db.has_upstream_version("package", version))185 self.assertTrue(db.has_upstream_version("package", version))
186 self.assertTrue(db.has_upstream_version("package", version,186 self.assertTrue(db.has_upstream_version("package", version,
187 [("foo.tar.gz", self.fake_md5_1)]))187 [("foo.tar.gz", None, self.fake_md5_1)]))
188 self.assertFalse(db.has_upstream_version("package", version,188 self.assertFalse(db.has_upstream_version("package", version,
189 [("foo.tar.gz", self.fake_md5_2)]))189 [("foo.tar.gz", None, self.fake_md5_2)]))
190 version = "0.2"190 version = "0.2"
191 self.assertFalse(db.has_upstream_version("package", version))191 self.assertFalse(db.has_upstream_version("package", version))
192 self.assertFalse(db.has_upstream_version("package", version,192 self.assertFalse(db.has_upstream_version("package", version,
193 [("foo.tar.gz", self.fake_md5_1)]))193 [("foo.tar.gz", None, self.fake_md5_1)]))
194 self.assertFalse(db.has_upstream_version("package", version,194 self.assertFalse(db.has_upstream_version("package", version,
195 [("foo.tar.gz", self.fake_md5_2)]))195 [("foo.tar.gz", None, self.fake_md5_2)]))
196196
197 def test_revid_of_version(self):197 def test_revid_of_version(self):
198 db = self.db1198 db = self.db1
@@ -640,48 +640,48 @@
640 version2 = Version("0.2-1")640 version2 = Version("0.2-1")
641 # With no versions tagged everything is None641 # With no versions tagged everything is None
642 branch = self.db2.branch_to_pull_upstream_from("package",642 branch = self.db2.branch_to_pull_upstream_from("package",
643 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])643 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
644 self.assertEqual(branch, None)644 self.assertEqual(branch, None)
645 branch = self.db2.branch_to_pull_upstream_from("package",645 branch = self.db2.branch_to_pull_upstream_from("package",
646 version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)])646 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_2)])
647 self.assertEqual(branch, None)647 self.assertEqual(branch, None)
648 branch = self.db1.branch_to_pull_upstream_from("package",648 branch = self.db1.branch_to_pull_upstream_from("package",
649 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])649 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
650 self.assertEqual(branch, None)650 self.assertEqual(branch, None)
651 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)
652 self.db1.tag_upstream_version(version1.upstream_version)652 self.db1.tag_upstream_version(version1.upstream_version)
653 # Version and md5 available, so we get the correct branch.653 # Version and md5 available, so we get the correct branch.
654 branch = self.db2.branch_to_pull_upstream_from("package",654 branch = self.db2.branch_to_pull_upstream_from("package",
655 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])655 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
656 self.assertEqual(branch, self.db1)656 self.assertEqual(branch, self.db1)
657 # Otherwise (different version or md5) then we get None657 # Otherwise (different version or md5) then we get None
658 branch = self.db2.branch_to_pull_upstream_from("package",658 branch = self.db2.branch_to_pull_upstream_from("package",
659 version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)])659 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_2)])
660 self.assertEqual(branch, None)660 self.assertEqual(branch, None)
661 branch = self.db2.branch_to_pull_upstream_from("package",661 branch = self.db2.branch_to_pull_upstream_from("package",
662 version2.upstream_version,662 version2.upstream_version,
663 [("foo.tar.gz", self.fake_md5_1)])663 [("foo.tar.gz", None, self.fake_md5_1)])
664 self.assertEqual(branch, None)664 self.assertEqual(branch, None)
665 branch = self.db2.branch_to_pull_upstream_from("package",665 branch = self.db2.branch_to_pull_upstream_from("package",
666 version2.upstream_version,666 version2.upstream_version,
667 [("foo.tar.gz", self.fake_md5_2)])667 [("foo.tar.gz", None, self.fake_md5_2)])
668 self.assertEqual(branch, None)668 self.assertEqual(branch, None)
669 # And we don't get a branch for the one that already has669 # And we don't get a branch for the one that already has
670 # the version670 # the version
671 branch = self.db1.branch_to_pull_upstream_from("package",671 branch = self.db1.branch_to_pull_upstream_from("package",
672 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])672 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
673 self.assertEqual(branch, None)673 self.assertEqual(branch, None)
674 self.up_tree2.pull(self.up_tree1.branch)674 self.up_tree2.pull(self.up_tree1.branch)
675 self.db2.tag_upstream_version(version1.upstream_version)675 self.db2.tag_upstream_version(version1.upstream_version)
676 # And we get the greatest branch when two lesser branches676 # And we get the greatest branch when two lesser branches
677 # have what we are looking for.677 # have what we are looking for.
678 branch = self.db3.branch_to_pull_upstream_from("package",678 branch = self.db3.branch_to_pull_upstream_from("package",
679 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])679 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
680 self.assertEqual(branch, self.db2)680 self.assertEqual(branch, self.db2)
681 # If the branches have diverged then we don't get a branch.681 # If the branches have diverged then we don't get a branch.
682 self.up_tree3.commit("three")682 self.up_tree3.commit("three")
683 branch = self.db3.branch_to_pull_upstream_from("package",683 branch = self.db3.branch_to_pull_upstream_from("package",
684 version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)])684 version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)])
685 self.assertEqual(branch, None)685 self.assertEqual(branch, None)
686686
687 def test_pull_from_lesser_branch_no_upstream(self):687 def test_pull_from_lesser_branch_no_upstream(self):
@@ -773,7 +773,8 @@
773 contents = [(basedir + '/' + element[0],) + element[1:] for773 contents = [(basedir + '/' + element[0],) + element[1:] for
774 element in contents]774 element in contents]
775 self.build_tree_contents(contents)775 self.build_tree_contents(contents)
776 self.db1.import_upstream(basedir, version.upstream_version, [])776 self.db1.import_upstream(basedir, "package", version.upstream_version,
777 [], [(None, None, None)])
777 return version778 return version
778779
779 def test_import_upstream(self):780 def test_import_upstream(self):
@@ -807,14 +808,15 @@
807 write_to_file(os.path.join(basedir, "README"), "Hi\n")808 write_to_file(os.path.join(basedir, "README"), "Hi\n")
808 write_to_file(os.path.join(basedir, "BUGS"), "")809 write_to_file(os.path.join(basedir, "BUGS"), "")
809 write_to_file(os.path.join(basedir, "COPYING"), "")810 write_to_file(os.path.join(basedir, "COPYING"), "")
810 self.db1.import_upstream(basedir, version1.upstream_version, [])811 self.db1.import_upstream(basedir, "package", version1.upstream_version, [],
812 [(None, None, None)])
811 basedir = name + "-" + str(version2.upstream_version)813 basedir = name + "-" + str(version2.upstream_version)
812 os.mkdir(basedir)814 os.mkdir(basedir)
813 write_to_file(os.path.join(basedir, "README"), "Now even better\n")815 write_to_file(os.path.join(basedir, "README"), "Now even better\n")
814 write_to_file(os.path.join(basedir, "BUGS"), "")816 write_to_file(os.path.join(basedir, "BUGS"), "")
815 write_to_file(os.path.join(basedir, "NEWS"), "")817 write_to_file(os.path.join(basedir, "NEWS"), "")
816 self.db1.import_upstream(basedir, version2.upstream_version,818 self.db1.import_upstream(basedir, "package", version2.upstream_version,
817 [self.up_tree1.branch.last_revision()])819 [self.up_tree1.branch.last_revision()], [(None, None, None)])
818 tree = self.up_tree1820 tree = self.up_tree1
819 branch = tree.branch821 branch = tree.branch
820 rh = branch.revision_history()822 rh = branch.revision_history()
@@ -845,8 +847,8 @@
845 tf.add(basedir)847 tf.add(basedir)
846 finally:848 finally:
847 tf.close()849 tf.close()
848 self.db1.import_upstream(basedir, version.upstream_version, [],850 self.db1.import_upstream(basedir, "package", version.upstream_version, [],
849 upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)])851 upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)])
850 tree = self.up_tree1852 tree = self.up_tree1
851 branch = tree.branch853 branch = tree.branch
852 rh = branch.revision_history()854 rh = branch.revision_history()
@@ -873,8 +875,8 @@
873 tf.add(basedir)875 tf.add(basedir)
874 finally:876 finally:
875 tf.close()877 tf.close()
876 self.db1.import_upstream(basedir, version.upstream_version,878 self.db1.import_upstream(basedir, "package", version.upstream_version,
877 [], upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)])879 [], upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)])
878 tree = self.up_tree1880 tree = self.up_tree1
879 branch = tree.branch881 branch = tree.branch
880 rh = branch.revision_history()882 rh = branch.revision_history()
@@ -1503,7 +1505,7 @@
1503 tf.add("a")1505 tf.add("a")
1504 finally:1506 finally:
1505 tf.close()1507 tf.close()
1506 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1")1508 conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1")
1507 self.assertEqual(0, conflicts)1509 self.assertEqual(0, conflicts)
15081510
1509 def test_merge_upstream_initial_with_branch(self):1511 def test_merge_upstream_initial_with_branch(self):
@@ -1540,7 +1542,7 @@
1540 tf.add("a")1542 tf.add("a")
1541 finally:1543 finally:
1542 tf.close()1544 tf.close()
1543 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1",1545 conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1",
1544 upstream_branch=upstream_tree.branch,1546 upstream_branch=upstream_tree.branch,
1545 upstream_revision=upstream_rev)1547 upstream_revision=upstream_rev)
1546 self.assertEqual(0, conflicts)1548 self.assertEqual(0, conflicts)
@@ -1580,7 +1582,7 @@
1580 tf.add("a")1582 tf.add("a")
1581 finally:1583 finally:
1582 tf.close()1584 tf.close()
1583 conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1",1585 conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1",
1584 upstream_branch=upstream_tree.branch,1586 upstream_branch=upstream_tree.branch,
1585 upstream_revision=upstream_rev)1587 upstream_revision=upstream_rev)
1586 # ./debian conflicts.1588 # ./debian conflicts.
@@ -1621,7 +1623,7 @@
1621 dbs.add_branch(db)1623 dbs.add_branch(db)
1622 tree.lock_write()1624 tree.lock_write()
1623 self.addCleanup(tree.unlock)1625 self.addCleanup(tree.unlock)
1624 db.merge_upstream([builder.tar_name()], "package", str(version2),1626 db.merge_upstream([(builder.tar_name(), None)], "package", str(version2),
1625 version1.upstream_version,1627 version1.upstream_version,
1626 upstream_branch=upstream_tree.branch,1628 upstream_branch=upstream_tree.branch,
1627 upstream_revision=upstream_rev)1629 upstream_revision=upstream_rev)
@@ -1660,7 +1662,7 @@
1660 tf.add("a")1662 tf.add("a")
1661 finally:1663 finally:
1662 tf.close()1664 tf.close()
1663 conflicts = db.merge_upstream([tarball_filename], "package", "0.2-1",1665 conflicts = db.merge_upstream([(tarball_filename, None)], "package", "0.2-1",
1664 "0.1")1666 "0.1")
1665 # Check that we tagged wiht the dash version1667 # Check that we tagged wiht the dash version
1666 self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1'))1668 self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1'))
@@ -1699,7 +1701,7 @@
1699 # We don't add the new file upstream, as the new file id would1701 # We don't add the new file upstream, as the new file id would
1700 # be picked up from there.1702 # be picked up from there.
1701 upstream_rev2 = upstream_tree.commit("two")1703 upstream_rev2 = upstream_tree.commit("two")
1702 db.merge_upstream([builder.tar_name()], "package",1704 db.merge_upstream([(builder.tar_name(), None)], "package",
1703 version2.upstream_version,1705 version2.upstream_version,
1704 version1.upstream_version,1706 version1.upstream_version,
1705 upstream_branch=upstream_tree.branch,1707 upstream_branch=upstream_tree.branch,
@@ -1736,7 +1738,7 @@
1736 # We don't add the new file upstream, as the new file id would1738 # We don't add the new file upstream, as the new file id would
1737 # be picked up from there.1739 # be picked up from there.
1738 upstream_rev2 = upstream_tree.commit("two")1740 upstream_rev2 = upstream_tree.commit("two")
1739 db.merge_upstream([builder.tar_name()], "package",1741 db.merge_upstream([(builder.tar_name(), None)], "package",
1740 version2.upstream_version,1742 version2.upstream_version,
1741 version1.upstream_version,1743 version1.upstream_version,
1742 upstream_branch=upstream_tree.branch,1744 upstream_branch=upstream_tree.branch,
@@ -1769,7 +1771,7 @@
1769 builder.add_upstream_file("a", "New a")1771 builder.add_upstream_file("a", "New a")
1770 builder.add_upstream_file("b", "Renamed a")1772 builder.add_upstream_file("b", "Renamed a")
1771 builder.build()1773 builder.build()
1772 db.merge_upstream([builder.tar_name()], "packaging",1774 db.merge_upstream([(builder.tar_name(), None)], "packaging",
1773 version2.upstream_version, version1.upstream_version)1775 version2.upstream_version, version1.upstream_version)
1774 self.assertEqual("a-id", packaging_tree.path2id("b"))1776 self.assertEqual("a-id", packaging_tree.path2id("b"))
1775 self.assertEqual("other-a-id", packaging_tree.path2id("a"))1777 self.assertEqual("other-a-id", packaging_tree.path2id("a"))
17761778
=== modified file 'tests/test_upstream.py'
--- tests/test_upstream.py 2011-06-14 14:07:21 +0000
+++ tests/test_upstream.py 2011-06-23 21:47:20 +0000
@@ -57,6 +57,9 @@
57 UScanSource,57 UScanSource,
58 extract_tarball_version,58 extract_tarball_version,
59 )59 )
60from bzrlib.plugins.builddeb.util import (
61 component_from_orig_tarball,
62 )
60from bzrlib.plugins.builddeb.upstream.branch import (63from bzrlib.plugins.builddeb.upstream.branch import (
61 get_export_upstream_revision,64 get_export_upstream_revision,
62 get_snapshot_revision,65 get_snapshot_revision,
@@ -803,7 +806,8 @@
803 paths = (self.already_exists_in_target(target_dir)806 paths = (self.already_exists_in_target(target_dir)
804 or self.provide_from_store_dir(target_dir))807 or self.provide_from_store_dir(target_dir))
805 if paths is not None:808 if paths is not None:
806 return paths809 return [(p, component_from_orig_tarball(p, self.package,
810 self.version)) for p in paths]
807 raise MissingUpstreamTarball(self.package, self.version)811 raise MissingUpstreamTarball(self.package, self.version)
808812
809813
810814
=== modified file 'tests/test_util.py'
--- tests/test_util.py 2011-06-15 15:33:08 +0000
+++ tests/test_util.py 2011-06-23 21:47:20 +0000
@@ -38,10 +38,10 @@
38 BUILD_TYPE_NATIVE,38 BUILD_TYPE_NATIVE,
39 BUILD_TYPE_NORMAL,39 BUILD_TYPE_NORMAL,
40 )40 )
41from bzrlib.plugins.builddeb.errors import (MissingChangelogError,41from bzrlib.plugins.builddeb.errors import (
42 MissingChangelogError,
42 AddChangelogError,43 AddChangelogError,
43 InconsistentSourceFormatError,44 InconsistentSourceFormatError,
44 MultipleUpstreamTarballsNotSupported,
45 NoPreviousUpload,45 NoPreviousUpload,
46 )46 )
47from bzrlib.plugins.builddeb.tests import (47from bzrlib.plugins.builddeb.tests import (
@@ -50,6 +50,7 @@
50 TestCaseWithTransport,50 TestCaseWithTransport,
51 )51 )
52from bzrlib.plugins.builddeb.util import (52from bzrlib.plugins.builddeb.util import (
53 component_from_orig_tarball,
53 dget,54 dget,
54 dget_changes,55 dget_changes,
55 extract_orig_tarballs,56 extract_orig_tarballs,
@@ -853,8 +854,10 @@
853 f.write("Hi\n")854 f.write("Hi\n")
854 finally:855 finally:
855 f.close()856 f.close()
856 tar_path = os.path.abspath("%s_%s.orig.tar.%s" % (package, version,857 prefix = "%s_%s.orig" % (package, version)
857 compression))858 if part is not None:
859 prefix += "-%s" % part
860 tar_path = os.path.abspath(prefix + ".tar." + compression)
858 tf = tarfile.open(tar_path, 'w:%s' % compression)861 tf = tarfile.open(tar_path, 'w:%s' % compression)
859 try:862 try:
860 tf.add(basedir)863 tf.add(basedir)
@@ -867,19 +870,45 @@
867 def test_single_orig_tar_gz(self):870 def test_single_orig_tar_gz(self):
868 tar_path = self.create_tarball("package", "0.1", "gz")871 tar_path = self.create_tarball("package", "0.1", "gz")
869 os.mkdir("target")872 os.mkdir("target")
870 extract_orig_tarballs([tar_path], "target", strip_components=1)873 extract_orig_tarballs([(tar_path, None)], "target",
874 strip_components=1)
871 self.assertEquals(os.listdir("target"), ["README"])875 self.assertEquals(os.listdir("target"), ["README"])
872876
873 def test_single_orig_tar_bz2(self):877 def test_single_orig_tar_bz2(self):
874 tar_path = self.create_tarball("package", "0.1", "bz2")878 tar_path = self.create_tarball("package", "0.1", "bz2")
875 os.mkdir("target")879 os.mkdir("target")
876 extract_orig_tarballs([tar_path], "target", strip_components=1)880 extract_orig_tarballs([(tar_path, None)], "target",
881 strip_components=1)
877 self.assertEquals(os.listdir("target"), ["README"])882 self.assertEquals(os.listdir("target"), ["README"])
878883
879 def test_multiple_tarballs(self):884 def test_multiple_tarballs(self):
880 base_tar_path = self.create_tarball("package", "0.1", "bz2")885 base_tar_path = self.create_tarball("package", "0.1", "bz2")
881 tar_path_extra = self.create_tarball("package", "0.1", "bz2", part="extra")886 tar_path_extra = self.create_tarball("package", "0.1", "bz2", part="extra")
882 os.mkdir("target")887 os.mkdir("target")
883 self.assertRaises(MultipleUpstreamTarballsNotSupported,888 extract_orig_tarballs([(base_tar_path, None), (tar_path_extra, "extra")], "target",
884 extract_orig_tarballs,889 strip_components=1)
885 [base_tar_path, tar_path_extra], "target")890 self.assertEquals(sorted(os.listdir("target")),
891 sorted(["README", "extra"]))
892
893
894class ComponentFromOrigTarballTests(TestCase):
895
896 def test_base_tarball(self):
897 self.assertIs(None,
898 component_from_orig_tarball("foo_0.1.orig.tar.gz", "foo", "0.1"))
899 self.assertRaises(ValueError,
900 component_from_orig_tarball, "foo_0.1.orig.tar.gz", "bar", "0.1")
901
902 def test_invalid_extension(self):
903 self.assertRaises(ValueError,
904 component_from_orig_tarball, "foo_0.1.orig.unknown", "foo", "0.1")
905
906 def test_component(self):
907 self.assertEquals("comp",
908 component_from_orig_tarball("foo_0.1.orig-comp.tar.gz", "foo", "0.1"))
909 self.assertEquals("comp-dash",
910 component_from_orig_tarball("foo_0.1.orig-comp-dash.tar.gz", "foo", "0.1"))
911
912 def test_invalid_character(self):
913 self.assertRaises(ValueError,
914 component_from_orig_tarball, "foo_0.1.orig;.tar.gz", "foo", "0.1")
886915
=== modified file 'upstream/__init__.py'
--- upstream/__init__.py 2011-06-16 21:02:32 +0000
+++ upstream/__init__.py 2011-06-23 21:47:20 +0000
@@ -44,6 +44,7 @@
44 )44 )
45from bzrlib.plugins.builddeb.repack_tarball import repack_tarball45from bzrlib.plugins.builddeb.repack_tarball import repack_tarball
46from bzrlib.plugins.builddeb.util import (46from bzrlib.plugins.builddeb.util import (
47 component_from_orig_tarball,
47 export,48 export,
48 tarball_name,49 tarball_name,
49 )50 )
@@ -395,7 +396,8 @@
395 if in_target is not None:396 if in_target is not None:
396 note("Upstream tarball already exists in build directory, "397 note("Upstream tarball already exists in build directory, "
397 "using that")398 "using that")
398 return in_target399 return [(p, component_from_orig_tarball(p,
400 self.package, self.version)) for p in in_target]
399 if self.already_exists_in_store() is None:401 if self.already_exists_in_store() is None:
400 if not os.path.exists(self.store_dir):402 if not os.path.exists(self.store_dir):
401 os.makedirs(self.store_dir)403 os.makedirs(self.store_dir)
@@ -410,7 +412,8 @@
410 self.store_dir)412 self.store_dir)
411 paths = self.provide_from_store_dir(target_dir)413 paths = self.provide_from_store_dir(target_dir)
412 assert paths is not None414 assert paths is not None
413 return paths415 return [(p, component_from_orig_tarball(p, self.package, self.version))
416 for p in paths]
414417
415 def _gather_orig_files(self, path):418 def _gather_orig_files(self, path):
416 prefix = "%s_%s.orig" % (self.package, self.version)419 prefix = "%s_%s.orig" % (self.package, self.version)
417420
=== modified file 'upstream/pristinetar.py'
--- upstream/pristinetar.py 2011-06-15 15:08:01 +0000
+++ upstream/pristinetar.py 2011-06-23 21:47:20 +0000
@@ -130,6 +130,52 @@
130 return "upstream-" + version130 return "upstream-" + version
131 return "upstream-%s-%s" % (distro, version)131 return "upstream-%s-%s" % (distro, version)
132132
133 def tag_version(self, version, revid):
134 """Tags the upstream branch's last revision with an upstream version.
135
136 Sets a tag on the last revision of the upstream branch and on the main
137 branch with a tag that refers to the upstream part of the version
138 provided.
139
140 :param version: the upstream part of the version number to derive the
141 tag name from.
142 :param revid: the revid to associate the tag with, or None for the
143 tip of self.pristine_upstream_branch.
144 :return The tag name, revid of the added tag.
145 """
146 assert isinstance(version, str)
147 tag_name = self.tag_name(version)
148 self.branch.tags.set_tag(tag_name, revid)
149 return tag_name, revid
150
151 def import_component_tarball(self, package, version, tree, component=None,
152 md5=None, tarball=None, author=None, timestamp=None,
153 parent_ids=None):
154 """Import a tarball.
155
156 :param package: Package name
157 :param version: Upstream version
158 :param component: Component name (None for base)
159 """
160 if component is not None:
161 raise BzrError("Importing non-base tarballs not yet supported")
162 tree.set_parent_ids(parent_ids)
163 revprops = {}
164 if md5 is not None:
165 revprops["deb-md5"] = md5
166 delta_revprops = self.create_delta_revprops(tree, tarball)
167 revprops.update(delta_revprops)
168 if author is not None:
169 revprops['authors'] = author
170 timezone = None
171 if timestamp is not None:
172 timezone = timestamp[1]
173 timestamp = timestamp[0]
174 revid = tree.commit("Import upstream version %s" % (version,),
175 revprops=revprops, timestamp=timestamp, timezone=timezone)
176 tag_name, _ = self.tag_version(version, revid=revid)
177 return tag_name, revid
178
133 def fetch_tarball(self, package, version, target_dir):179 def fetch_tarball(self, package, version, target_dir):
134 revid = self.version_as_revision(package, version)180 revid = self.version_as_revision(package, version)
135 try:181 try:
@@ -166,7 +212,7 @@
166 return True212 return True
167 if len(tarballs) != 1:213 if len(tarballs) != 1:
168 raise MultipleUpstreamTarballsNotSupported()214 raise MultipleUpstreamTarballsNotSupported()
169 (filename, md5) = tarballs[0]215 (filename, component, md5) = tarballs[0]
170 rev = self.branch.repository.get_revision(revid)216 rev = self.branch.repository.get_revision(revid)
171 try:217 try:
172 return rev.properties['deb-md5'] == md5218 return rev.properties['deb-md5'] == md5
173219
=== modified file 'util.py'
--- util.py 2011-06-15 01:28:19 +0000
+++ util.py 2011-06-23 21:47:20 +0000
@@ -66,7 +66,6 @@
66 MissingChangelogError,66 MissingChangelogError,
67 AddChangelogError,67 AddChangelogError,
68 InconsistentSourceFormatError,68 InconsistentSourceFormatError,
69 MultipleUpstreamTarballsNotSupported,
70 NoPreviousUpload,69 NoPreviousUpload,
71 TarFailed,70 TarFailed,
72 UnableToFindPreviousUpload,71 UnableToFindPreviousUpload,
@@ -685,24 +684,64 @@
685 return BUILD_TYPE_NORMAL684 return BUILD_TYPE_NORMAL
686685
687686
688def extract_orig_tarballs(tarballs, target, strip_components=None):687def component_from_orig_tarball(tarball_filename, package, version):
689 """Extract orig tarballs to a directory.688 tarball_filename = os.path.basename(tarball_filename)
690689 prefix = "%s_%s.orig" % (package, version)
691 :param tarballs: List of tarball filenames690 if not tarball_filename.startswith(prefix):
692 :param target: Target directory (must already exist)691 raise ValueError(
692 "invalid orig tarball file %s does not have expected prefix %s" % (
693 tarball_filename, prefix))
694 base = tarball_filename[len(prefix):]
695 for ext in (".tar.gz", ".tar.bz2", ".tar.lzma", ".tar.xz"):
696 if tarball_filename.endswith(ext):
697 base = base[:-len(ext)]
698 break
699 else:
700 raise ValueError(
701 "orig tarball file %s has unknown extension" % tarball_filename)
702 if base == "":
703 return None
704 elif base[0] == "-":
705 # Extra component
706 return base[1:]
707 else:
708 raise ValueError("Invalid extra characters in tarball filename %s" %
709 tarball_filename)
710
711
712def extract_orig_tarball(tarball_filename, component, target, strip_components=None):
713 """Extract an orig tarball.
714
715 :param tarball: Path to the tarball
716 :param component: Component name (or None for top-level)
717 :param target: Target path
718 :param strip_components: Optional number of components to strip
693 """719 """
694 if len(tarballs) != 1:
695 raise MultipleUpstreamTarballsNotSupported()
696 tarball_filename = tarballs[0]
697 tar_args = ["tar"]720 tar_args = ["tar"]
698 if tarball_filename.endswith(".tar.bz2"):721 if tarball_filename.endswith(".tar.bz2"):
699 tar_args.append('xjf')722 tar_args.append('xjf')
700 else:723 else:
701 tar_args.append('xzf')724 tar_args.append('xzf')
702 tar_args.extend([tarball_filename, "-C", target])725 if component is not None:
726 target_path = os.path.join(target, component)
727 os.mkdir(target_path)
728 else:
729 target_path = target
730 tar_args.extend([tarball_filename, "-C", target_path])
703 if strip_components is not None:731 if strip_components is not None:
704 tar_args.extend(["--strip-components", "1"])732 tar_args.extend(["--strip-components", "1"])
705 proc = subprocess.Popen(tar_args, preexec_fn=subprocess_setup)733 proc = subprocess.Popen(tar_args, preexec_fn=subprocess_setup)
706 proc.communicate()734 proc.communicate()
707 if proc.returncode != 0:735 if proc.returncode != 0:
708 raise TarFailed("extract", tarball_filename)736 raise TarFailed("extract", tarball_filename)
737
738
739def extract_orig_tarballs(tarballs, target, strip_components=None):
740 """Extract orig tarballs to a directory.
741
742 :param tarballs: List of tarball filenames
743 :param target: Target directory (must already exist)
744 """
745 for tarball_filename, component in tarballs:
746 extract_orig_tarball(tarball_filename, component, target,
747 strip_components=strip_components)

Subscribers

People subscribed via source and target branches