Merge lp:~rainct/apt-zeroconf/cheetah into lp:apt-zeroconf
- cheetah
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~rainct/apt-zeroconf/cheetah |
Merge into: | lp:apt-zeroconf |
Diff against target: |
1002 lines (+313/-327) 19 files modified
HACKING (+2/-1) MANIFEST (+1/-2) apt-zeroconf (+9/-7) aptzeroconf/exceptions.py (+32/-0) aptzeroconf/http.py (+17/-7) aptzeroconf/parse.py (+76/-120) azc_daemon/__init__.py (+14/-1) debian/apt-zeroconf.postinst (+7/-12) debian/changelog (+21/-0) debian/control (+28/-14) debian/init (+23/-29) debian/rules (+2/-6) debian/templates (+4/-0) setup.py (+10/-5) support/apt-zeroconf.1 (+65/-0) support/apt-zeroconf.xml (+0/-115) support/azc_rule (+1/-1) support/build.sh (+0/-5) test/test_general.py (+1/-2) |
To merge this branch: | bzr merge lp:~rainct/apt-zeroconf/cheetah |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Apt Zeroconf Team | Pending | ||
Review via email: mp+18348@code.launchpad.net |
Commit message
Description of the change
- 142. By Siegfried Gevatter
-
Catch exception when socket is already in use and signalize this
condition with a special code. - 143. By Siegfried Gevatter
-
apt-zeroconf.1: clarify the use of --daemon.
- 144. By Siegfried Gevatter
-
Fix debian/init.
The previous version was good enough for the package to work, but
"sudo service apt-zeroconf start/stop/restart" didn't work. - 145. By Siegfried Gevatter
-
Some more changes here and there to make pep-8.py happy.
Change debian/init to always return 0 on stop, else dpkg-reconfigure gets mad. - 146. By Siegfried Gevatter
-
azc_daemon/
__init_ _.py: close all file descriptors after forking Now that we don't use start-stop-daemon with the --background
workaround option anymore, dpkg-reconfigure was hanging again.
*Finally* I discovered the problem as being in _daemonize() :/. - 147. By Siegfried Gevatter
-
Update debian/changelog.
Unmerged revisions
- 147. By Siegfried Gevatter
-
Update debian/changelog.
- 146. By Siegfried Gevatter
-
azc_daemon/
__init_ _.py: close all file descriptors after forking Now that we don't use start-stop-daemon with the --background
workaround option anymore, dpkg-reconfigure was hanging again.
*Finally* I discovered the problem as being in _daemonize() :/. - 145. By Siegfried Gevatter
-
Some more changes here and there to make pep-8.py happy.
Change debian/init to always return 0 on stop, else dpkg-reconfigure gets mad. - 144. By Siegfried Gevatter
-
Fix debian/init.
The previous version was good enough for the package to work, but
"sudo service apt-zeroconf start/stop/restart" didn't work. - 143. By Siegfried Gevatter
-
apt-zeroconf.1: clarify the use of --daemon.
- 142. By Siegfried Gevatter
-
Catch exception when socket is already in use and signalize this
condition with a special code. - 141. By Siegfried Gevatter
-
Fix postinst, init file, etc. Installing the package works now!
- 140. By Siegfried Gevatter
-
Fix wrong path for HTML files when installed.
- 139. By Siegfried Gevatter
-
Remove now superfluous manpage generation code from setup.py.
- 138. By Siegfried Gevatter
-
Change python-central dependency to python-support.
Preview Diff
1 | === modified file 'HACKING' |
2 | --- HACKING 2009-08-09 01:45:52 +0000 |
3 | +++ HACKING 2010-02-01 20:58:13 +0000 |
4 | @@ -15,7 +15,8 @@ |
5 | ------- |
6 | |
7 | We use py.test for testing at the moment. |
8 | -You can get it by running "[sudo] easy_install -U py" |
9 | +You can get it by running "[sudo] easy_install -U py", or installing |
10 | +python-codespeak-lib on Debian systems. |
11 | |
12 | - For every change, try to create a new test. |
13 | - Run all tests: 'py.test' in main project dir. |
14 | |
15 | === modified file 'MANIFEST' |
16 | --- MANIFEST 2009-07-14 19:40:59 +0000 |
17 | +++ MANIFEST 2010-02-01 20:58:13 +0000 |
18 | @@ -21,10 +21,9 @@ |
19 | pages/list.xsl |
20 | pages/logo.png |
21 | pages/stats.html |
22 | -support/apt-zeroconf.1.gz |
23 | +support/apt-zeroconf.1 |
24 | support/apt-zeroconf.apt.conf |
25 | support/apt-zeroconf.conf |
26 | -support/apt-zeroconf.xml |
27 | support/azc_rule |
28 | support/build.sh |
29 | support/make_docs.sh |
30 | |
31 | === modified file 'apt-zeroconf' |
32 | --- apt-zeroconf 2009-07-25 21:59:12 +0000 |
33 | +++ apt-zeroconf 2010-02-01 20:58:13 +0000 |
34 | @@ -1,4 +1,4 @@ |
35 | -#!/usr/bin/python |
36 | +#!/usr/bin/python2.6 |
37 | # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil -*- |
38 | |
39 | # This file is part of apt-zeroconf. |
40 | @@ -25,10 +25,10 @@ |
41 | import optparse |
42 | import sys |
43 | import os |
44 | -#from pwd import getpwnam |
45 | + |
46 | +sys.path.append('/usr/share/pyshared/') |
47 | from aptzeroconf import main |
48 | - |
49 | -SCRIPTPATH = os.path.dirname(os.path.abspath(__file__)) |
50 | +from aptzeroconf.exceptions import AlreadyRunningError |
51 | |
52 | if __name__ == "__main__": |
53 | parser = optparse.OptionParser() |
54 | @@ -50,10 +50,8 @@ |
55 | class azcDaemon(Daemon): |
56 | |
57 | def run(self): |
58 | - os.chdir(SCRIPTPATH) |
59 | main(options) |
60 | |
61 | - |
62 | if os.getuid() != 0: |
63 | print ("** Logging has been disabled. **" |
64 | "You need root privileges to start apt-zeroconf as daemon." |
65 | @@ -97,4 +95,8 @@ |
66 | print "--background has been deprecated, use --daemon." |
67 | sys.exit(2) |
68 | |
69 | -main(options) |
70 | +try: |
71 | + main(options) |
72 | +except AlreadyRunningError: |
73 | + print "Another instance of Apt-ZeroConf is already running." |
74 | + sys.exit(42) |
75 | |
76 | === added file 'aptzeroconf/exceptions.py' |
77 | --- aptzeroconf/exceptions.py 1970-01-01 00:00:00 +0000 |
78 | +++ aptzeroconf/exceptions.py 2010-02-01 20:58:13 +0000 |
79 | @@ -0,0 +1,32 @@ |
80 | +# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil -*- |
81 | +# |
82 | +# Copyright (C) 2010 - Siegfried Gevatter <rainct@ubuntu.com> |
83 | +# |
84 | +# Apt-zeroconf is free software; you can redistribute it and/or modify |
85 | +# it under the terms of the GNU General Public License as published by |
86 | +# the Free Software Foundation; either version 2 of the License, or |
87 | +# (at your option) any later version. |
88 | +# |
89 | +# Apt-zeroconf is distributed in the hope that it will be useful, |
90 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
92 | +# GNU General Public License for more details. |
93 | +# |
94 | +# You should have received a copy of the GNU General Public License |
95 | +# along with apt-zeroconf; if not, write to the Free Software |
96 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
97 | + |
98 | + |
99 | +class AptZeroConfException(Exception): |
100 | + """ |
101 | + Base class for exceptions from AptZeroConf. |
102 | + """ |
103 | + pass |
104 | + |
105 | + |
106 | +class AlreadyRunningError(AptZeroConfException): |
107 | + """ |
108 | + Exception raised if another instance or a conflicting service is |
109 | + already running. |
110 | + """ |
111 | + pass |
112 | |
113 | === modified file 'aptzeroconf/http.py' |
114 | --- aptzeroconf/http.py 2009-09-12 02:04:35 +0000 |
115 | +++ aptzeroconf/http.py 2010-02-01 20:58:13 +0000 |
116 | @@ -25,9 +25,11 @@ |
117 | redirected, or page url. |
118 | |
119 | @requires: logging |
120 | +@requires: socket |
121 | @requires: SocketServer.[ThreadingTCPServer|BaseServer] |
122 | @requires: SimpleHTTPServer.SimpleHTTPRequestHandler |
123 | @requires: aptzeroconf.config.[config|cache] |
124 | +@requires: aptzeroconf.exceptions.AlreadyRunningError |
125 | @requires: socket |
126 | @requires: urllib2.HTTPError |
127 | """ |
128 | @@ -37,6 +39,7 @@ |
129 | from SocketServer import ThreadingTCPServer, BaseServer |
130 | from SimpleHTTPServer import SimpleHTTPRequestHandler |
131 | from aptzeroconf.config import config, cache |
132 | +from aptzeroconf.exceptions import AlreadyRunningError |
133 | |
134 | |
135 | class HttpServer(ThreadingTCPServer): |
136 | @@ -45,11 +48,18 @@ |
137 | """ |
138 | |
139 | def __init__(self): |
140 | - BaseServer.__init__(self, ('', config['http_port']), AZCHTTPHandler) |
141 | - self.socket = socket.socket(socket.AF_INET6, self.socket_type) |
142 | - self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
143 | - self.server_bind() |
144 | - self.server_activate() |
145 | + try: |
146 | + BaseServer.__init__(self, ('', config['http_port']), |
147 | + AZCHTTPHandler) |
148 | + self.socket = socket.socket(socket.AF_INET6, self.socket_type) |
149 | + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
150 | + self.server_bind() |
151 | + self.server_activate() |
152 | + except socket.error as error: |
153 | + if error.args and error.args[0] == 98: |
154 | + # Address already in use |
155 | + raise AlreadyRunningError |
156 | + raise |
157 | |
158 | |
159 | def trap_socketerror(method): |
160 | @@ -145,7 +155,7 @@ |
161 | @trap_socketerror |
162 | def do_GET(self): |
163 | self._do_GET() |
164 | - |
165 | + |
166 | def _do_GET(self): |
167 | """ |
168 | Respond to a GET request by proxy the url to preferably local content, |
169 | @@ -186,7 +196,7 @@ |
170 | if os.path.isfile("pages/" + filename): |
171 | page = "pages/" + filename |
172 | else: |
173 | - page = "/usr/share/pages/" + filename |
174 | + page = "/usr/share/apt-zeroconf/pages/" + filename |
175 | return open(page, "r") |
176 | |
177 | httpCode = 200 #: Default HTTP Error code set |
178 | |
179 | === modified file 'aptzeroconf/parse.py' |
180 | --- aptzeroconf/parse.py 2009-08-09 02:39:51 +0000 |
181 | +++ aptzeroconf/parse.py 2010-02-01 20:58:13 +0000 |
182 | @@ -21,116 +21,72 @@ |
183 | from xml.sax import parseString, ContentHandler |
184 | #from xml.sax.handler import feature_namespaces |
185 | from xml.sax._exceptions import SAXParseException |
186 | +from apt_pkg import VersionCompare |
187 | import logging |
188 | import re |
189 | |
190 | __version__ = float(0.3) |
191 | |
192 | V2, V3 = 0.2, 0.3 |
193 | -EPOCH_PATTERN = { |
194 | - V2 : re.compile(r'\_\d+\%3a'), |
195 | - V3 : re.compile(r'\_\d+\:') |
196 | -} |
197 | +EPOCH_PATTERN = re.compile(r'\_\d+\%3a') |
198 | + |
199 | |
200 | def normalize_whitespace(text): |
201 | """Remove excessive whitespace in spaces.""" |
202 | return ' '.join(text.split()) |
203 | |
204 | -def _is_equal(pkg, find, ver): |
205 | + |
206 | +def _is_equal(pkg, find): |
207 | """Are the packages equal disregarding the epoch?""" |
208 | - return EPOCH_PATTERN[ver].sub('_', pkg) == find or pkg == find |
209 | - |
210 | - |
211 | -class _PackageList(list): |
212 | - """ |
213 | - Found Package list container. |
214 | - """ |
215 | - |
216 | - def found(self, item): |
217 | - """ |
218 | - Callback to add a found package to contatiner |
219 | - |
220 | - @param item: Package Name |
221 | - @type item: basestring |
222 | - """ |
223 | - self.append(item) |
224 | - |
225 | - def __str__(self): |
226 | - """ |
227 | - String representaion of found package container. Displays the best |
228 | - package found in container if multiples were added. |
229 | - |
230 | - @return: Best or only package |
231 | - @rtype: basestring |
232 | - """ |
233 | - from apt_pkg import VersionCompare |
234 | - from urllib2 import quote |
235 | - if len(self) > 1: |
236 | - self.sort(cmp=VersionCompare) |
237 | - return quote(self[-1]) |
238 | - |
239 | - elif len(self) == 1: |
240 | - return quote(self[0]) |
241 | - |
242 | - else: |
243 | - return "" |
244 | - |
245 | + return EPOCH_PATTERN.sub('_', pkg) == find or pkg == find |
246 | + |
247 | + |
248 | +class Package(object): |
249 | + """Represents a single package.""" |
250 | + def __init__(self, name=''): |
251 | + self.name = name |
252 | def __repr__(self): |
253 | - return '<Package name="%s" count="%d">' % (str(self), len(self)) |
254 | - |
255 | - |
256 | -class _PackageFinder(ContentHandler): |
257 | + return '<Package name=' + self.name + '>' |
258 | + |
259 | + |
260 | +class _XMLDecoder(ContentHandler): |
261 | + """Decodes an xml package list, calling a callback for each package.""" |
262 | callback = None #: Callback function to be set when item found |
263 | - inPkgElemCnt = {} |
264 | |
265 | - def __init__(self, package): |
266 | + def __init__(self): |
267 | """ |
268 | Initialize sax content handler. |
269 | |
270 | @param search_name: Package to locate in search data. |
271 | @type search_name: basestring |
272 | """ |
273 | - self.packageSearch = normalize_whitespace(package) |
274 | - |
275 | - self.inPkgName = False #: Initialize the content flag to False |
276 | - self.inPkg = False #: Initialize the content flag to False |
277 | - self.list_version = '' #: Initialize the version value to None |
278 | + self.text = '' |
279 | + self.package = None |
280 | + self.list_version = '' |
281 | |
282 | def startElement(self, name, attrs): |
283 | """ |
284 | Check start element tags for packagelist or name. |
285 | |
286 | - @param name: element tag. |
287 | - @type name: basestring |
288 | - @param name: element tag attrs. |
289 | - @type name: basestring |
290 | + @param name: element tag |
291 | + @type name: basestring |
292 | + @param name: element attributes |
293 | + @type name: dict |
294 | """ |
295 | if name == 'packagelist': #: handle element by getting ver. attribute |
296 | self.list_version = normalize_whitespace(attrs.get('version', "")) |
297 | - |
298 | - if float(self.list_version) == __version__: |
299 | - |
300 | - if name == 'package': |
301 | - self.inPkg = True |
302 | - self.inPkgElemCnt = {'name': 0} |
303 | - |
304 | - elif name == 'name': #: handle element by set flag, reset value |
305 | - if self.inPkgElemCnt[name] > 1: |
306 | - raise SAXParseException |
307 | - |
308 | - self.inPkgName = True |
309 | - self.packageName = "" |
310 | - self.inPkgElemCnt[name] += 1 |
311 | + if name == 'package': |
312 | + self.package = Package() |
313 | + self.text = '' |
314 | |
315 | def characters(self, char): |
316 | """ |
317 | - Check characters for name value. |
318 | + Add character input to text buffer. |
319 | |
320 | @param char: text chunk |
321 | @type name: basestring |
322 | """ |
323 | - if self.inPkgName: |
324 | - self.packageName = self.packageName + char |
325 | + self.text += char |
326 | |
327 | def endElement(self, name): |
328 | """ |
329 | @@ -140,70 +96,72 @@ |
330 | @param name: element tag. |
331 | @type name: basestring |
332 | """ |
333 | - if float(self.list_version) == __version__: |
334 | - if name == 'package': |
335 | - self.inPkgName = False |
336 | - elif name == 'name': |
337 | - self.inPkgName = False |
338 | - self.packageName = normalize_whitespace(self.packageName) |
339 | - |
340 | - #{ Check search_name for match with packagename |
341 | - if _is_equal(self.packageName, self.packageSearch, V3): |
342 | - self.callback(self.packageName) |
343 | - |
344 | - |
345 | -def has_package(package, data): |
346 | + if name == 'package': |
347 | + self.callback(self.package) |
348 | + elif name == 'name': |
349 | + self.package.name = self.text |
350 | + |
351 | + |
352 | +def decode_list(data): |
353 | """ |
354 | - Locate package in data string. |
355 | - |
356 | - @param package: package name |
357 | - @type package: basestring |
358 | - @param data: xml package data |
359 | + @param data: xml/raw package data |
360 | @type data: basestring |
361 | - @return: PkgList object |
362 | - @rtype: object |
363 | + @return: list of Packages |
364 | + @rtype: list |
365 | """ |
366 | - pkglist = _PackageList() |
367 | if not data.startswith('<?xml'): |
368 | - for name in data.split(): |
369 | - if _is_equal(name, package, V2): |
370 | - pkglist.found(name) |
371 | - return pkglist |
372 | + data = data.split() |
373 | + if data[0] == str(V2): |
374 | + return [Package(name) for name in data[1:]] |
375 | |
376 | - handler = _PackageFinder(package) |
377 | - handler.callback = pkglist.found |
378 | + pkglist = [] |
379 | + handler = _XMLDecoder() |
380 | + handler.callback = pkglist.append |
381 | |
382 | try: |
383 | parseString(data, handler) |
384 | - |
385 | except SAXParseException: |
386 | #{ Non-conforming list |
387 | logging.warning( |
388 | '[PARSER] Parse Error, Ignoring: malformed package list.') |
389 | - return _PackageList() |
390 | - |
391 | + return [] |
392 | return pkglist |
393 | |
394 | |
395 | +def has_package(package, list): |
396 | + """ |
397 | + Locate package (disregarding the epoch) in package list. |
398 | + |
399 | + Returns the package name, including the epoch if there is one. |
400 | + |
401 | + @param package: package name |
402 | + @type package: basestring |
403 | + @param data: list of Packages |
404 | + @type data: list |
405 | + @return: package name |
406 | + @rtype: basestring |
407 | + """ |
408 | + results = [] |
409 | + for pkg in list: |
410 | + if _is_equal(pkg.name, package): |
411 | + results.append(pkg.name) |
412 | + |
413 | + results.sort(cmp=VersionCompare) |
414 | + if results: |
415 | + return results[-1] |
416 | + else: |
417 | + return '' |
418 | + |
419 | + |
420 | def store_packages(url, port): |
421 | """ |
422 | Fetch non-local AZC Cache service host cache listings. |
423 | - |
424 | - @param url: |
425 | - @type url: |
426 | """ |
427 | from urllib2 import Request, urlopen |
428 | |
429 | - pkglist = urlopen(Request(url="http://%s:%d/list" % (url, port))) |
430 | - pkgdata = pkglist.read(4) |
431 | - |
432 | - if pkgdata[:3] == V2: |
433 | - return pkglist.read() |
434 | - |
435 | - elif pkgdata == '<?xm': |
436 | - return pkgdata + pkglist.read() |
437 | - |
438 | - return '' |
439 | + pkglist = urlopen("http://%s:%d/list" % (url, port)) |
440 | + data = pkglist.read() |
441 | + return decode_list(data) |
442 | |
443 | |
444 | def make_packagelist(packages): |
445 | @@ -215,12 +173,10 @@ |
446 | @return: xml package data |
447 | @rtype: basestring |
448 | """ |
449 | - from urllib2 import unquote |
450 | - |
451 | form = ("<?xml version='1.0' ?>\n" |
452 | "<?xml-stylesheet href='list.xsl' type='text/xsl' ?>\n" |
453 | "<packagelist version='%.1f'>\n" % __version__) |
454 | for pkg in packages: |
455 | - form += " <package>\n <name>%s</name>\n </package>" % unquote(pkg) |
456 | + form += " <package>\n <name>%s</name>\n </package>" % pkg |
457 | form += "</packagelist>\n" |
458 | return form |
459 | |
460 | === modified file 'azc_daemon/__init__.py' |
461 | --- azc_daemon/__init__.py 2009-07-11 22:12:07 +0000 |
462 | +++ azc_daemon/__init__.py 2010-02-01 20:58:13 +0000 |
463 | @@ -23,6 +23,7 @@ |
464 | import os |
465 | import time |
466 | import atexit |
467 | +import resource |
468 | from signal import SIGTERM |
469 | |
470 | |
471 | @@ -85,9 +86,21 @@ |
472 | error.errno, error.strerror)) |
473 | sys.exit(1) |
474 | |
475 | - #{ redirect standard file descriptors |
476 | sys.stdout.flush() |
477 | sys.stderr.flush() |
478 | + |
479 | + #{ close all file descriptors; without this dpkg-reconfigure gets mad |
480 | + #{ code taken from http://code.activestate.com/recipes/278731/ |
481 | + maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] |
482 | + if maxfd == resource.RLIM_INFINITY: |
483 | + maxfd = 1024 |
484 | + for fd in xrange(0, maxfd): |
485 | + try: |
486 | + os.close(fd) |
487 | + except OSError: |
488 | + pass # fd wasn't open, ignore it |
489 | + |
490 | + #{ redirect standard file descriptors |
491 | si = file(self.stdin, 'r') |
492 | so = file(self.stdout, 'a+') |
493 | se = file(self.stderr, 'a+', 0) |
494 | |
495 | === renamed file 'debian/postinst' => 'debian/apt-zeroconf.postinst' |
496 | --- debian/postinst 2009-07-24 23:20:29 +0000 |
497 | +++ debian/apt-zeroconf.postinst 2010-02-01 20:58:13 +0000 |
498 | @@ -9,23 +9,18 @@ |
499 | |
500 | case "$1" in |
501 | configure) |
502 | + db_input medium apt-zeroconf/activate || true |
503 | + db_go |
504 | db_get apt-zeroconf/activate |
505 | - if [ "$RET" = true ]; then |
506 | + if [ "$RET" = "false" ]; then |
507 | + echo "ENABLED=0" > /etc/default/apt-zeroconf |
508 | + else |
509 | echo "ENABLED=1" > /etc/default/apt-zeroconf |
510 | - ln -s /usr/share/apt-zeroconf/apt-zeroconf.apt.conf \ |
511 | + [ -L /etc/apt/apt.conf.d/10apt-zeroconf ] || \ |
512 | + ln -s /usr/share/apt-zeroconf/apt-zeroconf.apt.conf \ |
513 | /etc/apt/apt.conf.d/10apt-zeroconf || true |
514 | - else |
515 | - echo "ENABLED=0" > /etc/default/apt-zeroconf |
516 | fi |
517 | ;; |
518 | - |
519 | - abort-upgrade|abort-remove|abort-deconfigure) |
520 | - ;; |
521 | - |
522 | - *) |
523 | - echo "postinst called with unknown argument \`$1'" >&2 |
524 | - exit 1 |
525 | - ;; |
526 | esac |
527 | |
528 | update-rc.d -f apt-zeroconf remove >/dev/null |
529 | |
530 | === modified file 'debian/changelog' |
531 | --- debian/changelog 2009-07-01 00:04:09 +0000 |
532 | +++ debian/changelog 2010-02-01 20:58:13 +0000 |
533 | @@ -1,3 +1,24 @@ |
534 | +apt-zeroconf (0.5.0+20100131-0ubuntu1~ppa1) unstable; urgency=low |
535 | + |
536 | + [ Josh Holland ] |
537 | + * Moved packaging to use debhelper 7. |
538 | + |
539 | + [ Siegfried-Angel Gevatter Pujals ] |
540 | + * debian/ |
541 | + - Fix Python dependencies so this works on Debian. |
542 | + - Other little changes. |
543 | + * debian/templates, debian/apt-zeroconf.postinst: |
544 | + - Give the debconf question priority "medium" and define a template for it. |
545 | + * apt-zeroconf: |
546 | + - Add installation directory to the path. |
547 | + * aptzeroconf/__init__.py: |
548 | + - Close open file descriptors after forking, without this |
549 | + dpkg-reconfigure would hang forever. |
550 | + * Replace manpage with a troff version, which doesn't need to |
551 | + be generated. |
552 | + |
553 | + -- Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> Sun, 31 Jan 2010 21:55:46 +0100 |
554 | + |
555 | apt-zeroconf (0.5.0-0ubuntu1~karmic~ppa1) karmic; urgency=low |
556 | |
557 | * Improve proxy server to include some test urls and improved pages. |
558 | |
559 | === modified file 'debian/control' |
560 | --- debian/control 2009-07-24 23:20:29 +0000 |
561 | +++ debian/control 2010-02-01 20:58:13 +0000 |
562 | @@ -1,30 +1,44 @@ |
563 | Source: apt-zeroconf |
564 | Section: admin |
565 | -Priority: extra |
566 | +Priority: optional |
567 | Maintainer: Apt-ZeroConf Launchpad Team <apt-zeroconf@lists.launchpad.net> |
568 | -Uploaders: Jeremy Austin-Bardo <ausimage@ubuntu.com>, Martin-Éric Racine <q-funk@iki.fi> |
569 | +Uploaders: Jeremy Austin-Bardo <ausimage@ubuntu.com>, |
570 | + Martin-Éric Racine <q-funk@iki.fi>, |
571 | + Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> |
572 | Homepage: https://launchpad.net/apt-zeroconf |
573 | -Build-Depends: cdbs (>= 0.4.49), debhelper (>= 5.0.37.2), python-central (>= 0.6), python-dev (>= 2.6) |
574 | -Build-Depends-Indep: dpkg (>= 1.14.6), po-debconf |
575 | -Standards-Version: 3.8.0 |
576 | -Vcs-Bzr: https://code.launchpad.net/~apt-zeroconf/apt-zeroconf/r0.5 |
577 | -XS-Python-Version: >=2.6 |
578 | +Build-Depends: cdbs (>= 0.4.49), |
579 | + debhelper (>= 7), |
580 | + python-support (>= 0.6), |
581 | + python2.6-dev, |
582 | + dpkg (>= 1.14.6), |
583 | + po-debconf |
584 | +Standards-Version: 3.8.3 |
585 | +Vcs-Bzr: https://code.launchpad.net/~apt-zeroconf/apt-zeroconf/trunk |
586 | +Vcs-Browser: https://code.launchpad.net/~apt-zeroconf/apt-zeroconf/trunk |
587 | +XS-Python-Version: >= 2.6 |
588 | |
589 | Package: apt-zeroconf |
590 | Architecture: all |
591 | -Depends: python-apt, python-avahi, python-dbus, debconf, python-azc-daemon, |
592 | - ${python:Depends}, ${misc:Depends} |
593 | +Depends: ${python:Depends}, |
594 | + ${misc:Depends}, |
595 | + python-apt, |
596 | + python-avahi, |
597 | + python-dbus, |
598 | + debconf, |
599 | + python-azc-daemon, |
600 | + lsb-base (>= 3.0-6) |
601 | XB-Python-Version: ${python:Versions} |
602 | Description: Caching peer-to-peer apt proxy for local networks |
603 | Apt-zeroconf is an extension to apt which enables it to find other |
604 | - instances on the LAN in order to exchange debian package files and not to |
605 | + instances on the LAN in order to exchange Debian package files and not to |
606 | fetch them from the internet. |
607 | |
608 | Package: python-azc-daemon |
609 | Architecture: all |
610 | XB-Python-Version: ${python:Versions} |
611 | -Depends: ${python:Depends}, ${misc:Depends} |
612 | -Description: AZC daemon library. |
613 | - Daemon library to allow python code to run in the background. Based on code |
614 | - found at |
615 | +Depends: ${python:Depends}, |
616 | + ${misc:Depends} |
617 | +Description: apt-zeroconf daemon library |
618 | + Daemon library to allow Python code to run in the background. Based upon code |
619 | + found at: |
620 | http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ |
621 | |
622 | === modified file 'debian/init' |
623 | --- debian/init 2009-08-14 22:08:19 +0000 |
624 | +++ debian/init 2010-02-01 20:58:13 +0000 |
625 | @@ -4,20 +4,18 @@ |
626 | # Required-Start: $local_fs dbus avahi |
627 | # Required-Stop: $local_fs dbus avahi |
628 | # Default-Start: 2 3 4 5 |
629 | -# Default-Stop: S 0 1 6 |
630 | +# Default-Stop: 0 1 6 |
631 | # Short-Description: apt-zeroconf peer-to-peer apt proxy |
632 | # Description: apt-zeroconf is a caching peer-to-peer proxy for |
633 | # local networks |
634 | ### END INIT INFO |
635 | |
636 | -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
637 | -#PYTHONPATH=/usr/share/pyshared #<== Not sure of this... anyone??? -- ausimage |
638 | -DAEMON=/usr/bin/apt-zeroconf |
639 | -#DAEMON_OPTS_START="-d start" |
640 | -#DAEMON_OPTS_STOP="-d stop" |
641 | -#DAEMON_OPTS_RESTART="-d restart" |
642 | +PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin |
643 | NAME=apt-zeroconf |
644 | DESC="apt-zeroconf APT proxy" |
645 | +DAEMON=/usr/bin/apt-zeroconf |
646 | +PIDFILE=/var/run/$NAME.pid |
647 | +STATUSCODE=0 |
648 | |
649 | test -x $DAEMON || exit 0 |
650 | |
651 | @@ -25,40 +23,36 @@ |
652 | |
653 | . /lib/lsb/init-functions |
654 | |
655 | -#start_azc() { |
656 | -# start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ |
657 | -# --startas $DAEMON -- $DAEMON_OPTS |
658 | -#} |
659 | - |
660 | -#stop_azc() { |
661 | -# start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid |
662 | -# rm -f /var/run/$NAME.pid |
663 | -#} |
664 | - |
665 | case "$1" in |
666 | start) |
667 | if [ "$ENABLED" != 1 ]; then |
668 | log_begin_msg "Starting $DESC (not enabled)" |
669 | else |
670 | log_begin_msg "Starting $DESC" |
671 | - #start_azc |
672 | - $DAEMON -d start |
673 | + if [ -f "$PIDFILE" ]; then |
674 | + STATUSCODE=1 # already running |
675 | + else |
676 | + $DAEMON -d start |
677 | + STATUSCODE=$? |
678 | + if [ $STATUSCODE -eq 42 ]; then |
679 | + STATUSCODE=1 # already running |
680 | + elif [ $STATUSCODE -ne 0 ]; then |
681 | + STATUSCODE=2 # error |
682 | + fi |
683 | + fi |
684 | fi |
685 | - log_end_msg 0 |
686 | + log_end_msg $STATUSCODE |
687 | ;; |
688 | stop) |
689 | log_begin_msg "Stopping $DESC" |
690 | - #stop_azc |
691 | - $DAEMON -d stop |
692 | - log_end_msg 0 |
693 | + $DAEMON -d stop >/dev/null 2>&1 |
694 | + log_end_msg 0 # else dpkg-reconfigure fails |
695 | ;; |
696 | restart|force-reload) |
697 | log_begin_msg "Restarting $DESC" |
698 | - #stop_azc |
699 | - #sleep 1 |
700 | - #start_azc |
701 | - $DAEMON -d restart |
702 | - log_end_msg 0 |
703 | + $DAEMON -d restart >/dev/null 2>&1 |
704 | + STATUSCODE=$? |
705 | + log_end_msg $STATUSCODE |
706 | ;; |
707 | *) |
708 | echo "Usage: $0 {start|stop|restart|force-reload}" >&2 |
709 | @@ -66,4 +60,4 @@ |
710 | ;; |
711 | esac |
712 | |
713 | -exit 0 |
714 | +exit $STATUSCODE |
715 | |
716 | === modified file 'debian/rules' |
717 | --- debian/rules 2009-05-06 04:18:16 +0000 |
718 | +++ debian/rules 2010-02-01 20:58:13 +0000 |
719 | @@ -1,7 +1,3 @@ |
720 | #!/usr/bin/make -f |
721 | - |
722 | -DEB_UPDATE_RCD_PARAMS=defaults 25 |
723 | -DEB_PYTHON_SYSTEM=pycentral |
724 | - |
725 | -include /usr/share/cdbs/1/rules/debhelper.mk |
726 | -include /usr/share/cdbs/1/class/python-distutils.mk |
727 | +%: |
728 | + dh $@ |
729 | |
730 | === added file 'debian/templates' |
731 | --- debian/templates 1970-01-01 00:00:00 +0000 |
732 | +++ debian/templates 2010-02-01 20:58:13 +0000 |
733 | @@ -0,0 +1,4 @@ |
734 | +Template: apt-zeroconf/activate |
735 | +Type: boolean |
736 | +Default: true |
737 | +Description: Do you want to apt-zeroconf to start automatically at boot? |
738 | |
739 | === modified file 'setup.py' |
740 | --- setup.py 2009-08-14 22:08:19 +0000 |
741 | +++ setup.py 2010-02-01 20:58:13 +0000 |
742 | @@ -1,7 +1,11 @@ |
743 | #!/usr/bin/env python |
744 | +import os |
745 | + |
746 | from distutils.core import setup |
747 | +from distutils.command.build import build |
748 | |
749 | -setup(name='apt-zeroconf', |
750 | +setup( |
751 | + name='apt-zeroconf', |
752 | version='0.6.x~bzr', |
753 | author='Apt-Zeroconf Launchpad Team', |
754 | author_email='apt-zeroconf@lists.launchpad.net', |
755 | @@ -18,18 +22,19 @@ |
756 | packages=['aptzeroconf', 'azc_daemon'], |
757 | scripts=['apt-zeroconf'], |
758 | data_files=[ |
759 | - ('/usr/share/apt-zeroconf', ['support/apt-zeroconf.apt.conf', ]), |
760 | - ('/usr/share/apt-zeroconf/pages', [ |
761 | + ('share/apt-zeroconf', ['support/apt-zeroconf.apt.conf', ]), |
762 | + ('share/apt-zeroconf/pages', [ |
763 | 'pages/aptzeroconf.css', 'pages/host.html', 'pages/index.html', |
764 | 'pages/listupdate.html', 'pages/list.xsl', 'pages/aptzeroconf.png', |
765 | 'pages/stats.html', ]), |
766 | - ('/usr/share/apt-zeroconf/tests', [ |
767 | + ('share/apt-zeroconf/tests', [ |
768 | 'test/common.py', 'test/__init__.py', 'test/pep8.py', |
769 | 'test/test_auth.py', 'test/test_general.py', |
770 | 'test/test_sourcecode.py', ]), |
771 | ('/etc/', ['support/apt-zeroconf.conf']), |
772 | ('/etc/ufw/applications.d/', ['support/azc_rule']), |
773 | - ('/usr/share/man/man1', ['support/apt-zeroconf.1.gz', ]), ], |
774 | + ('share/man/man1', ['support/apt-zeroconf.1', ]), |
775 | + ], |
776 | keywords="zeroconf, apt, cache, pacakage, proxy, adhoc", |
777 | platforms="Ubuntu 9.04 and 9.10 (others may work as well)", |
778 | classifiers=[ |
779 | |
780 | === added file 'support/apt-zeroconf.1' |
781 | --- support/apt-zeroconf.1 1970-01-01 00:00:00 +0000 |
782 | +++ support/apt-zeroconf.1 2010-02-01 20:58:13 +0000 |
783 | @@ -0,0 +1,65 @@ |
784 | +.TH APT\-ZEROCONF 1 "January 31, 2010" "Apt-ZeroConf" |
785 | + |
786 | +.SH NAME |
787 | +apt\-zeroconf \- write summary here... |
788 | + |
789 | +.SH SYNOPSIS |
790 | +\fBapt\-zeroconf\fP \fI[OPTION]\fP |
791 | + |
792 | +.SH DESCRIPTION |
793 | +\fBapt\-zeroconf\fP creates an adhoc network on your local network to provide |
794 | +apt repository packages. Allowing you download once, then retrieve locally for |
795 | +all other computers on your network. |
796 | + |
797 | +.SH OPTIONS |
798 | +The program follows the usual GNU command line syntax, with |
799 | +options starting with two dashes (`--'). A summary of options is |
800 | +included below. |
801 | +.TP |
802 | +.B \-p, \-\-port |
803 | +Start \fBapt\-zeroconf\fP at the given port. |
804 | +.TP |
805 | +.B \-r, \-\-restrict |
806 | +Overrides the option in \fBapt\-zeroconf\fP's configuration file, on whether |
807 | +to restrict the proxy to only operate for the URLs specified under the |
808 | +[apt-cache] section. |
809 | +.TP |
810 | +.B \-d, \-\-daemon=start|stop|restart |
811 | +Start \fBapt\-zeroconf\fP as a background process, stop an already running |
812 | +instance or restart an already running instance. |
813 | +.TP |
814 | +.B -l, \-\-logger=debug|info|warning|error|critical |
815 | +Change the verbosity of the log output. |
816 | + |
817 | +.SH EXIT VALUES |
818 | +.TP |
819 | +.B 0 |
820 | +Success. |
821 | +.TP |
822 | +.B 2 |
823 | +Incorrect parameter or another user error. |
824 | +.TP |
825 | +.B 42 |
826 | +Another instance of \fBapt\-zeroconf\fP is already running or there's |
827 | +another service using the same port. |
828 | + |
829 | +.SH BUGS |
830 | +Please report any bugs at https://bugs.launchpad.net/apt-zeroconf. |
831 | + |
832 | +.SH AUTHORS |
833 | +Please see the AUTHORS file bundled with this application for |
834 | +a complete list of contributors. |
835 | + |
836 | +.SH LICENSE |
837 | +This program is free software: you can redistribute it and/or modify |
838 | +it under the terms of the GNU Lesser General Public License as published by |
839 | +the Free Software Foundation, either version 3 of the License, or |
840 | +(at your option) any later version. |
841 | +.PP |
842 | +This program is distributed in the hope that it will be useful, |
843 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
844 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
845 | +GNU Lesser General Public License for more details. |
846 | +.PP |
847 | +You should have received a copy of the GNU Lesser General Public License |
848 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
849 | |
850 | === removed file 'support/apt-zeroconf.xml' |
851 | --- support/apt-zeroconf.xml 2009-07-04 03:53:33 +0000 |
852 | +++ support/apt-zeroconf.xml 1970-01-01 00:00:00 +0000 |
853 | @@ -1,115 +0,0 @@ |
854 | -<?xml version="1.0" encoding="utf-8"?> |
855 | -<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" |
856 | -"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> |
857 | -<!-- See http://www.docbook.org/tdg/en/html/refentry.html for more info |
858 | - Use docbook2x-man to generate manpage. --> |
859 | -<refentry id="application.soovee"> |
860 | - <refentryinfo> |
861 | - <author>Apt-ZeroConf Launchpad Team</author> |
862 | - <address></address> |
863 | - |
864 | - <copyright><year>2009</year><holder>Jeremy Austin-Bardo</holder></copyright> |
865 | - </refentryinfo> |
866 | - |
867 | - <refmeta> |
868 | - <refentrytitle>apt-zeroconf</refentrytitle><manvolnum>1</manvolnum> |
869 | - </refmeta> |
870 | - |
871 | - <refnamediv> |
872 | - <refname>apt-zeroconf</refname> |
873 | - <refpurpose>Create an adhoc network on your local network to provide |
874 | - Internet apt repository packages. Allowing you download once, then retrieve |
875 | - locally for all other computers on your network. |
876 | - </refpurpose> |
877 | - </refnamediv> |
878 | - <refsynopsisdiv> |
879 | - <cmdsynopsis> |
880 | - <command>apt-zeroconf</command> |
881 | - <arg choice="opt"> |
882 | - <option>-p</option><option>--port</option> Number |
883 | - </arg> |
884 | - <arg choice="opt"> |
885 | - <option>-r</option><option>--restrict</option> |
886 | - </arg> |
887 | - <arg choice="opt"> |
888 | - <option>-d</option><option>--daemon</option> |
889 | - <arg choice="req">start stop restart</arg> |
890 | - </arg> |
891 | - <arg choice="opt"> |
892 | - <option>-r</option><option>--restrict</option> |
893 | - </arg> |
894 | - <arg choice="opt"> |
895 | - <option>-l</option><option>--logger</option> |
896 | - <arg choice="req">debug info warning error critical</arg> |
897 | - </arg> |
898 | - </cmdsynopsis> |
899 | - </refsynopsisdiv> |
900 | - <refsect1> |
901 | - <title>Description</title> |
902 | - |
903 | - <para><command>apt-zeroconf</command> </para> |
904 | - </refsect1> |
905 | - |
906 | - <refsect1> |
907 | - <title>Command Arguments</title> |
908 | - |
909 | - <variablelist> |
910 | - <varlistentry> |
911 | - <term> |
912 | - <option>--port</option><option>-p</option> |
913 | - </term> |
914 | - <listitem> |
915 | - <para>Override configuration file port designation for |
916 | - <option>Number</option></para> |
917 | - </listitem> |
918 | - </varlistentry> |
919 | - <varlistentry> |
920 | - <term> |
921 | - <option>-r</option><option>--restrict</option> |
922 | - </term> |
923 | - <listitem> |
924 | - <para>Override configuration file proxy restriction to enable only |
925 | - designated urls in [apt-cache] section.</para> |
926 | - </listitem> |
927 | - </varlistentry> |
928 | - <varlistentry> |
929 | - <term> |
930 | - <option>-d</option><option>--daemon</option> |
931 | - </term> |
932 | - <listitem> |
933 | - <para>Daemonize apt-zeroconf process to run as a background process. |
934 | - Daemons value should be <option>debug</option>, <option>info</option>, |
935 | - <option>warning</option>, <option>error</option>, or |
936 | - <option>critical</option>. Should be run with sudo priviledges to |
937 | - enable logging functionality. |
938 | - </para> |
939 | - </listitem> |
940 | - </varlistentry> |
941 | - <varlistentry> |
942 | - <term> |
943 | - <option>-l</option><option>--logger</option> |
944 | - </term> |
945 | - <listitem> |
946 | - <para>Set logger logging level for apt-zeroconf to one of the |
947 | - following <option>info</option>, <option>warning</option>, |
948 | - <option>error</option>, or <option>critical</option>. Without setting |
949 | - this switch the default will be <option>info</option>. |
950 | - </para> |
951 | - </listitem> |
952 | - </varlistentry> |
953 | - </variablelist> |
954 | - </refsect1> |
955 | - |
956 | - <refsect1> |
957 | - <title>See Also</title> |
958 | - |
959 | - </refsect1> |
960 | - |
961 | - <refsect1> |
962 | - <title>Author</title> |
963 | - <para>Apt-ZeroConf Launchpad Team</para> |
964 | - <para>Permission is hereby granted to copy, distribute and/or modify this |
965 | - document under the terms of the GNU General Public License, Version 2 or |
966 | - later by the Free Software Foundation.</para> |
967 | - </refsect1> |
968 | -</refentry> |
969 | |
970 | === modified file 'support/azc_rule' |
971 | --- support/azc_rule 2009-07-13 23:48:19 +0000 |
972 | +++ support/azc_rule 2010-02-01 20:58:13 +0000 |
973 | @@ -1,4 +1,4 @@ |
974 | [AptZeroConf] |
975 | -title= Apt-ZeroConf |
976 | +title=Apt-ZeroConf |
977 | description=Personal Package Cache using Avahi ZeroConf. |
978 | ports=1618/tcp |
979 | |
980 | === removed file 'support/build.sh' |
981 | --- support/build.sh 2009-06-30 21:20:54 +0000 |
982 | +++ support/build.sh 1970-01-01 00:00:00 +0000 |
983 | @@ -1,5 +0,0 @@ |
984 | -#!/bin/sh |
985 | -echo "building..." |
986 | -for file in `ls *.xml`; do docbook2x-man $file; done |
987 | -echo "compressing..." |
988 | -for file in `ls *.1`; do gzip $file; done |
989 | |
990 | === modified file 'test/test_general.py' |
991 | --- test/test_general.py 2009-08-09 03:57:29 +0000 |
992 | +++ test/test_general.py 2010-02-01 20:58:13 +0000 |
993 | @@ -122,8 +122,7 @@ |
994 | PORT, DEBNAME)).read() |
995 | # make sure the data is equal |
996 | assert data == '*contents*' |
997 | - |
998 | - |
999 | + |
1000 | def test_download_epoch_local_server(tmpdir): |
1001 | """ |
1002 | Test fetching a file with an epoch from an AZC instance on the local network. |
- Several fixes so that installing the package works correctly.
- Fix http.py to look in the right path for the installed files.
- Replace the manpage with a roff one, so that no conversion is needed.
- Change hashbang to python2.6 so this works on Debian too (where 2.5 is default).
- Merge in a couple other branches.
- Other little changes to debian/.