Mercurial > treepkg
annotate bin/publishdebianpackages.py @ 412:58ecf7c0ecba treepkg-status
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Thu, 22 Jul 2010 16:01:43 +0000 |
parents | ecc671a84a73 |
children | 94a6ae627b31 |
rev | line source |
---|---|
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
1 #! /usr/bin/python |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
2 # Copyright (C) 2007 - 2010 by Intevation GmbH |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
3 # Authors: |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
4 # Bernhard Herzog <bh@intevation.de> |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
5 # Bjoern Ricks <bjoern.ricks@intevation.de> |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
6 # |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
7 # This program is free software under the GPL (>=v2) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
8 # Read the file COPYING coming with the software for details. |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
9 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
10 """Publishes selected packages created by treepkg""" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
11 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
12 import os |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
13 import sys |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
14 import shlex |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
15 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
16 from optparse import OptionParser |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
17 from ConfigParser import SafeConfigParser |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
18 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
19 import treepkgcmd |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
20 from treepkg.readconfig import read_config_section, convert_bool |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
21 from treepkg.run import call, capture_output |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
22 from treepkg.cmdexpand import cmdexpand |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
23 from treepkg.publish import * |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
24 from treepkg.util import md5sum |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
25 from treepkg.info.status import TreepkgInfo |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
26 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
27 config_desc = ["distribution", "section", "num_newest", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
28 "build_user", "build_host", "build_listpackages", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
29 "publish_user", "publish_host", |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
30 ("architectures", shlex.split, "armel i386 source"), |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
31 ("after_upload_hook", shlex.split), |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
32 ("publish_remove_old_packages", convert_bool), |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
33 ("publish_dir", remove_trailing_slashes), |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
34 ("cachedir", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
35 lambda s: expand_filename(remove_trailing_slashes(s)))] |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
36 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
37 def read_config(filename): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
38 if not os.path.exists(filename): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
39 print >>sys.stderr, "Config file %s does not exist" % filename |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
40 sys.exit(1) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
41 parser = SafeConfigParser() |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
42 parser.read([filename]) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
43 return read_config_section(parser, "publishpackages", config_desc) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
44 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
45 def parse_commandline(): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
46 parser = OptionParser() |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
47 parser.set_defaults(config_file=os.path.join(treepkgcmd.topdir, |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
48 "publishpackages.cfg"), |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
49 quiet=False) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
50 parser.add_option("--config-file", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
51 help=("The configuration file." |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
52 " Default is publishpackages.cfg")) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
53 parser.add_option("--dist", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
54 help=("The debian distribution name to use on" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
55 " the publishing system")) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
56 parser.add_option("--section", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
57 help=("The debian distribution section name to use on" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
58 " the publishing system")) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
59 parser.add_option("--track", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
60 help=("The package track whose files are to be" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
61 " published. If not given, files of all tracks" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
62 " will be published")) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
63 parser.add_option("--quiet", action="store_true", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
64 help=("Do not print progress meters or other" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
65 " informational output")) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
66 return parser.parse_args() |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
67 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
68 def get_treepkg_info(variables): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
69 runremote = prefix_for_remote_command(variables["build_user"], |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
70 variables["build_host"]) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
71 xml = capture_output(cmdexpand("@runremote $build_listpackages" |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
72 " --newest=$num_newest", |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
73 #runremote=runremote, |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
74 runremote="", |
409 | 75 **variables)) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
76 return TreepkgInfo.fromxml(xml) |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
77 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
78 def get_binary_arch(arch): |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
79 if not arch is None and not arch.startswith("binary") and \ |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
80 not arch == "source": |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
81 arch = "binary-" + arch |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
82 return arch |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
83 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
84 def check_package_is_new(packagename, destdir, packagemd5sum): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
85 destpackage = os.path.join(destdir, packagename) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
86 if not os.path.isfile(destpackage): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
87 return True |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
88 destmd5sum = md5sum(destpackage) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
89 return (destmd5sum != packagemd5sum) |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
90 |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
91 def copy_to_destdir(package, dir, arch, subdir, quiet = False): |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
92 scp_flags = [] |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
93 if quiet: |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
94 scp_flags.append("-q") |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
95 destdir = os.path.join(dir, arch, subdir) |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
96 print "package: %s, destdir: %s" % (package.name, destdir) |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
97 md5sum = "" |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
98 for checksum in package.checksums: |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
99 if checksum.type == "md5": |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
100 md5sum = checksum.checksum |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
101 break |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
102 # update only if the packages differ |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
103 if check_package_is_new(package.name, destdir, md5sum): |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
104 pass |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
105 # scp the packages to the cache dir |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
106 #call(cmdexpand("scp -p @scp_flags $file $cachedir/", file=package.path, |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
107 # scp_flags=scp_flags, cachedir=destdir)) |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
108 |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
109 def copy_to_cache(variables, track, revision, quiet = False, architectures=None): |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
110 cachedir = variables["cachedir"] |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
111 treepkginfo = get_treepkg_info(variables) |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
112 #allowedarchs = set([]) # contains all wanted architectures (incl. source) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
113 allarchs = set([]) # contains all present architectures (incl. source) |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
114 binaryallpackages = [] |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
115 # change e.g. armel in binary-armel |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
116 if not architectures is None: |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
117 allowedarchs = set([get_binary_arch(a) for a in architectures]) |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
118 else: |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
119 allowedarchs = set([]) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
120 |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
121 for track in treepkginfo.tracks: |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
122 for rev in track.revisions: |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
123 for package in rev.packages: |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
124 arch = get_binary_arch(package.arch) |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
125 print "%s %s %s %s" % (track.name, package.name, package.type, package.arch) |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
126 if package.type == "binary": |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
127 # skip other files |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
128 if package.arch is None: |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
129 continue |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
130 # handle binary-all |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
131 if arch == "binary-all": |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
132 # add trackname for subdir name |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
133 package.trackname = track.name |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
134 binaryallpackages.append(package) |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
135 continue |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
136 allarchs.add(arch) |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
137 elif package.type == "source": |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
138 arch = package.type |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
139 # only copy requested archs |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
140 if len(allowedarchs) == 0 or \ |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
141 arch in allowedarchs: |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
142 copy_to_destdir(package, cachedir, arch, track.name, |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
143 quiet) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
144 |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
145 #print "architectures %s" % architectures |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
146 #print "allowed %s" % allowedarchs |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
147 #print "all %s" % allarchs |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
148 # copy binary-all packages |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
149 sourcearch = set(["source"]) |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
150 if len(allowedarchs) == 0: |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
151 binallarchs = allarchs - sourcearch |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
152 elif len(allarchs) == 0: |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
153 binallarchs = allowedarchs - sourcearch |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
154 else: |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
155 binallarchs = (allowedarchs & allarchs) - sourcearch |
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
156 #print "binallarcgs %s" % binallarchs |
408
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
157 for package in binaryallpackages: |
02d498ee90b8
copy binary-all packages in all binary-xyz dirs
Bjoern Ricks <bricks@intevation.de>
parents:
406
diff
changeset
|
158 for arch in binallarchs: |
412
58ecf7c0ecba
improved publishdebianpackages and fixed a lot of bugs in the xml info parsing part
Bjoern Ricks <bricks@intevation.de>
parents:
409
diff
changeset
|
159 copy_to_destdir(package, cachedir, arch, package.trackname, quiet) |
406
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
160 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
161 def publish_packages_arch(variables, track, revision, dist, section, |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
162 quiet, architectures): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
163 copy_to_cache(variables, track, revision, quiet, architectures) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
164 # copy_to_publishdir(variables, dist, section, arch, quiet) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
165 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
166 def publish_packages(config_filename, track, revision, dist, section, quiet): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
167 config = read_config(config_filename) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
168 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
169 if dist is None: |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
170 dist = config["distribution"] |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
171 if section is None: |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
172 section = config["section"] |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
173 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
174 architectures = config["architectures"] |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
175 publish_packages_arch(config, track, revision, dist, section, |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
176 quiet, architectures) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
177 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
178 # update apt archive |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
179 # call(config["after_upload_hook"]) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
180 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
181 def main(): |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
182 options, args = parse_commandline() |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
183 revision = None # for future use cases |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
184 publish_packages(options.config_file, options.track, revision, |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
185 options.dist, options.section, options.quiet) |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
186 |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
187 if __name__ == "__main__": |
52e3c3976e53
inital checkin for new publishpackages processing
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
188 main() |