Merge lp:~james-w/launchpad/copy-archive-package-sets into lp:launchpad/db-devel

Proposed by James Westby
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 9495
Proposed branch: lp:~james-w/launchpad/copy-archive-package-sets
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~james-w/launchpad/copy-archive-test-refactor
Diff against target: 446 lines (+212/-15)
5 files modified
lib/lp/soyuz/adapters/packagelocation.py (+26/-4)
lib/lp/soyuz/adapters/tests/test_packagelocation.py (+54/-2)
lib/lp/soyuz/model/packagecloner.py (+13/-1)
lib/lp/soyuz/scripts/populate_archive.py (+17/-6)
lib/lp/soyuz/scripts/tests/test_populatearchive.py (+102/-2)
To merge this branch: bzr merge lp:~james-w/launchpad/copy-archive-package-sets
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+28165@code.launchpad.net

Commit message

--package-set can now be passed to populate_archive to limit the packages copied.

Description of the change

Summary

We want to be able to create copy archives that aren't the full archive.

A way to subset the archive in LP is by packageset, so we make use of that.

Proposed fix

This merge proposal adds a --package-set option to populate_archive.py,
which can be specified multiple times, and then only copies the packages
contained within the named sets.

Pre-implementation notes

Spoke briefly with Julian.

Implementation details

First PackageLocation was modified to store a list of package sets for the
source. build_package_location was also changed to lookup package sets based
on names.

We then hooked that up to the --package-set option to get the list of package
sets the user wants.

The final step is to hook that in to the query that copies the sources. Here we
take care to include the transitive closure of packages across the DAG of package
sets.

Tests

You can run them with

./bin/test -s lp.soyuz.scripts -m test_populatearchive
and
./bin/test -s lp.soyuz.adapters

Demo and Q/A

None.

lint

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/soyuz/adapters/packagelocation.py
  lib/lp/soyuz/adapters/tests/__init__.py
  lib/lp/soyuz/adapters/tests/test_packagelocation.py
  lib/lp/soyuz/model/packagecloner.py
  lib/lp/soyuz/scripts/populate_archive.py
  lib/lp/soyuz/scripts/tests/test_populatearchive.py

== Pyflakes notices ==

lib/lp/soyuz/scripts/populate_archive.py
    112: local variable 'ignore_this' is assigned to but never used
    287: local variable 'ignore_result' is assigned to but never used

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Hi James,

One minor nitpick but otherwise this branch is r=me.

> === modified file 'lib/lp/soyuz/adapters/packagelocation.py'
> --- lib/lp/soyuz/adapters/packagelocation.py 2009-08-28 06:39:38 +0000
> +++ lib/lp/soyuz/adapters/packagelocation.py 2010-06-22 12:11:56 +0000
> @@ -63,6 +66,10 @@
> if self.component is not None:
> result += ' (%s)' % self.component.name
>
> + if self.packagesets:

We should explicitly test len() here, since we know it's going to be a
list even if it's empty.

