Merge lp:~cjwatson/ubuntu-dev-tools/syncpackage-lp into lp:~ubuntu-dev/ubuntu-dev-tools/trunk
- syncpackage-lp
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 1120 |
Proposed branch: | lp:~cjwatson/ubuntu-dev-tools/syncpackage-lp |
Merge into: | lp:~ubuntu-dev/ubuntu-dev-tools/trunk |
Diff against target: |
476 lines (+239/-31) 8 files modified
debian/changelog (+8/-0) doc/requestsync.1 (+5/-0) doc/syncpackage.1 (+27/-11) requestsync (+4/-0) syncpackage (+149/-17) ubuntutools/archive.py (+24/-0) ubuntutools/lp/lpapicache.py (+20/-1) ubuntutools/requestsync/lp.py (+2/-2) |
To merge this branch: | bzr merge lp:~cjwatson/ubuntu-dev-tools/syncpackage-lp |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benjamin Drung | Approve | ||
Iain Lane | Approve | ||
Stefano Rivera | Approve | ||
Review via email: mp+71718@code.launchpad.net |
Commit message
Description of the change
Native source syncing in Launchpad is finally ready! This branch adds code to syncpackage to use it, keeping the old mode of operation available behind the --no-lp option.
I'd like to get this into the Ubuntu archive before we announce the facility for general use.
- 1124. By Colin Watson
-
merge trunk
Stefano Rivera (stefanor) wrote : | # |
Should we make --no-lp spit out a warning when run?
ack-sync is supposed to go away, and be replaced by a similar feature in sponsor-patch (which will have to test build, by doing a syncpackage --no-lp). Considering that's it's just one simple API call, I wouldn't worry about using the same function in both.
- 1125. By Colin Watson
-
typo
Iain Lane (laney) wrote : | # |
It is just one call, but so is other stuff in there. I think it's better to preserve encapsulation (and provide a nicer interface than raw API calls). I don't want to hold this MP up on that though; it can be done when refactoring the other tools.
- 1126. By Colin Watson
-
move copyPackage into lpapicache for better encapsulation
- 1127. By Colin Watson
-
handle -d in Launchpad copy mode
Colin Watson (cjwatson) wrote : | # |
Iain, thanks for your suggestions; I believe I've fixed all of these now.
Stefano, I think eventually we probably do want to deprecate --no-lp rather more completely, but for now it's still useful for things like uploading to PPAs (which copy() could eventually support, I think, but doesn't yet) and for fakesyncs when upstream tarballs differ. For now, I think that having to type an extra option to invoke it and the fact that it's slower and more effort (it has to download the package and then you have to upload the result manually) should be enough discouragement.
Benjamin Drung (bdrung) wrote : | # |
1) You could use ubuntutools.
2) syncpackage --lp doesn't seem to support sponsoring syncs or how is this supposed to work?
3) Is it possible to have online tests for syncpackage to test the new behaviour and for checking that there is no regression?
4) What happens if the source tarballs differ with --lp?
- 1128. By Colin Watson
-
use ubuntutools.
question - 1129. By Colin Watson
-
syncpackage: Require -f/--force option to overwrite Ubuntu changes.
Colin Watson (cjwatson) wrote : | # |
On Tue, Aug 16, 2011 at 05:55:50PM -0000, Benjamin Drung wrote:
> 1) You could use ubuntutools.
I didn't know about that, thanks. Done.
> 2) syncpackage --lp doesn't seem to support sponsoring syncs or how is this supposed to work?
I've filed https:/
> 3) Is it possible to have online tests for syncpackage to test the new behaviour and for checking that there is no regression?
You can use '-l dogfood' or '-l staging' (with varying degrees of
current-data-ness and likeliness-
> 4) What happens if the source tarballs differ with --lp?
I believe that you will get an error by e-mail when Launchpad tries to
process the copy job, and you'll then need to go back and use --no-lp.
I'd prefer to avoid having to download the original tarballs, and this
is enough of a corner case that I think we can perhaps not worry too
much about it for the time being.
Also, at Steve Langasek's suggestion, I pushed a further change that
requires an -f/--force option to discard Ubuntu changes. This matches
the current (archive admin only) sync-source.py script, and is because
otherwise it's too easy for accidents to happen.
Benjamin Drung (bdrung) wrote : | # |
2) Thanks for filing the bug. Can you update the documentation and warn the user if they want to change the author?
3) It would be nice if you could provide test cases. This will give you bonus points. Stefano and I can help you putting them into our test framework.
4) Downloading the original tarballs makes no sense. It would be nice if LP would provide the hash sums. Until then I can live with the current behavior.
Stefano Rivera (stefanor) wrote : | # |
Benjamin: I think test cases would be reasonable for non-lp-syncpackage, but not much more than that.
You don't have to download original tarballs, the .dsc files can give you the hash sums. ubuntutools.archive knows how to do most of this. That's probably out of scope for this merge proposal, though (assuming lp will reject a sync where fakesyncing is required)
- 1130. By Colin Watson
-
validate that the provided Debian version exists
- 1131. By Colin Watson
-
document restriction of -n and -e to --no-lp mode
Colin Watson (cjwatson) wrote : | # |
On Tue, Aug 16, 2011 at 08:06:22PM -0000, Benjamin Drung wrote:
> 2) Thanks for filing the bug. Can you update the documentation and warn the user if they want to change the author?
My branch already disallows using --uploader-name or --uploader-email
without --no-lp. I've updated the manual page now to match.
> 3) It would be nice if you could provide test cases. This will give you bonus points. Stefano and I can help you putting them into our test framework.
While I agree with the sentiment, I have no idea how you would go about
testing this without a mock version of Launchpad where you could control
the available test data, or at least perhaps a mock version of
launchpadlib. There seem to be no lpapicache tests in ubuntu-dev-tools
right now.
> 4) Downloading the original tarballs makes no sense. It would be nice if LP would provide the hash sums. Until then I can live with the current behavior.
I'm working on rearranging the code to make better use of
ubuntutools.archive facilities as Stefano suggested, at which point this
should be straightforward; I wasn't really aware of that module and I
definitely have some duplicated code here anyway. This will probably
take me until tomorrow.
- 1132. By Colin Watson
-
make it possible to quieten download progress information, particularly useful if downloading only the small .dsc files
- 1133. By Colin Watson
-
make better use of ubuntutools.
archive, allowing us to detect when fakesyncs are required in LP mode
Colin Watson (cjwatson) wrote : | # |
I believe I've got fakesync detection in LP mode working now.
$ ./syncpackage -l staging -f nautilus-
syncpackage: Source nautilus-
syncpackage: Error: The checksums of the Debian and Ubuntu packages mismatch. A fake sync is required.
Stefano Rivera (stefanor) wrote : | # |
src_pkg.lp_spph is a property, not a method (I'm coming to think that those @properties may have been poor API design :) )
- 1134. By Colin Watson
-
DebianSourcePac
kage.lp_ spph is annoyingly overloaded; just do the check directly
Colin Watson (cjwatson) wrote : | # |
On Wed, Aug 17, 2011 at 08:10:24AM -0000, Stefano Rivera wrote:
> src_pkg.lp_spph is a property, not a method (I'm coming to think that those @properties may have been poor API design :) )
Good point. It's annoyingly overloaded anyway, as I really just want to
specifically ask LP rather than anything else, so I've changed it to
just call getPublishedSources directly again.
- 1135. By Colin Watson
-
use version.
full_version rather than str(version) - 1136. By Colin Watson
-
refer to syncpackage from requestsync(1) for users with upload permission
- 1137. By Colin Watson
-
add note on requestsync stderr about syncpackage
Stefano Rivera (stefanor) : | # |
Iain Lane (laney) : | # |
Benjamin Drung (bdrung) wrote : | # |
When you detect that a fakesync is needed, can you either tell the user to use syncpackage with --no-lp or just do the fakesync and tell the user how to proceed?
Colin Watson (cjwatson) wrote : | # |
For now, I've made an adjustment to mention --no-lp in the error
message.
- 1138. By Colin Watson
-
fake syncs require --no-lp
Benjamin Drung (bdrung) wrote : | # |
Should we add "source" to the syncpackage description? -> "copy source packages from Debian to Ubuntu"
The copy function could be refactored. pylint says:
W:313:copy: Redefining name 'debian' from outer scope (line 23)
C:312:copy: Missing docstring
R:312:copy: Too many local variables (24/15)
W:312:copy: Unused argument 'debian_dist'
W:325:copy: Unused variable 'debian_spph'
R:312:copy: Too many branches (13/12)
I don't like the "if not quiet: Logger.
There are too many spaces in "getUbuntuSrcPk
Besides these small this it looks ready.
- 1139. By Colin Watson
-
avoid shadowing global "debian" name
- 1140. By Colin Watson
-
drop unused argument
- 1141. By Colin Watson
-
drop unused variable
- 1142. By Colin Watson
-
factor out dsc comparison into a method on ubuntutools.
archive. Dsc - 1143. By Colin Watson
-
docstring for copy()
- 1144. By Colin Watson
-
tweak to manual page suggested by bdrung
- 1145. By Colin Watson
-
drop quiet download stuff, not worth an API debate
- 1146. By Colin Watson
-
style
Colin Watson (cjwatson) wrote : | # |
On Wed, Aug 17, 2011 at 04:59:23PM -0000, Benjamin Drung wrote:
> Should we add "source" to the syncpackage description? -> "copy source
> packages from Debian to Ubuntu"
Done.
> The copy function could be refactored. pylint says:
> W:313:copy: Redefining name 'debian' from outer scope (line 23)
> C:312:copy: Missing docstring
> R:312:copy: Too many local variables (24/15)
> W:312:copy: Unused argument 'debian_dist'
> W:325:copy: Unused variable 'debian_spph'
> R:312:copy: Too many branches (13/12)
Done, mainly by moving the .dsc comparison out to a method on the Dsc
class which was probably a good idea anyway. (Though note that pylint
still has a bunch of output for stuff that was there before my changes.)
> I don't like the "if not quiet: Logger.
> should be set in the Logger instead.
I've just dropped the quiet download stuff. It's not really worth it.
> There are too many spaces in "getUbuntuSrcPk
> 'Release'):" it should be "getUbuntuSrcPk
> pocket='Release'):"
Fixed, but note that the extra spaces weren't my usual style - I only
did it that way because I found other similar code in ubuntu-dev-tools
that was written that way! (I think I was looking at
ubuntutools.
apply a consistent style across existing code in the whole project - it
really helps other developers figure out how they should be writing code
for submission.
Thanks,
--
Colin Watson [<email address hidden>]
Benjamin Drung (bdrung) wrote : | # |
Patches for making ubuntu-dev-tools code more pylint compliant/more readable are welcome. :)
The scripts in ubuntu-dev-tools didn't had consistent styles. We tried to make the style consistent by using PEP-8, but some places probably needs more love. I fixed the spacings in ubuntutools.
Thanks for your work. I merged the branch. I still love to see test cases for the new (and old) syncpackage code.
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2011-08-16 09:19:15 +0000 |
3 | +++ debian/changelog 2011-08-18 14:13:55 +0000 |
4 | @@ -1,3 +1,11 @@ |
5 | +ubuntu-dev-tools (0.129) UNRELEASED; urgency=low |
6 | + |
7 | + * syncpackage: Convert to new LP API, with --no-lp available for the old |
8 | + style of operation. |
9 | + * syncpackage: Require -f/--force option to overwrite Ubuntu changes. |
10 | + |
11 | + -- Colin Watson <cjwatson@ubuntu.com> Tue, 16 Aug 2011 16:40:22 +0100 |
12 | + |
13 | ubuntu-dev-tools (0.128) unstable; urgency=low |
14 | |
15 | [ Stefano Rivera ] |
16 | |
17 | === modified file 'doc/requestsync.1' |
18 | --- doc/requestsync.1 2011-02-24 14:30:45 +0000 |
19 | +++ doc/requestsync.1 2011-08-18 14:13:55 +0000 |
20 | @@ -32,6 +32,11 @@ |
21 | answer the question about upload permissions honestly to determine if a team |
22 | with approval rights is to be subscribed to the bug. |
23 | |
24 | +If you have permission to upload the package directly, then you may prefer |
25 | +to use \fBsyncpackage\fR instead to copy the package using the Launchpad |
26 | +API. At some future point, \fBrequestsync\fR will be changed to do this |
27 | +automatically. |
28 | + |
29 | .PP |
30 | \fBrequestsync\fR uses launchpadlib authentication to file its requests. |
31 | |
32 | |
33 | === modified file 'doc/syncpackage.1' |
34 | --- doc/syncpackage.1 2010-12-31 10:37:52 +0000 |
35 | +++ doc/syncpackage.1 2011-08-18 14:13:55 +0000 |
36 | @@ -1,12 +1,12 @@ |
37 | .TH SYNCPACKAGE "1" "June 2010" "ubuntu-dev-tools" |
38 | .SH NAME |
39 | -syncpackage \- helper to prepare .changes file to upload synced packages |
40 | +syncpackage \- copy source packages from Debian to Ubuntu |
41 | .SH SYNOPSIS |
42 | .B syncpackage |
43 | [\fIoptions\fR] \fI<.dsc URL/path or package name>\fR |
44 | .SH DESCRIPTION |
45 | -\fBsyncpackage\fR generates a changes file to be directly uploaded to Ubuntu |
46 | -primary archive or PPA starting from a pristine Debian package. |
47 | +\fBsyncpackage\fR causes a source package to be copied from Debian to |
48 | +Ubuntu. |
49 | .PP |
50 | \fBsyncpackage\fR allows you to upload files with the same checksums of the |
51 | Debian ones, as the common script used by Ubuntu archive administrators does, |
52 | @@ -15,14 +15,15 @@ |
53 | \fBsyncpackage\fR will detect source tarballs with mismatching checksums |
54 | and will automatically create fake syncs instead. |
55 | .SH WARNING |
56 | -The use of \fBsyncpackage\fR is discouraged by the Ubuntu Archive |
57 | -Administrators, as it introduces an unnecessary window for error. |
58 | -In future launchpad will offer the ability to directly perform sync |
59 | -requests, without a developer having to do an upload. |
60 | -Until then, it's advised to use \fBsyncpackage\fR with caution, and |
61 | -request syncs via bugs with |
62 | -.BR requestsync (1) |
63 | -where possible. |
64 | +The use of \fBsyncpackage \-\-no\-lp\fR, which generates a changes file to |
65 | +be directly uploaded to the Ubuntu primary archive or a PPA, is discouraged |
66 | +by the Ubuntu Archive Administrators, as it introduces an unnecessary window |
67 | +for error. |
68 | +This only exists for backward compatibility, for unusual corner cases, and |
69 | +for uploads to archives other than the Ubuntu primary archive. |
70 | +Omitting this option will cause Launchpad to perform the sync request |
71 | +directly, which is the preferred method for uploads to the Ubuntu primary |
72 | +archive. |
73 | .SH OPTIONS |
74 | .TP |
75 | \fB\-h\fR, \fB\-\-help\fR |
76 | @@ -43,13 +44,22 @@ |
77 | \fB\-v\fR, \fB\-\-verbose\fR |
78 | Display more progress information. |
79 | .TP |
80 | +.B \-\-no\-lp |
81 | +Construct sync locally rather than letting Launchpad copy the package |
82 | +directly (not recommended). |
83 | +.TP |
84 | +\fB\-l\fI INSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR |
85 | +Launchpad instance to connect to (default: production). |
86 | +.TP |
87 | \fB\-n\fI UPLOADER_NAME\fR, \fB\-\-uploader\-name\fR=\fIUPLOADER_NAME\fR |
88 | Use UPLOADER_NAME as the name of the maintainer for this upload instead |
89 | of evaluating DEBFULLNAME and UBUMAIL. |
90 | +This option may only be used in \fB\-\-no\-lp\fR mode. |
91 | .TP |
92 | \fB\-e\fI UPLOADER_EMAIL\fR, \fB\-\-uploader\-email\fR=\fIUPLOADER_EMAIL\fR |
93 | Use UPLOADER_EMAIL as the email address of the maintainer for this |
94 | upload instead of evaluating DEBEMAIL and UBUMAIL. |
95 | +This option may only be used in \fB\-\-no\-lp\fR mode. |
96 | .TP |
97 | \fB\-k\fI KEYID\fR, \fB\-\-key\fR=\fIKEYID\fR |
98 | Specify the key ID to be used for signing. |
99 | @@ -60,6 +70,9 @@ |
100 | \fB\-b\fI BUG\fR, \fB\-\-bug\fR=\fIBUG\fR |
101 | Mark a Launchpad bug as being fixed by this upload. |
102 | .TP |
103 | +\fB\-f\fR, \fB\-\-force\fR |
104 | +Force sync over the top of Ubuntu changes. |
105 | +.TP |
106 | .B \-d \fIDEBIAN_MIRROR\fR, \fB\-\-debian\-mirror\fR=\fIDEBIAN_MIRROR\fR |
107 | Use the specified mirror. |
108 | Should be in the form \fBhttp://ftp.debian.org/debian\fR. |
109 | @@ -75,6 +88,9 @@ |
110 | .B \-\-no\-conf |
111 | Do not read any configuration files, or configuration from environment |
112 | variables. |
113 | +.TP |
114 | +.B \-\-simulate |
115 | +Show what would be done, but don't actually do it. |
116 | .SH ENVIRONMENT |
117 | .TP |
118 | .BR DEBFULLNAME ", " DEBEMAIL ", " UBUMAIL |
119 | |
120 | === modified file 'requestsync' |
121 | --- requestsync 2011-06-25 15:53:44 +0000 |
122 | +++ requestsync 2011-08-18 14:13:55 +0000 |
123 | @@ -239,6 +239,10 @@ |
124 | if not sponsorship: |
125 | sponsorship = needSponsorship(srcpkg, ubuntu_component, release) |
126 | |
127 | + if not sponsorship and not ffe: |
128 | + print >> sys.stderr, ('Consider using syncpackage(1) for syncs that ' |
129 | + 'do not require feature freeze exceptions.') |
130 | + |
131 | # Check for existing package reports |
132 | if not newsource: |
133 | checkExistingReports(srcpkg) |
134 | |
135 | === modified file 'syncpackage' |
136 | --- syncpackage 2011-05-24 18:22:37 +0000 |
137 | +++ syncpackage 2011-08-18 14:13:55 +0000 |
138 | @@ -29,6 +29,10 @@ |
139 | |
140 | from devscripts.logger import Logger |
141 | |
142 | +from distro_info import DebianDistroInfo |
143 | + |
144 | +from lazr.restfulclient.errors import HTTPError |
145 | + |
146 | from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage, |
147 | DownloadError) |
148 | from ubuntutools.config import UDTConfig, ubu_email |
149 | @@ -36,7 +40,9 @@ |
150 | as requestsync_mail_getDebianSrcPkg) |
151 | from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg |
152 | from ubuntutools.lp import udtexceptions |
153 | -from ubuntutools.lp.lpapicache import Launchpad |
154 | +from ubuntutools.lp.lpapicache import Distribution, Launchpad |
155 | +from ubuntutools.misc import split_release_pocket |
156 | +from ubuntutools.question import YesNoQuestion |
157 | from ubuntutools import subprocess |
158 | |
159 | |
160 | @@ -110,7 +116,7 @@ |
161 | return "\n".join(changes + [""]) |
162 | |
163 | def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror, |
164 | - keyid=None): |
165 | + keyid=None, simulate=False, force=False): |
166 | uploader = name + " <" + email + ">" |
167 | |
168 | src_pkg.pull_dsc() |
169 | @@ -136,9 +142,15 @@ |
170 | |
171 | cur_ver = ubuntu_ver.get_related_debian_version() |
172 | if ubuntu_ver.is_modified_in_ubuntu(): |
173 | + if not force: |
174 | + Logger.error('--force is required to discard Ubuntu changes.') |
175 | + sys.exit(1) |
176 | + |
177 | Logger.warn('Overwriting modified Ubuntu version %s, ' |
178 | 'setting current version to %s', |
179 | ubuntu_ver.full_version, cur_ver.full_version) |
180 | + if simulate: |
181 | + return |
182 | |
183 | try: |
184 | src_pkg.pull() |
185 | @@ -248,8 +260,13 @@ |
186 | """Download the specified source package. |
187 | dist, version, component, mirror can all be None. |
188 | """ |
189 | + if mirror is None: |
190 | + mirrors = [] |
191 | + else: |
192 | + mirrors = [mirror] |
193 | + |
194 | if package.endswith('.dsc'): |
195 | - return DebianSourcePackage(dscfile=package, mirrors=[mirror]) |
196 | + return DebianSourcePackage(dscfile=package, mirrors=mirrors) |
197 | |
198 | if dist is None: |
199 | dist = "unstable" |
200 | @@ -290,7 +307,80 @@ |
201 | assert component in ('main', 'contrib', 'non-free') |
202 | |
203 | return DebianSourcePackage(package, version.full_version, component, |
204 | - mirrors=[mirror]) |
205 | + mirrors=mirrors) |
206 | + |
207 | +def copy(src_pkg, release, simulate=False, force=False): |
208 | + """Copy a source package from Debian to Ubuntu using the Launchpad API.""" |
209 | + ubuntu = Distribution('ubuntu') |
210 | + debian_archive = Distribution('debian').getArchive() |
211 | + ubuntu_archive = ubuntu.getArchive() |
212 | + if release is None: |
213 | + ubuntu_series = ubuntu.getDevelopmentSeries().name |
214 | + ubuntu_pocket = 'Release' |
215 | + else: |
216 | + ubuntu_series, ubuntu_pocket = split_release_pocket(release) |
217 | + |
218 | + # Ensure that the provided Debian version actually exists. |
219 | + try: |
220 | + debian_archive.getPublishedSources( |
221 | + source_name=src_pkg.source, |
222 | + version=src_pkg.version.full_version, |
223 | + exact_match=True)[0] |
224 | + except IndexError: |
225 | + Logger.error('Debian version %s does not exist!', src_pkg.version) |
226 | + sys.exit(1) |
227 | + |
228 | + try: |
229 | + ubuntu_spph = getUbuntuSrcPkg(src_pkg.source, |
230 | + ubuntu_series, ubuntu_pocket) |
231 | + ubuntu_pkg = UbuntuSourcePackage(src_pkg.source, |
232 | + ubuntu_spph.getVersion(), |
233 | + ubuntu_spph.getComponent(), |
234 | + mirrors=[]) |
235 | + |
236 | + Logger.normal('Source %s -> %s/%s: current version %s, new version %s', |
237 | + src_pkg.source, ubuntu_series, ubuntu_pocket, |
238 | + ubuntu_pkg.version, src_pkg.version) |
239 | + |
240 | + ubuntu_version = Version(ubuntu_pkg.version.full_version) |
241 | + if not force and ubuntu_version.is_modified_in_ubuntu(): |
242 | + Logger.error('--force is required to discard Ubuntu changes.') |
243 | + sys.exit(1) |
244 | + |
245 | + # Check whether a fakesync would be required. |
246 | + src_pkg.pull_dsc() |
247 | + ubuntu_pkg.pull_dsc() |
248 | + if not src_pkg.dsc.compare_dsc(ubuntu_pkg.dsc): |
249 | + Logger.error('The checksums of the Debian and Ubuntu packages ' |
250 | + 'mismatch. A fake sync using --no-lp is required.') |
251 | + sys.exit(1) |
252 | + except udtexceptions.PackageNotFoundException: |
253 | + Logger.normal('Source %s -> %s/%s: not in Ubuntu, new version %s', |
254 | + src_pkg.source, ubuntu_series, ubuntu_pocket, |
255 | + src_pkg.version) |
256 | + if simulate: |
257 | + return |
258 | + |
259 | + answer = YesNoQuestion().ask("Sync this package", "no") |
260 | + if answer != "yes": |
261 | + return |
262 | + |
263 | + try: |
264 | + ubuntu_archive.copyPackage( |
265 | + source_name=src_pkg.source, |
266 | + version=src_pkg.version.full_version, |
267 | + from_archive=debian_archive, |
268 | + to_series=ubuntu_series, |
269 | + to_pocket=ubuntu_pocket, |
270 | + include_binaries=False) |
271 | + except HTTPError, error: |
272 | + Logger.error("HTTP Error %s: %s" % |
273 | + (error.response.status, error.response.reason)) |
274 | + Logger.error(error.content) |
275 | + sys.exit(1) |
276 | + |
277 | + Logger.normal('Request succeeded; you should get an e-mail once it is ' |
278 | + 'processed.') |
279 | |
280 | def main(): |
281 | usage = "%prog [options] <.dsc URL/path or package name>" |
282 | @@ -312,6 +402,15 @@ |
283 | parser.add_option("-v", "--verbose", |
284 | dest="verbose", action="store_true", default=False, |
285 | help="Display more progress information.") |
286 | + parser.add_option("--no-lp", |
287 | + dest="lp", action="store_false", default=True, |
288 | + help="Construct sync locally rather than letting " |
289 | + "Launchpad copy the package directly (not " |
290 | + "recommended).") |
291 | + parser.add_option('-l', '--lpinstance', metavar='INSTANCE', |
292 | + dest='lpinstance', default=None, |
293 | + help='Launchpad instance to connect to ' |
294 | + '(default: production).') |
295 | parser.add_option("-n", "--uploader-name", |
296 | dest="uploader_name", default=None, |
297 | help="Use UPLOADER_NAME as the name of the maintainer " |
298 | @@ -330,6 +429,9 @@ |
299 | dest="bugs", action="append", default=list(), |
300 | help="Mark Launchpad bug BUG as being fixed by this " |
301 | "upload.") |
302 | + parser.add_option("-f", "--force", |
303 | + dest="force", action="store_true", default=False, |
304 | + help="Force sync over the top of Ubuntu changes.") |
305 | parser.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR', |
306 | dest='debian_mirror', |
307 | help='Preferred Debian mirror ' |
308 | @@ -343,6 +445,10 @@ |
309 | parser.add_option('--no-conf', |
310 | dest='no_conf', default=False, action='store_true', |
311 | help="Don't read config files or environment variables.") |
312 | + parser.add_option('--simulate', |
313 | + dest='simulate', default=False, action='store_true', |
314 | + help="Show what would be done, but don't actually do " |
315 | + "it.") |
316 | |
317 | (options, args) = parser.parse_args() |
318 | |
319 | @@ -362,6 +468,14 @@ |
320 | 'It should be one of main, contrib, or non-free.' |
321 | % options.component) |
322 | |
323 | + if options.lp and options.uploader_name: |
324 | + parser.error('Uploader name can only be overridden using --no-lp.') |
325 | + if options.lp and options.uploader_email: |
326 | + parser.error('Uploader email address can only be overridden using ' |
327 | + '--no-lp.') |
328 | + # --key, --dont-sign, --debian-mirror, and --ubuntu-mirror are just |
329 | + # ignored with options.lp, and do not require warnings. |
330 | + |
331 | Logger.verbose = options.verbose |
332 | config = UDTConfig(options.no_conf) |
333 | if options.debian_mirror is None: |
334 | @@ -373,19 +487,37 @@ |
335 | if options.uploader_email is None: |
336 | options.uploader_email = ubu_email(export=False)[1] |
337 | |
338 | - Launchpad.login_anonymously() |
339 | - if options.release is None: |
340 | - options.release = Launchpad.distributions["ubuntu"].current_series.name |
341 | - |
342 | - os.environ['DEB_VENDOR'] = 'Ubuntu' |
343 | - |
344 | - src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion, |
345 | - options.component, options.release, |
346 | - options.debian_mirror) |
347 | - |
348 | - sync_dsc(src_pkg, options.dist, options.release, options.uploader_name, |
349 | - options.uploader_email, options.bugs, options.ubuntu_mirror, |
350 | - options.keyid) |
351 | + if options.lp: |
352 | + if args[0].endswith('.dsc'): |
353 | + parser.error('.dsc files can only be synced using --no-lp.') |
354 | + |
355 | + if options.lpinstance is None: |
356 | + options.lpinstance = config.get_value('LPINSTANCE') |
357 | + |
358 | + try: |
359 | + Launchpad.login(service=options.lpinstance, api_version='devel') |
360 | + except IOError: |
361 | + sys.exit(1) |
362 | + |
363 | + src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion, |
364 | + options.component, options.release, None) |
365 | + |
366 | + copy(src_pkg, options.release, options.simulate, options.force) |
367 | + else: |
368 | + Launchpad.login_anonymously() |
369 | + if options.release is None: |
370 | + ubuntu = Launchpad.distributions["ubuntu"] |
371 | + options.release = ubuntu.current_series.name |
372 | + |
373 | + os.environ['DEB_VENDOR'] = 'Ubuntu' |
374 | + |
375 | + src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion, |
376 | + options.component, options.release, |
377 | + options.debian_mirror) |
378 | + |
379 | + sync_dsc(src_pkg, options.dist, options.release, options.uploader_name, |
380 | + options.uploader_email, options.bugs, options.ubuntu_mirror, |
381 | + options.keyid, options.simulate, options.force) |
382 | |
383 | if __name__ == "__main__": |
384 | main() |
385 | |
386 | === modified file 'ubuntutools/archive.py' |
387 | --- ubuntutools/archive.py 2011-08-15 23:17:25 +0000 |
388 | +++ ubuntutools/archive.py 2011-08-18 14:13:55 +0000 |
389 | @@ -95,6 +95,30 @@ |
390 | return hash_func.hexdigest() == digest |
391 | return False |
392 | |
393 | + def compare_dsc(self, other): |
394 | + """Check whether any files in these two dscs that have the same name |
395 | + also have the same checksum.""" |
396 | + for field, key in (('Checksums-Sha256', 'sha256'), |
397 | + ('Checksums-Sha1', 'sha1'), |
398 | + ('Files', 'md5sum')): |
399 | + if field not in self or field not in other: |
400 | + continue |
401 | + our_checksums = \ |
402 | + dict((entry['name'], (int(entry['size']), entry[key])) |
403 | + for entry in self[field]) |
404 | + their_checksums = \ |
405 | + dict((entry['name'], (int(entry['size']), entry[key])) |
406 | + for entry in other[field]) |
407 | + for name, (size, checksum) in our_checksums.iteritems(): |
408 | + if name not in their_checksums: |
409 | + # file only in one dsc |
410 | + continue |
411 | + if (size != their_checksums[name][0] or |
412 | + checksum != their_checksums[name][1]): |
413 | + return False |
414 | + return True # one checksum is good enough |
415 | + return True |
416 | + |
417 | |
418 | class SourcePackage(object): |
419 | """Base class for source package downloading. |
420 | |
421 | === modified file 'ubuntutools/lp/lpapicache.py' |
422 | --- ubuntutools/lp/lpapicache.py 2011-02-28 22:30:54 +0000 |
423 | +++ ubuntutools/lp/lpapicache.py 2011-08-18 14:13:55 +0000 |
424 | @@ -53,7 +53,7 @@ |
425 | class _Launchpad(object): |
426 | '''Singleton for LP API access.''' |
427 | |
428 | - def login(self, service=service): |
429 | + def login(self, service=service, api_version=api_version): |
430 | '''Enforce a non-anonymous login.''' |
431 | if not self.logged_in: |
432 | try: |
433 | @@ -332,6 +332,25 @@ |
434 | |
435 | return self._srcpkgs[(name, series.name, pocket)] |
436 | |
437 | + def copyPackage(self, source_name, version, from_archive, to_pocket, |
438 | + to_series = None, include_binaries = False): |
439 | + '''Copy a single named source into this archive. |
440 | + |
441 | + Asynchronously copy a specific version of a named source to the |
442 | + destination archive if necessary. Calls to this method will return |
443 | + immediately if the copy passes basic security checks and the copy |
444 | + will happen sometime later with full checking. |
445 | + ''' |
446 | + |
447 | + self._lpobject.copyPackage( |
448 | + source_name=source_name, |
449 | + version=version, |
450 | + from_archive=from_archive._lpobject, |
451 | + to_pocket=to_pocket, |
452 | + to_series=to_series, |
453 | + include_binaries=include_binaries |
454 | + ) |
455 | + |
456 | |
457 | class SourcePackagePublishingHistory(BaseWrapper): |
458 | ''' |
459 | |
460 | === modified file 'ubuntutools/requestsync/lp.py' |
461 | --- ubuntutools/requestsync/lp.py 2011-06-25 15:53:44 +0000 |
462 | +++ ubuntutools/requestsync/lp.py 2011-08-18 14:13:55 +0000 |
463 | @@ -34,11 +34,11 @@ |
464 | |
465 | return debian_archive.getSourcePackage(name, release) |
466 | |
467 | -def getUbuntuSrcPkg(name, release): |
468 | +def getUbuntuSrcPkg(name, release, pocket='Release'): |
469 | ubuntu = Distribution('ubuntu') |
470 | ubuntu_archive = ubuntu.getArchive() |
471 | |
472 | - return ubuntu_archive.getSourcePackage(name, release) |
473 | + return ubuntu_archive.getSourcePackage(name, release, pocket) |
474 | |
475 | def needSponsorship(name, component, release): |
476 | ''' |
Woo!
Warts:
* laney@raleigh> syncpackage -d experimental mono
syncpackage: Source mono -> oneiric/Release: current version 2.10.3-1, new version 2.6.7-5
(should find 2.10.4-2; worked before, works now with -V)
* Typo in the manpage: "The use of syncpackage --no--lp"
* Perhaps copy() should move to ubuntutools; lp_object breaks encapsulation. It could then be used by ack-sync (if the interface is suitable for sponsoring use) and requestsync --lp.