diff 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
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):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)