> + result += ' [%s]' % (
> + ", ".join([str(p.name) for p in self.packagesets]),)
> +
> return result
>
>

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/adapters/packagelocation.py'
--- lib/lp/soyuz/adapters/packagelocation.py 2009-08-28 06:39:38 +0000
+++ lib/lp/soyuz/adapters/packagelocation.py 2010-06-22 12:51:37 +0000
@@ -28,22 +28,25 @@
28 distroseries = None28 distroseries = None
29 pocket = None29 pocket = None
30 component = None30 component = None
31 packagesets = None
3132
32 def __init__(self, archive, distribution, distroseries, pocket,33 def __init__(self, archive, distribution, distroseries, pocket,
33 component=None):34 component=None, packagesets=None):
34 """Initialize the PackageLocation from the given parameters."""35 """Initialize the PackageLocation from the given parameters."""
35 self.archive = archive36 self.archive = archive
36 self.distribution = distribution37 self.distribution = distribution
37 self.distroseries = distroseries38 self.distroseries = distroseries
38 self.pocket = pocket39 self.pocket = pocket
39 self.component = component40 self.component = component
41 self.packagesets = packagesets or []
4042
41 def __eq__(self, other):43 def __eq__(self, other):
42 if (self.distribution == other.distribution and44 if (self.distribution == other.distribution and
43 self.archive == other.archive and45 self.archive == other.archive and
44 self.distroseries == other.distroseries and46 self.distroseries == other.distroseries and
45 self.component == other.component and47 self.component == other.component and
46 self.pocket == other.pocket):48 self.pocket == other.pocket and
49 self.packagesets == other.packagesets):
47 return True50 return True
48 return False51 return False
4952
@@ -63,6 +66,10 @@
63 if self.component is not None:66 if self.component is not None:
64 result += ' (%s)' % self.component.name67 result += ' (%s)' % self.component.name
6568
69 if len(self.packagesets) > 0:
70 result += ' [%s]' % (
71 ", ".join([str(p.name) for p in self.packagesets]),)
72
66 return result73 return result
6774
6875
@@ -71,7 +78,8 @@
7178
7279
73def build_package_location(distribution_name, suite=None, purpose=None,80def build_package_location(distribution_name, suite=None, purpose=None,
74 person_name=None, archive_name=None):81 person_name=None, archive_name=None,
82 packageset_names=None):
75 """Convenience function to build PackageLocation objects."""83 """Convenience function to build PackageLocation objects."""
7684
77 # XXX kiko 2007-10-24:85 # XXX kiko 2007-10-24:
@@ -87,6 +95,7 @@
87 # Avoid circular imports.95 # Avoid circular imports.
88 from lp.registry.interfaces.distribution import IDistributionSet96 from lp.registry.interfaces.distribution import IDistributionSet
89 from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet97 from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet
98 from lp.soyuz.interfaces.packageset import IPackagesetSet
90 from lp.registry.interfaces.pocket import PackagePublishingPocket99 from lp.registry.interfaces.pocket import PackagePublishingPocket
91100
92 try:101 try:
@@ -144,4 +153,17 @@
144 distroseries = distribution.currentseries153 distroseries = distribution.currentseries
145 pocket = PackagePublishingPocket.RELEASE154 pocket = PackagePublishingPocket.RELEASE
146155
147 return PackageLocation(archive, distribution, distroseries, pocket)156 packagesets = []
157 if packageset_names:
158 packageset_set = getUtility(IPackagesetSet)
159 for packageset_name in packageset_names:
160 try:
161 packageset = packageset_set.getByName(
162 packageset_name, distroseries=distroseries)
163 except NotFoundError, err:
164 raise PackageLocationError(
165 "Could not find packageset %s" % err)
166 packagesets.append(packageset)
167
168 return PackageLocation(archive, distribution, distroseries, pocket,
169 packagesets=packagesets)
148170
=== added file 'lib/lp/soyuz/adapters/tests/__init__.py'
=== modified file 'lib/lp/soyuz/adapters/tests/test_packagelocation.py'
--- lib/lp/soyuz/adapters/tests/test_packagelocation.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/adapters/tests/test_packagelocation.py 2010-06-22 12:51:37 +0000
@@ -20,10 +20,11 @@
2020
21 def getPackageLocation(self, distribution_name='ubuntu', suite=None,21 def getPackageLocation(self, distribution_name='ubuntu', suite=None,
22 purpose=None, person_name=None,22 purpose=None, person_name=None,
23 archive_name=None):23 archive_name=None, packageset_names=None):
24 """Use a helper method to setup a `PackageLocation` object."""24 """Use a helper method to setup a `PackageLocation` object."""
25 return build_package_location(25 return build_package_location(
26 distribution_name, suite, purpose, person_name, archive_name)26 distribution_name, suite, purpose, person_name, archive_name,
27 packageset_names=packageset_names)
2728
28 def testSetupLocationForCOPY(self):29 def testSetupLocationForCOPY(self):
29 """`PackageLocation` for COPY archives."""30 """`PackageLocation` for COPY archives."""
@@ -45,6 +46,7 @@
45 self.assertEqual(location.pocket.name, 'RELEASE')46 self.assertEqual(location.pocket.name, 'RELEASE')
46 self.assertEqual(location.archive.displayname,47 self.assertEqual(location.archive.displayname,
47 'Copy archive now-comes-the-mystery for Mysteryman')48 'Copy archive now-comes-the-mystery for Mysteryman')
49 self.assertEqual([], location.packagesets)
4850
49 def testSetupLocationForPRIMARY(self):51 def testSetupLocationForPRIMARY(self):
50 """`PackageLocation` for PRIMARY archives."""52 """`PackageLocation` for PRIMARY archives."""
@@ -54,6 +56,7 @@
54 self.assertEqual(location.pocket.name, 'RELEASE')56 self.assertEqual(location.pocket.name, 'RELEASE')
55 self.assertEqual(location.archive.displayname,57 self.assertEqual(location.archive.displayname,
56 'Primary Archive for Ubuntu Linux')58 'Primary Archive for Ubuntu Linux')
59 self.assertEqual([], location.packagesets)
5760
58 def testSetupLocationForPPA(self):61 def testSetupLocationForPPA(self):
59 """`PackageLocation` for PPA archives."""62 """`PackageLocation` for PPA archives."""
@@ -65,6 +68,7 @@
65 self.assertEqual(location.pocket.name, 'RELEASE')68 self.assertEqual(location.pocket.name, 'RELEASE')
66 self.assertEqual(location.archive.displayname,69 self.assertEqual(location.archive.displayname,
67 'PPA for Celso Providelo')70 'PPA for Celso Providelo')
71 self.assertEqual([], location.packagesets)
6872
69 def testSetupLocationForPARTNER(self):73 def testSetupLocationForPARTNER(self):
70 """`PackageLocation` for PARTNER archives."""74 """`PackageLocation` for PARTNER archives."""
@@ -74,6 +78,16 @@
74 self.assertEqual(location.pocket.name, 'RELEASE')78 self.assertEqual(location.pocket.name, 'RELEASE')
75 self.assertEqual(location.archive.displayname,79 self.assertEqual(location.archive.displayname,
76 'Partner Archive for Ubuntu Linux')80 'Partner Archive for Ubuntu Linux')
81 self.assertEqual([], location.packagesets)
82
83 def testSetupLocationWithPackagesets(self):
84 packageset_name1 = u"foo-packageset"
85 packageset_name2 = u"bar-packageset"
86 packageset1 = self.factory.makePackageset(name=packageset_name1)
87 packageset2 = self.factory.makePackageset(name=packageset_name2)
88 location = self.getPackageLocation(
89 packageset_names=[packageset_name1, packageset_name2])
90 self.assertEqual([packageset1, packageset2], location.packagesets)
7791
78 def testSetupLocationUnknownDistribution(self):92 def testSetupLocationUnknownDistribution(self):
79 """`PackageLocationError` is raised on unknown distribution."""93 """`PackageLocationError` is raised on unknown distribution."""
@@ -115,6 +129,24 @@
115 distribution_name='debian',129 distribution_name='debian',
116 purpose=ArchivePurpose.PARTNER)130 purpose=ArchivePurpose.PARTNER)
117131
132 def test_build_package_location_when_packageset_unknown(self):
133 """`PackageLocationError` is raised on unknown packageset."""
134 self.assertRaises(
135 PackageLocationError,
136 self.getPackageLocation,
137 distribution_name='debian',
138 packageset_names=[u"unknown"])
139
140 def test_build_package_location_when_one_packageset_unknown(self):
141 """Test that with one of two packagesets unknown."""
142 packageset_name = u"foo-packageset"
143 self.factory.makePackageset(name=packageset_name)
144 self.assertRaises(
145 PackageLocationError,
146 self.getPackageLocation,
147 distribution_name='debian',
148 packageset_names=[packageset_name, u"unknown"])
149
118 def testSetupLocationPPANotMatchingDistribution(self):150 def testSetupLocationPPANotMatchingDistribution(self):
119 """`PackageLocationError` is raised when PPA does not match the151 """`PackageLocationError` is raised when PPA does not match the
120 distribution."""152 distribution."""
@@ -167,6 +199,18 @@
167 distribution_name='ubuntu', purpose=ArchivePurpose.PARTNER)199 distribution_name='ubuntu', purpose=ArchivePurpose.PARTNER)
168 self.assertNotEqual(location_ubuntu_partner, location_cprov_ppa)200 self.assertNotEqual(location_ubuntu_partner, location_cprov_ppa)
169201
202 def testComparePackagesets(self):
203 location_ubuntu_hoary = self.getPackageLocation()
204 location_ubuntu_hoary_again = self.getPackageLocation()
205 packageset = self.factory.makePackageset()
206 location_ubuntu_hoary.packagesets = [packageset]
207 self.assertNotEqual(
208 location_ubuntu_hoary, location_ubuntu_hoary_again)
209
210 location_ubuntu_hoary_again.packagesets = [packageset]
211 self.assertEqual(
212 location_ubuntu_hoary, location_ubuntu_hoary_again)
213
170 def testRepresentation(self):214 def testRepresentation(self):
171 """Check if PackageLocation is represented correctly."""215 """Check if PackageLocation is represented correctly."""
172 location_ubuntu_hoary = self.getPackageLocation()216 location_ubuntu_hoary = self.getPackageLocation()
@@ -204,6 +248,14 @@
204 str(location_ubuntu_partner),248 str(location_ubuntu_partner),
205 'Partner Archive for Ubuntu Linux: hoary-RELEASE')249 'Partner Archive for Ubuntu Linux: hoary-RELEASE')
206250
251 self.factory.makePackageset(name=u"foo-packageset")
252 location_ubuntu_packageset = self.getPackageLocation(
253 packageset_names=[u"foo-packageset"])
254 self.assertEqual(
255 str(location_ubuntu_packageset),
256 'Primary Archive for Ubuntu Linux: '
257 'hoary-RELEASE [foo-packageset]')
258
207259
208def test_suite():260def test_suite():
209 return unittest.TestLoader().loadTestsFromName(__name__)261 return unittest.TestLoader().loadTestsFromName(__name__)
210262
=== modified file 'lib/lp/soyuz/model/packagecloner.py'
--- lib/lp/soyuz/model/packagecloner.py 2010-01-12 08:36:58 +0000
+++ lib/lp/soyuz/model/packagecloner.py 2010-06-22 12:51:37 +0000
@@ -305,7 +305,7 @@
305 to be copied.305 to be copied.
306 """306 """
307 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)307 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
308 store.execute('''308 query = ('''
309 INSERT INTO SourcePackagePublishingHistory (309 INSERT INTO SourcePackagePublishingHistory (
310 sourcepackagerelease, distroseries, status, component,310 sourcepackagerelease, distroseries, status, component,
311 section, archive, datecreated, datepublished, pocket)311 section, archive, datecreated, datepublished, pocket)
@@ -322,6 +322,18 @@
322 PackagePublishingStatus.PENDING,322 PackagePublishingStatus.PENDING,
323 PackagePublishingStatus.PUBLISHED,323 PackagePublishingStatus.PUBLISHED,
324 origin.pocket, origin.archive))324 origin.pocket, origin.archive))
325 if origin.packagesets:
326 query += '''AND spph.sourcepackagerelease IN
327 (SELECT spr.id
328 FROM SourcePackageRelease AS spr,
329 packagesetsources AS pss,
330 flatpackagesetinclusion AS fpsi
331 WHERE spr.sourcepackagename
332 = pss.sourcepackagename
333 AND pss.packageset = fpsi.child
334 AND fpsi.parent in %s)
335 ''' % sqlvalues([p.id for p in origin.packagesets])
336 store.execute(query)
325337
326 def packageSetDiff(self, origin, destination, logger=None):338 def packageSetDiff(self, origin, destination, logger=None):
327 """Please see `IPackageCloner`."""339 """Please see `IPackageCloner`."""
328340
=== modified file 'lib/lp/soyuz/scripts/populate_archive.py'
--- lib/lp/soyuz/scripts/populate_archive.py 2010-06-22 12:51:34 +0000
+++ lib/lp/soyuz/scripts/populate_archive.py 2010-06-22 12:51:37 +0000
@@ -53,7 +53,7 @@
53 self, from_archive, from_distribution, from_suite, from_user,53 self, from_archive, from_distribution, from_suite, from_user,
54 component, to_distribution, to_suite, to_archive, to_user, reason,54 component, to_distribution, to_suite, to_archive, to_user, reason,
55 include_binaries, arch_tags, merge_copy_flag,55 include_binaries, arch_tags, merge_copy_flag,
56 packageset_delta_flag):56 packageset_delta_flag, packageset_tags):
57 """Create archive, populate it with packages and builds.57 """Create archive, populate it with packages and builds.
5858
59 Please note: if a component was specified for the origin then the59 Please note: if a component was specified for the origin then the
@@ -79,6 +79,9 @@
79 existing copy archive.79 existing copy archive.
80 :param packageset_delta_flag: only show packages that are fresher or80 :param packageset_delta_flag: only show packages that are fresher or
81 new in the origin archive. Do not copy anything.81 new in the origin archive. Do not copy anything.
82
83 :param packageset_tags: list of packagesets to limit the packages
84 copied to.
82 """85 """
83 # Avoid circular imports.86 # Avoid circular imports.
84 from lp.registry.interfaces.person import IPersonSet87 from lp.registry.interfaces.person import IPersonSet
@@ -108,13 +111,14 @@
108 for proc_family in proc_families:111 for proc_family in proc_families:
109 ignore_this = aa_set.new(archive, proc_family)112 ignore_this = aa_set.new(archive, proc_family)
110113
111 def build_location(distro, suite, component):114 def build_location(distro, suite, component, packageset_names=None):
112 """Build and return package location."""115 """Build and return package location."""
113 location = build_package_location(distro, suite=suite)116 location = build_package_location(
117 distro, suite=suite, packageset_names=packageset_names)
114 if component is not None:118 if component is not None:
115 try:119 try:
116 the_component = getUtility(IComponentSet)[component]120 the_component = getUtility(IComponentSet)[component]
117 except NotFoundError, e:121 except NotFoundError:
118 raise SoyuzScriptError(122 raise SoyuzScriptError(
119 "Invalid component name: '%s'" % component)123 "Invalid component name: '%s'" % component)
120 location.component = the_component124 location.component = the_component
@@ -122,7 +126,9 @@
122126
123 archive_set = getUtility(IArchiveSet)127 archive_set = getUtility(IArchiveSet)
124 # Build the origin package location.128 # Build the origin package location.
125 the_origin = build_location(from_distribution, from_suite, component)129 the_origin = build_location(
130 from_distribution, from_suite, component,
131 packageset_names=packageset_tags)
126132
127 # Use a non-PPA(!) origin archive if specified and existent.133 # Use a non-PPA(!) origin archive if specified and existent.
128 if from_archive is not None and from_user is None:134 if from_archive is not None and from_user is None:
@@ -315,7 +321,7 @@
315 opts.from_user, opts.component, opts.to_distribution,321 opts.from_user, opts.component, opts.to_distribution,
316 opts.to_suite, opts.to_archive, opts.to_user, opts.reason,322 opts.to_suite, opts.to_archive, opts.to_user, opts.reason,
317 opts.include_binaries, opts.arch_tags, opts.merge_copy_flag,323 opts.include_binaries, opts.arch_tags, opts.merge_copy_flag,
318 opts.packageset_delta_flag)324 opts.packageset_delta_flag, opts.packageset_tags)
319325
320 def add_my_options(self):326 def add_my_options(self):
321 """Parse command line arguments for copy archive creation/population.327 """Parse command line arguments for copy archive creation/population.
@@ -379,6 +385,11 @@
379 'Only show packages that are fresher or new in origin '385 'Only show packages that are fresher or new in origin '
380 'archive. Destination archive must exist already.'))386 'archive. Destination archive must exist already.'))
381387
388 self.parser.add_option(
389 "--package-set", dest="packageset_tags", action="append",
390 help=(
391 'Limit to copying packages in the selected packagesets.'))
392
382 def _createMissingBuilds(393 def _createMissingBuilds(
383 self, distroseries, archive, proc_families):394 self, distroseries, archive, proc_families):
384 """Create builds for all cloned source packages.395 """Create builds for all cloned source packages.
385396
=== modified file 'lib/lp/soyuz/scripts/tests/test_populatearchive.py'
--- lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-06-22 12:51:34 +0000
+++ lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-06-22 12:51:37 +0000
@@ -206,7 +206,7 @@
206 def getScript(self, test_args=None):206 def getScript(self, test_args=None):
207 """Return an ArchivePopulator instance."""207 """Return an ArchivePopulator instance."""
208 if test_args is None:208 if test_args is None:
209 test_args = []209 test_args = []
210 script = ArchivePopulator("test copy archives", test_args=test_args)210 script = ArchivePopulator("test copy archives", test_args=test_args)
211 script.logger = QuietFakeLogger()211 script.logger = QuietFakeLogger()
212 script.txn = self.layer.txn212 script.txn = self.layer.txn
@@ -214,7 +214,7 @@
214214
215 def copyArchive(self, distroseries, archive_name, owner,215 def copyArchive(self, distroseries, archive_name, owner,
216 architectures=None, component="main", from_user=None,216 architectures=None, component="main", from_user=None,
217 from_archive=None):217 from_archive=None, packageset_names=None):
218 """Run the copy-archive script."""218 """Run the copy-archive script."""
219 extra_args = [219 extra_args = [
220 '--from-distribution', distroseries.distribution.name,220 '--from-distribution', distroseries.distribution.name,
@@ -240,6 +240,12 @@
240 for architecture in architectures:240 for architecture in architectures:
241 extra_args.extend(['-a', architecture])241 extra_args.extend(['-a', architecture])
242242
243 if packageset_names is None:
244 packageset_names = []
245
246 for packageset_name in packageset_names:
247 extra_args.extend(['--package-set', packageset_name])
248
243 script = self.getScript(test_args=extra_args)249 script = self.getScript(test_args=extra_args)
244 script.mainTask()250 script.mainTask()
245251
@@ -521,6 +527,86 @@
521 component="main")527 component="main")
522 self.checkBuilds(copy_archive, package_infos)528 self.checkBuilds(copy_archive, package_infos)
523529
530 def testCopyArchiveSubsetsBasedOnPackageset(self):
531 """Test that --package-set limits the sources copied."""
532 package_infos = [
533 PackageInfo(
534 "bzr", "2.1", status=PackagePublishingStatus.PUBLISHED),
535 PackageInfo(
536 "apt", "2.2", status=PackagePublishingStatus.PUBLISHED),
537 ]
538 owner = self.createTargetOwner()
539 distroseries = self.createSourceDistribution(package_infos)
540 packageset_name = u"apt-packageset"
541 spn = self.factory.getOrMakeSourcePackageName(name="apt")
542 self.factory.makePackageset(
543 name=packageset_name, distroseries=distroseries, packages=(spn,))
544 archive_name = self.getTargetArchiveName(distroseries.distribution)
545 copy_archive = self.copyArchive(
546 distroseries, archive_name, owner,
547 packageset_names=[packageset_name])
548 self.checkCopiedSources(
549 copy_archive, distroseries, [package_infos[1]])
550
551 def testCopyArchiveUnionsPackagesets(self):
552 """Test that package sets are unioned when copying archives."""
553 package_infos = [
554 PackageInfo(
555 "bzr", "2.1", status=PackagePublishingStatus.PUBLISHED),
556 PackageInfo(
557 "apt", "2.2", status=PackagePublishingStatus.PUBLISHED),
558 PackageInfo(
559 "gcc", "4.5", status=PackagePublishingStatus.PUBLISHED),
560 ]
561 owner = self.createTargetOwner()
562 distroseries = self.createSourceDistribution(package_infos)
563 apt_packageset_name = u"apt-packageset"
564 apt_spn = self.factory.getOrMakeSourcePackageName(name="apt")
565 gcc_packageset_name = u"gcc-packageset"
566 gcc_spn = self.factory.getOrMakeSourcePackageName(name="gcc")
567 self.factory.makePackageset(
568 name=apt_packageset_name, distroseries=distroseries,
569 packages=(apt_spn,))
570 self.factory.makePackageset(
571 name=gcc_packageset_name, distroseries=distroseries,
572 packages=(gcc_spn,))
573 archive_name = self.getTargetArchiveName(distroseries.distribution)
574 copy_archive = self.copyArchive(
575 distroseries, archive_name, owner,
576 packageset_names=[apt_packageset_name, gcc_packageset_name])
577 self.checkCopiedSources(
578 copy_archive, distroseries, package_infos[1:])
579
580 def testCopyArchiveRecursivelyCopiesPackagesets(self):
581 """Test that package set copies include subsets."""
582 package_infos = [
583 PackageInfo(
584 "bzr", "2.1", status=PackagePublishingStatus.PUBLISHED),
585 PackageInfo(
586 "apt", "2.2", status=PackagePublishingStatus.PUBLISHED),
587 PackageInfo(
588 "gcc", "4.5", status=PackagePublishingStatus.PUBLISHED),
589 ]
590 owner = self.createTargetOwner()
591 distroseries = self.createSourceDistribution(package_infos)
592 apt_packageset_name = u"apt-packageset"
593 apt_spn = self.factory.getOrMakeSourcePackageName(name="apt")
594 gcc_packageset_name = u"gcc-packageset"
595 gcc_spn = self.factory.getOrMakeSourcePackageName(name="gcc")
596 apt_packageset = self.factory.makePackageset(
597 name=apt_packageset_name, distroseries=distroseries,
598 packages=(apt_spn,))
599 gcc_packageset = self.factory.makePackageset(
600 name=gcc_packageset_name, distroseries=distroseries,
601 packages=(gcc_spn,))
602 apt_packageset.add((gcc_packageset,))
603 archive_name = self.getTargetArchiveName(distroseries.distribution)
604 copy_archive = self.copyArchive(
605 distroseries, archive_name, owner,
606 packageset_names=[apt_packageset_name])
607 self.checkCopiedSources(
608 copy_archive, distroseries, package_infos[1:])
609
524 def testCopyFromPPA(self):610 def testCopyFromPPA(self):
525 """Test we can create a copy archive with a PPA as the source."""611 """Test we can create a copy archive with a PPA as the source."""
526 ppa_owner_name = "ppa-owner"612 ppa_owner_name = "ppa-owner"
@@ -712,6 +798,20 @@
712 exception_type=SoyuzScriptError,798 exception_type=SoyuzScriptError,
713 exception_text="Invalid user name: '%s'" % invalid_user)799 exception_text="Invalid user name: '%s'" % invalid_user)
714800
801 def testUnknownPackagesetName(self):
802 """Try copy archive population with an unknown packageset name.
803
804 The caller can request copying specific packagesets. We test
805 what happens if they request a packageset that doesn't exist.
806 """
807 unknown_packageset = "unknown"
808 extra_args = ['-a', '386', "--package-set", unknown_packageset]
809 self.runScript(
810 extra_args=extra_args,
811 exception_type=PackageLocationError,
812 exception_text="Could not find packageset No such package set"
813 " (in the specified distro series): '%s'." % unknown_packageset)
814
715 def testPackagesetDelta(self):815 def testPackagesetDelta(self):
716 """Try to calculate the delta between two source package sets."""816 """Try to calculate the delta between two source package sets."""
717 hoary = getUtility(IDistributionSet)['ubuntu']['hoary']817 hoary = getUtility(IDistributionSet)['ubuntu']['hoary']

Subscribers

People subscribed via source and target branches

to status/vote changes: