changeset 408:02d498ee90b8 treepkg-status

copy binary-all packages in all binary-xyz dirs
author Bjoern Ricks <bricks@intevation.de>
date Thu, 22 Jul 2010 10:17:42 +0000
parents fb473f67345b
children ecc671a84a73
files bin/publishdebianpackages.py
diffstat 1 files changed, 46 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/bin/publishdebianpackages.py	Wed Jul 21 15:52:15 2010 +0000
+++ b/bin/publishdebianpackages.py	Thu Jul 22 10:17:42 2010 +0000
@@ -73,7 +73,7 @@
                                      #runremote=runremote,
                                      runremote="",
                                      **variables)).splitlines()
-    treepkginfo = TreepkgInfo.fromxml(xml)
+    return TreepkgInfo.fromxml(xml)
 
 def get_binary_arch(arch): 
     if not arch == "source":
@@ -86,45 +86,60 @@
     if not os.path.isfile(destpackage):
         return True
     destmd5sum = md5sum(destpackage)
-    return destmd5sum == packagemd5sum
+    return (destmd5sum != packagemd5sum)
+
+def copy_to_destdir(package, dir, arch, subdir):
+    scp_flags = []
+    destdir = os.path.join(dir, arch, subdir)
+    print "package: %s, destdir: %s" % (package.name, destdir)
+    md5sum = ""
+    for checksum in package.checksums:
+        if checksum.type == "md5":
+            md5sum = checksum.checksum
+            break
+    # update only if the packages differ
+    if check_package_is_new(package.name, destdir, md5sum):
+        pass
+        # scp the packages to the cache dir 
+        #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):
-    scp_flags = []
+    cachedir = variables["cachedir"]
     if quiet:
         scp_flags.append("-q")
     treepkginfo = get_treepkg_info(variables)
-    treepkgroot = treepkginfo.root
-    binaryarchs = []
+    allowedarchs = set([]) # contains all wanted architectures (incl. source)
+    allarchs = set([]) # contains all present architectures (incl. source)
+    binaryallpackages = []
     # change e.g. armel in binary-armel
-    for arch in architectures:
-        binaryarchs.append(get_binary_arch(arch))
-    # add binary-all to requested packages
-    if not binaryarchs is None:
-        binaryarchs.append("binary-all")
-    
-    for track in treepkgroot.tracks:
-        files = []
+    if not architectures is None:
+        for arch in architectures:
+            allowedarchs.append(get_binary_arch(arch))
+   
+    for track in treepkginfo.tracks:
         for rev in track.revisions:
             for package in rev.packages:
-                # only copy requested archs (+ all)
-                if not binaryarchs is None and \
-                   not package.arch in binaryarchs:
+                # handle binary-all
+                if package.arch == "binary-all":
+                    # add trackname for subdir name
+                    package.tackname = track.name
+                    binaryallpackages.append(package)
                     break
-                destdir = os.path.join(variables["cachedir"],
-                                       package.arch,
-                                       track.name)
-                print "package: %s, destdir: %s" % (package.name, destdir)
-                md5sum = ""
-                for checksum in package.checksums:
-                    if checksum.type == "md5":
-                        md5sum = checksum.checksum
-                        break
-                # update only if the packages differ
-                if check_package_is_new(package.name, destdir, md5sum):
-                    files.append(package.path)
-         # scp the packages of a track to the cache dir 
-         #call(cmdexpand("scp -p @scp_flags @files $cachedir/", files=files,
-         #                scp_flags=scp_flagsd, cachedir=destdir))
+                allarchs.append(package.arch)
+                # only copy requested archs
+                if len(allowedarchs) == 0 or \
+                   package.arch in allowedarchs:
+                    copy_to_destdir(package, cachedir, package.arch, track.name)
+
+    # copy binary-all packages
+    if len(allowedarchs) == 0:
+        binallarchs = allarchs - set(["source"])
+    else:
+        binallarchs = allowedarchs & allarchs - set(["source"])
+    for package in binaryallpackages:
+        for arch in binallarchs:
+            copy_to_destdir(package, cachedir, arch, package.trackname)
 
 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)