Merge lp:~stevenk/launchpad/fixes-bug-529950 into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Deryck Hodge
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~stevenk/launchpad/fixes-bug-529950
Merge into: lp:launchpad
Diff against target: 215 lines (+63/-50)
4 files modified
lib/lp/soyuz/doc/gina.txt (+7/-5)
lib/lp/soyuz/scripts/gina/archive.py (+3/-2)
lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources (+14/-0)
scripts/gina.py (+39/-43)
To merge this branch: bzr merge lp:~stevenk/launchpad/fixes-bug-529950
Reviewer Review Type Date Requested Status
Deryck Hodge (community) release-critical Approve
Michael Nelson (community) code Approve
Jelmer Vernooij (community) code mentat Approve
Review via email: mp+21546@code.launchpad.net

Commit message

Fix scripts/gina.py to be able to import multiple versions of the same source package from a single archive.

Description of the change

This branch fixes gina to be able to import multiple versions of the same source package from a single repository.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Steve,

Thanks, nice straightforward change.

My only concern is that this would perhaps break spnames_only mode. My understanding is that scripts/gina.py:193 now loops over sets, not dictionaries.

review: Needs Information (code mentat)
Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (5.4 KiB)

Hi Steve and Jelmer,

Nice find Jelmer. It's a shame (but not a surprise :/), that we don't seem to have a test for the sourcepackagenames_only option. It's only referenced in the config. Steve, feel free to add one before fixing the issue :) Actually, I can't see it referenced anywhere in the lp-production-configs? Do we even use it? (if not, we could remove it).

I've just got a few style questions below.

Thanks for the fix!

> === modified file 'lib/lp/soyuz/scripts/gina/archive.py'
> --- lib/lp/soyuz/scripts/gina/archive.py 2009-06-25 04:06:00 +0000
> +++ lib/lp/soyuz/scripts/gina/archive.py 2010-03-17 11:15:37 +0000
> @@ -207,7 +207,7 @@
> log.exception("Invalid Sources stanza in %s" %
> info_set.sources_tagfile)
> continue
> - self.src_map[src_name] = src_tmp
> + self.src_map.setdefault(src_name, []).append(src_tmp)

Not sure what you prefer, but I think this is more readable like this:

http://pastebin.ubuntu.com/399865/

which also passes the test. Up to you.

> === modified file 'scripts/gina.py'
> --- scripts/gina.py 2009-10-13 14:38:07 +0000
> +++ scripts/gina.py 2010-03-17 11:15:37 +0000
> @@ -229,44 +229,45 @@
> npacks = len(packages_map.src_map)
> log.info('%i Source Packages to be imported' % npacks)
>
> - for source in sorted(packages_map.src_map.values(),
> - key=lambda x: x.get("Package")):
> - count += 1
> - package_name = source.get("Package", "unknown")
> - try:
> + for list_source in sorted(packages_map.src_map.values(),
> + key=lambda x: x[0].get("Package")):

The python style guide used to allow the previous indentation, but it now should be:

   for list_source in sorted(
       packages_map.src_map.values(), key=lambda x: x[0].get("Package")):

See https://dev.launchpad.net/PythonStyleGuide#Multiline%20function%20calls

Or another option, if you rename your var 'list_source' to simply 'source_list', then you can create your source_lists prior to the iteration (for source_list in source_lists:). See what you think.

