Mercurial > treepkg
changeset 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 | 8dd64f8bf572 |
children | 94a6ae627b31 |
files | bin/publishdebianpackages.py treepkg/info/status.py |
diffstat | 2 files changed, 67 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/publishdebianpackages.py Thu Jul 22 11:09:52 2010 +0000 +++ b/bin/publishdebianpackages.py Thu Jul 22 16:01:43 2010 +0000 @@ -27,7 +27,7 @@ config_desc = ["distribution", "section", "num_newest", "build_user", "build_host", "build_listpackages", "publish_user", "publish_host", - ("architectures", shlex.split, "i386, source"), + ("architectures", shlex.split, "armel i386 source"), ("after_upload_hook", shlex.split), ("publish_remove_old_packages", convert_bool), ("publish_dir", remove_trailing_slashes), @@ -76,8 +76,8 @@ return TreepkgInfo.fromxml(xml) def get_binary_arch(arch): - if not arch == "source": - if not arch.startswith("binary"): + if not arch is None and not arch.startswith("binary") and \ + not arch == "source": arch = "binary-" + arch return arch @@ -88,8 +88,10 @@ destmd5sum = md5sum(destpackage) return (destmd5sum != packagemd5sum) -def copy_to_destdir(package, dir, arch, subdir): +def copy_to_destdir(package, dir, arch, subdir, quiet = False): scp_flags = [] + if quiet: + scp_flags.append("-q") destdir = os.path.join(dir, arch, subdir) print "package: %s, destdir: %s" % (package.name, destdir) md5sum = "" @@ -104,42 +106,57 @@ #call(cmdexpand("scp -p @scp_flags $file $cachedir/", file=package.path, # scp_flags=scp_flags, cachedir=destdir)) -def copy_to_cache(variables, track, revision, quiet, architectures=None): +def copy_to_cache(variables, track, revision, quiet = False, architectures=None): cachedir = variables["cachedir"] - if quiet: - scp_flags.append("-q") treepkginfo = get_treepkg_info(variables) - allowedarchs = set([]) # contains all wanted architectures (incl. source) + #allowedarchs = set([]) # contains all wanted architectures (incl. source) allarchs = set([]) # contains all present architectures (incl. source) binaryallpackages = [] # change e.g. armel in binary-armel if not architectures is None: - for arch in architectures: - allowedarchs.append(get_binary_arch(arch)) + allowedarchs = set([get_binary_arch(a) for a in architectures]) + else: + allowedarchs = set([]) for track in treepkginfo.tracks: for rev in track.revisions: for package in rev.packages: - # handle binary-all - if package.arch == "binary-all": - # add trackname for subdir name - package.tackname = track.name - binaryallpackages.append(package) - break - allarchs.append(package.arch) + arch = get_binary_arch(package.arch) + print "%s %s %s %s" % (track.name, package.name, package.type, package.arch) + if package.type == "binary": + # skip other files + if package.arch is None: + continue + # handle binary-all + if arch == "binary-all": + # add trackname for subdir name + package.trackname = track.name + binaryallpackages.append(package) + continue + allarchs.add(arch) + elif package.type == "source": + arch = package.type # only copy requested archs if len(allowedarchs) == 0 or \ - package.arch in allowedarchs: - copy_to_destdir(package, cachedir, package.arch, track.name) + arch in allowedarchs: + copy_to_destdir(package, cachedir, arch, track.name, + quiet) + #print "architectures %s" % architectures + #print "allowed %s" % allowedarchs + #print "all %s" % allarchs # copy binary-all packages + sourcearch = set(["source"]) if len(allowedarchs) == 0: - binallarchs = allarchs - set(["source"]) + binallarchs = allarchs - sourcearch + elif len(allarchs) == 0: + binallarchs = allowedarchs - sourcearch else: - binallarchs = allowedarchs & allarchs - set(["source"]) + binallarchs = (allowedarchs & allarchs) - sourcearch + #print "binallarcgs %s" % binallarchs for package in binaryallpackages: for arch in binallarchs: - copy_to_destdir(package, cachedir, arch, package.trackname) + copy_to_destdir(package, cachedir, arch, package.trackname, quiet) def publish_packages_arch(variables, track, revision, dist, section, quiet, architectures):
--- a/treepkg/info/status.py Thu Jul 22 11:09:52 2010 +0000 +++ b/treepkg/info/status.py Thu Jul 22 16:01:43 2010 +0000 @@ -35,16 +35,26 @@ return textnode.data def getChild(node, name, required=False): + childs = getChilds(node, name, required) + if not childs or len(childs) == 0: + return None + else: + return childs[0] + +def getChilds(node, name, required=False): if not node: if required: - raise TreepkgInfoException("") + raise TreepkgInfoException("Element %s is required as child. But" + "parent element is not available.") return None childs = node.getElementsByTagName(name) if not childs: if required: - raise TreepkgInfoException("") + raise TreepkgInfoException("Element %s is required as child for %s." + "The XML file must be invalid." % (name, node.nodeName)) return None - return childs[0] + return childs + class TreepkgInfoException(Exception): """ Exception class for TreepkgInfo """ @@ -73,7 +83,6 @@ doc = xml.dom.minidom.parseString(xmlstr) root = doc.documentElement if not root.tagName == "treepkg": - print xmlstr raise TreepkgInfoException("XML is not valid for treepkginfo") return TreepkgRoot.fromxml(root) @@ -141,12 +150,13 @@ @staticmethod def fromxml(node): version = node.getAttribute("version") - trackseles = node.getElementsByTagName("tracks") + tracksele = getChild(node, "tracks") + trackeles = getChilds(tracksele, "track") infoele = getChild(node, "info") treepkgrootinfo = TreepkgRootInfo.fromxml(infoele) treepkgroot = TreepkgRoot(version, treepkgrootinfo) tracks = [] - for trackele in trackseles: + for trackele in trackeles: tracks.append(TreepkgTrackInfo.fromxml(trackele)) treepkgroot.tracks = tracks return treepkgroot @@ -189,12 +199,11 @@ @staticmethod def fromxml(node): version = node.getAttribute("version") - infoele = getChild(node, "info", True) - nameele = getChild(infoele, "name", True) + nameele = getChild(node, "name", True) name = getTextFromNode(nameele) - treepkgpathele = getChild(infoele, "treepkgpath") + treepkgpathele = getChild(node, "treepkgpath") treepkgpath = getTextFromNode(treepkgpathele) - trackspathele = getChild(infoele, "trackspath") + trackspathele = getChild(node, "trackspath") trackspath = getTextFromNode(trackspathele) return TreepkgRootInfo(name, treepkgpath, trackspath, version) @@ -296,11 +305,13 @@ treepkgrevisioninfo = TreepkgTrackRevisionInfo(number, rules, message) treepkgrevisioninfo.packages = [] treepkgrevisioninfo.logs = [] - packageeles = getChild(node, "packages") + packagesele = getChild(node, "packages") + packageeles = getChilds(packagesele, "package") for packageele in packageeles: treepkgrevisioninfo.packages.append( TreepkgPackageInfo.fromxml(packageele)) - logeles = getChild(node, "logs") + logsele = getChild(node, "logs") + logeles = getChilds(logsele, "log") for logele in logeles: treepkgrevisioninfo.logs.append( TreepkgLogInfo.fromxml(logele)) @@ -375,6 +386,8 @@ path = getTextFromNode(pathele) ptype = node.getAttribute("type") arch = node.getAttribute("arch") + if len(arch) == 0: + arch = None packageinfo = TreepkgPackageInfo(name, path, ptype, arch) checksumeles = node.getElementsByTagName("checksum") for checksumele in checksumeles: @@ -398,7 +411,8 @@ @staticmethod def fromxml(node): - checksumele = getChild(node, "checksum", True) - checksum = getTextFromNode(checksumele) + checksum = getTextFromNode(node) ctype = node.getAttribute("type") + if len(ctype) == 0: + return TreepkgChecksumInfo(checksum) return TreepkgChecksumInfo(checksum, ctype)