Mercurial > treepkg
comparison 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 |
comparison
equal
deleted
inserted
replaced
411:8dd64f8bf572 | 412:58ecf7c0ecba |
---|---|
25 from treepkg.info.status import TreepkgInfo | 25 from treepkg.info.status import TreepkgInfo |
26 | 26 |
27 config_desc = ["distribution", "section", "num_newest", | 27 config_desc = ["distribution", "section", "num_newest", |
28 "build_user", "build_host", "build_listpackages", | 28 "build_user", "build_host", "build_listpackages", |
29 "publish_user", "publish_host", | 29 "publish_user", "publish_host", |
30 ("architectures", shlex.split, "i386, source"), | 30 ("architectures", shlex.split, "armel i386 source"), |
31 ("after_upload_hook", shlex.split), | 31 ("after_upload_hook", shlex.split), |
32 ("publish_remove_old_packages", convert_bool), | 32 ("publish_remove_old_packages", convert_bool), |
33 ("publish_dir", remove_trailing_slashes), | 33 ("publish_dir", remove_trailing_slashes), |
34 ("cachedir", | 34 ("cachedir", |
35 lambda s: expand_filename(remove_trailing_slashes(s)))] | 35 lambda s: expand_filename(remove_trailing_slashes(s)))] |
74 runremote="", | 74 runremote="", |
75 **variables)) | 75 **variables)) |
76 return TreepkgInfo.fromxml(xml) | 76 return TreepkgInfo.fromxml(xml) |
77 | 77 |
78 def get_binary_arch(arch): | 78 def get_binary_arch(arch): |
79 if not arch == "source": | 79 if not arch is None and not arch.startswith("binary") and \ |
80 if not arch.startswith("binary"): | 80 not arch == "source": |
81 arch = "binary-" + arch | 81 arch = "binary-" + arch |
82 return arch | 82 return arch |
83 | 83 |
84 def check_package_is_new(packagename, destdir, packagemd5sum): | 84 def check_package_is_new(packagename, destdir, packagemd5sum): |
85 destpackage = os.path.join(destdir, packagename) | 85 destpackage = os.path.join(destdir, packagename) |
86 if not os.path.isfile(destpackage): | 86 if not os.path.isfile(destpackage): |
87 return True | 87 return True |
88 destmd5sum = md5sum(destpackage) | 88 destmd5sum = md5sum(destpackage) |
89 return (destmd5sum != packagemd5sum) | 89 return (destmd5sum != packagemd5sum) |
90 | 90 |
91 def copy_to_destdir(package, dir, arch, subdir): | 91 def copy_to_destdir(package, dir, arch, subdir, quiet = False): |
92 scp_flags = [] | 92 scp_flags = [] |
93 if quiet: | |
94 scp_flags.append("-q") | |
93 destdir = os.path.join(dir, arch, subdir) | 95 destdir = os.path.join(dir, arch, subdir) |
94 print "package: %s, destdir: %s" % (package.name, destdir) | 96 print "package: %s, destdir: %s" % (package.name, destdir) |
95 md5sum = "" | 97 md5sum = "" |
96 for checksum in package.checksums: | 98 for checksum in package.checksums: |
97 if checksum.type == "md5": | 99 if checksum.type == "md5": |
102 pass | 104 pass |
103 # scp the packages to the cache dir | 105 # scp the packages to the cache dir |
104 #call(cmdexpand("scp -p @scp_flags $file $cachedir/", file=package.path, | 106 #call(cmdexpand("scp -p @scp_flags $file $cachedir/", file=package.path, |
105 # scp_flags=scp_flags, cachedir=destdir)) | 107 # scp_flags=scp_flags, cachedir=destdir)) |
106 | 108 |
107 def copy_to_cache(variables, track, revision, quiet, architectures=None): | 109 def copy_to_cache(variables, track, revision, quiet = False, architectures=None): |
108 cachedir = variables["cachedir"] | 110 cachedir = variables["cachedir"] |
109 if quiet: | |
110 scp_flags.append("-q") | |
111 treepkginfo = get_treepkg_info(variables) | 111 treepkginfo = get_treepkg_info(variables) |
112 allowedarchs = set([]) # contains all wanted architectures (incl. source) | 112 #allowedarchs = set([]) # contains all wanted architectures (incl. source) |
113 allarchs = set([]) # contains all present architectures (incl. source) | 113 allarchs = set([]) # contains all present architectures (incl. source) |
114 binaryallpackages = [] | 114 binaryallpackages = [] |
115 # change e.g. armel in binary-armel | 115 # change e.g. armel in binary-armel |
116 if not architectures is None: | 116 if not architectures is None: |
117 for arch in architectures: | 117 allowedarchs = set([get_binary_arch(a) for a in architectures]) |
118 allowedarchs.append(get_binary_arch(arch)) | 118 else: |
119 allowedarchs = set([]) | |
119 | 120 |
120 for track in treepkginfo.tracks: | 121 for track in treepkginfo.tracks: |
121 for rev in track.revisions: | 122 for rev in track.revisions: |
122 for package in rev.packages: | 123 for package in rev.packages: |
123 # handle binary-all | 124 arch = get_binary_arch(package.arch) |
124 if package.arch == "binary-all": | 125 print "%s %s %s %s" % (track.name, package.name, package.type, package.arch) |
125 # add trackname for subdir name | 126 if package.type == "binary": |
126 package.tackname = track.name | 127 # skip other files |
127 binaryallpackages.append(package) | 128 if package.arch is None: |
128 break | 129 continue |
129 allarchs.append(package.arch) | 130 # handle binary-all |
131 if arch == "binary-all": | |
132 # add trackname for subdir name | |
133 package.trackname = track.name | |
134 binaryallpackages.append(package) | |
135 continue | |
136 allarchs.add(arch) | |
137 elif package.type == "source": | |
138 arch = package.type | |
130 # only copy requested archs | 139 # only copy requested archs |
131 if len(allowedarchs) == 0 or \ | 140 if len(allowedarchs) == 0 or \ |
132 package.arch in allowedarchs: | 141 arch in allowedarchs: |
133 copy_to_destdir(package, cachedir, package.arch, track.name) | 142 copy_to_destdir(package, cachedir, arch, track.name, |
143 quiet) | |
134 | 144 |
145 #print "architectures %s" % architectures | |
146 #print "allowed %s" % allowedarchs | |
147 #print "all %s" % allarchs | |
135 # copy binary-all packages | 148 # copy binary-all packages |
149 sourcearch = set(["source"]) | |
136 if len(allowedarchs) == 0: | 150 if len(allowedarchs) == 0: |
137 binallarchs = allarchs - set(["source"]) | 151 binallarchs = allarchs - sourcearch |
152 elif len(allarchs) == 0: | |
153 binallarchs = allowedarchs - sourcearch | |
138 else: | 154 else: |
139 binallarchs = allowedarchs & allarchs - set(["source"]) | 155 binallarchs = (allowedarchs & allarchs) - sourcearch |
156 #print "binallarcgs %s" % binallarchs | |
140 for package in binaryallpackages: | 157 for package in binaryallpackages: |
141 for arch in binallarchs: | 158 for arch in binallarchs: |
142 copy_to_destdir(package, cachedir, arch, package.trackname) | 159 copy_to_destdir(package, cachedir, arch, package.trackname, quiet) |
143 | 160 |
144 def publish_packages_arch(variables, track, revision, dist, section, | 161 def publish_packages_arch(variables, track, revision, dist, section, |
145 quiet, architectures): | 162 quiet, architectures): |
146 copy_to_cache(variables, track, revision, quiet, architectures) | 163 copy_to_cache(variables, track, revision, quiet, architectures) |
147 # copy_to_publishdir(variables, dist, section, arch, quiet) | 164 # copy_to_publishdir(variables, dist, section, arch, quiet) |