> + for source in list_source:
> + count += 1
> + package_name = source.get("Package", "unknown")
> try:
> - do_one_sourcepackage(source, kdb, package_root, keyrings,
> + try:
> + do_one_sourcepackage(source, kdb, package_root, keyrings,
> importer_handler)

Similar, if you need to wrap the args to a fn call, they should start on the next line.

> - except psycopg2.Error:
> - log.exception("Database error: unable to create "
> + except psycopg2.Error:
> + log.exception("Database error: unable to create "
> "SourcePackage for %s. Retrying once.."
> % package_name)

And again.

> - importer_handler.abort()
> - time.sleep(15)
> - do_one_sourcepackage(source, kdb, package_root, keyrings,
> + import...

Read more...

review: Needs Information (code)
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Minor comment; lib/canonical/config/schema-lazr.conf and configs/schema-lazr.conf still reference spnamesonly, can you also remove those ?

review: Approve (code mentat)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

> Minor comment; lib/canonical/config/schema-lazr.conf and configs/schema-
> lazr.conf still reference spnamesonly, can you also remove those ?

I was trying to figure out why I only found one reference initially... configs/schema-lazr.conf is a link ;)

Also, the earlier code in scripts/gina.py that actually defines the variable from the config should go to.

> spnames_only = target_section.sourcepackagenames_only

Thanks!

review: Approve (code)
Revision history for this message
Deryck Hodge (deryck) wrote :

Given that this would have to be CP'ed anyway, I'm fine with letting it in before the current release.

review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/doc/gina.txt'
2--- lib/lp/soyuz/doc/gina.txt 2010-01-10 04:58:44 +0000
3+++ lib/lp/soyuz/doc/gina.txt 2010-03-25 10:13:54 +0000
4@@ -63,6 +63,8 @@
5
6 * archive-copier, a source package which generates one udeb
7 in debian-installer. Its maintainer has a name which contains a ","
8+ * archive-copier, again, with a different version number to see that
9+ both versions get correctly imported.
10 * db1-compat, source package what generates 1 binary package. The same
11 version was included in both hoary and breezy, but its source
12 package's section and its binary package's priority were changed in
13@@ -317,13 +319,13 @@
14 util-linux (again, poor thing)
15
16 >>> print SSPPH.select().count() - orig_sspph_count
17- 20
18+ 21
19
20 >>> print SSPPH.selectBy(
21 ... componentID=1,
22 ... pocket=PackagePublishingPocket.RELEASE).count() - \
23 ... orig_sspph_main_count
24- 20
25+ 21
26
27 === Testing Binary Package Results ===
28
29@@ -532,7 +534,7 @@
30 >>> SBPPH.select().count() - orig_sbpph_count
31 47
32 >>> print SSPPH.select().count() - orig_sspph_count
33- 22
34+ 23
35
36 Check that the overrides we did were correctly issued. We can't use selectOneBy
37 because, of course, there may be multiple rows published for that package --
38@@ -607,7 +609,7 @@
39
40 >>> source_difference = partner_source_set_after - partner_source_set
41 >>> len(source_difference)
42- 11
43+ 12
44
45 >>> binary_difference = partner_binary_set_after - partner_binary_set
46 >>> len(binary_difference)
47@@ -700,7 +702,7 @@
48
49 >>> lenny_sources = SSPPH.select("distroseries = %s" % sqlvalues(lenny))
50 >>> lenny_sources.count()
51- 11
52+ 12
53
54 >>> print set([pub.status.name for pub in lenny_sources])
55 set(['PENDING'])
56
57=== modified file 'lib/lp/soyuz/scripts/gina/archive.py'
58--- lib/lp/soyuz/scripts/gina/archive.py 2009-06-25 04:06:00 +0000
59+++ lib/lp/soyuz/scripts/gina/archive.py 2010-03-25 10:13:54 +0000
60@@ -18,6 +18,7 @@
61 import apt_pkg
62 import tempfile
63 import os
64+from collections import defaultdict
65
66 from canonical.launchpad.scripts import log
67 from lp.soyuz.scripts.gina import call
68@@ -185,7 +186,7 @@
69
70 def create_maps(self, arch_component_items):
71 # Create the maps
72- self.src_map = {}
73+ self.src_map = defaultdict(list)
74 self.bin_map = {}
75
76 # Iterate over ArchComponentItems instance to cover
77@@ -207,7 +208,7 @@
78 log.exception("Invalid Sources stanza in %s" %
79 info_set.sources_tagfile)
80 continue
81- self.src_map[src_name] = src_tmp
82+ self.src_map[src_name].append(src_tmp)
83
84 # Check if it's in source-only mode, if so, skip binary index
85 # mapping.
86
87=== modified file 'lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources'
88--- lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources 2005-12-01 22:49:03 +0000
89+++ lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources 2010-03-25 10:13:54 +0000
90@@ -12,6 +12,20 @@
91 41b62efd646e5f010d6e34862503e5a5 510 archive-copier_0.1.5.dsc
92 cc6132eb7b8bc715ddd1690a68d7df89 16600 archive-copier_0.1.5.tar.gz
93
94+Package: archive-copier
95+Binary: archive-copier
96+Version: 0.3.6
97+Section: misc
98+Maintainer: Colin Watson <cjwatson@ubuntu.com>
99+Build-Depends: debhelper (>= 4.2)
100+Architecture: any
101+Standards-Version: 3.6.2
102+Format: 1.0
103+Directory: pool/main/a/archive-copier
104+Files:
105+ 3b6c16962308a4b8b753ec8d5b289506 510 archive-copier_0.3.6.dsc
106+ 6ca2e13475a9aa0a694b85330d905dbd 19598 archive-copier_0.3.6.tar.gz
107+
108 Package: db1-compat
109 Binary: libdb1-compat
110 Version: 2.1.3-7
111
112=== modified file 'lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources.gz'
113Binary files lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources.gz 2005-12-01 22:49:03 +0000 and lib/lp/soyuz/scripts/tests/gina_test_archive/dists/hoary/main/source/Sources.gz 2010-03-25 10:13:54 +0000 differ
114=== modified file 'scripts/gina.py'
115--- scripts/gina.py 2009-10-13 14:38:07 +0000
116+++ scripts/gina.py 2010-03-25 10:13:54 +0000
117@@ -194,14 +194,6 @@
118 dry_run, kdb, package_root, keyrings,
119 pocket, component_override)
120
121- if spnames_only:
122- log.info('Running in SourcePackageName-only mode...')
123- for source in packages_map.src_map.itervalues():
124- log.info('Ensuring %s name' % source['Package'])
125- importer_handler.ensure_sourcepackagename(source['Package'])
126- log.info('done')
127- return
128-
129 import_sourcepackages(packages_map, kdb, package_root, keyrings,
130 importer_handler)
131 importer_handler.commit()
132@@ -229,44 +221,48 @@
133 npacks = len(packages_map.src_map)
134 log.info('%i Source Packages to be imported' % npacks)
135
136- for source in sorted(packages_map.src_map.values(),
137- key=lambda x: x.get("Package")):
138- count += 1
139- package_name = source.get("Package", "unknown")
140- try:
141+ for list_source in sorted(
142+ packages_map.src_map.values(), key=lambda x: x[0].get("Package")):
143+ for source in list_source:
144+ count += 1
145+ package_name = source.get("Package", "unknown")
146 try:
147- do_one_sourcepackage(source, kdb, package_root, keyrings,
148- importer_handler)
149- except psycopg2.Error:
150- log.exception("Database error: unable to create "
151- "SourcePackage for %s. Retrying once.."
152- % package_name)
153- importer_handler.abort()
154- time.sleep(15)
155- do_one_sourcepackage(source, kdb, package_root, keyrings,
156- importer_handler)
157- except (InvalidVersionError, MissingRequiredArguments,
158+ try:
159+ do_one_sourcepackage(
160+ source, kdb, package_root, keyrings, importer_handler)
161+ except psycopg2.Error:
162+ log.exception(
163+ "Database error: unable to create SourcePackage "
164+ "for %s. Retrying once.." % package_name)
165+ importer_handler.abort()
166+ time.sleep(15)
167+ do_one_sourcepackage(
168+ source, kdb, package_root, keyrings, importer_handler)
169+ except (
170+ InvalidVersionError, MissingRequiredArguments,
171 DisplayNameDecodingError):
172- log.exception("Unable to create SourcePackageData for %s" %
173- package_name)
174- continue
175- except (PoolFileNotFound, ExecutionError):
176- # Problems with katie db stuff of opening files
177- log.exception("Error processing package files for %s" %
178- package_name)
179- continue
180- except psycopg2.Error:
181- log.exception("Database errors made me give up: unable to create "
182- "SourcePackage for %s" % package_name)
183- importer_handler.abort()
184- continue
185- except MultiplePackageReleaseError:
186- log.exception("Database duplication processing %s" %
187- package_name)
188- continue
189+ log.exception(
190+ "Unable to create SourcePackageData for %s" %
191+ package_name)
192+ continue
193+ except (PoolFileNotFound, ExecutionError):
194+ # Problems with katie db stuff of opening files
195+ log.exception(
196+ "Error processing package files for %s" % package_name)
197+ continue
198+ except psycopg2.Error:
199+ log.exception(
200+ "Database errors made me give up: unable to create "
201+ "SourcePackage for %s" % package_name)
202+ importer_handler.abort()
203+ continue
204+ except MultiplePackageReleaseError:
205+ log.exception(
206+ "Database duplication processing %s" % package_name)
207+ continue
208
209- if COUNTDOWN and count % COUNTDOWN == 0:
210- log.warn('%i/%i sourcepackages processed' % (count, npacks))
211+ if COUNTDOWN and count % COUNTDOWN == 0:
212+ log.warn('%i/%i sourcepackages processed' % (count, npacks))
213
214
215 def do_one_sourcepackage(source, kdb, package_root, keyrings,