[Pkg-ocaml-maint-commits] r5172 - /trunk/tools/gen-binNMU-request/gen-binNMU-request.py

glondu-guest at users.alioth.debian.org glondu-guest at users.alioth.debian.org
Thu Feb 14 21:32:22 UTC 2008


Author: glondu-guest
Date: Thu Feb 14 21:32:22 2008
New Revision: 5172

URL: http://svn.debian.org/wsvn/?sc=1&rev=5172
Log:
Taking into account info from debian-ocaml-status.html

Modified:
    trunk/tools/gen-binNMU-request/gen-binNMU-request.py

Modified: trunk/tools/gen-binNMU-request/gen-binNMU-request.py
URL: http://svn.debian.org/wsvn/trunk/tools/gen-binNMU-request/gen-binNMU-request.py?rev=5172&op=diff
==============================================================================
--- trunk/tools/gen-binNMU-request/gen-binNMU-request.py (original)
+++ trunk/tools/gen-binNMU-request/gen-binNMU-request.py Thu Feb 14 21:32:22 2008
@@ -11,12 +11,16 @@
 import sys, os, sre
 from commands import getoutput, getstatusoutput
 from debian_bundle.debian_support import version_compare
+from xml.dom.minidom import parseString
+from httplib import HTTPConnection
 
 redep = sre.compile("[][ ;\n]+")
 madep = sre.compile("[ |,\n]+")
 nxdep = sre.compile("\+b([0-9]+)$")
 
 excluded_archs = ("source", "hurd-i386", "kfreebsd-i386", "kfreebsd-amd64")
+reference_arch = "i386"
+all_archs = "alpha, amd64, arm, armel, hppa, i386, ia64, m68k, mips, mipsel, powerpc, s390, sparc"
 
 def next_binNMU(v):
     x = nxdep.findall(v)
@@ -33,9 +37,9 @@
     archs = []
     binary_package = pkg
     for x in filter(None, r.split("\n")):
-        if "i386" in x:
+        if reference_arch in x:
             binary_package = madep.split(x.strip())[0]
-        y = x.replace("all", "alpha, amd64, arm, armel, hppa, i386, ia64, m68k, mips, mipsel, powerpc, s390, sparc")
+        y = x.replace("all", all_archs)
         l = madep.split(y.strip())
         version = l[1]
         next = next_binNMU(version)
@@ -51,32 +55,56 @@
     else:
         return None
 
+def get_up_to_date(status):
+    """Returns last_version, list_of_up_to_date_packages"""
+    # Takes only run-time dependencies
+    deps = status.getElementsByTagName("table")[0]
+    lines = deps.getElementsByTagName("tr")
+    last_version_elt = lines[0].getElementsByTagName("th")[-1].getElementsByTagName("span")[0]
+    if last_version_elt.attributes["class"].value != "version":
+        raise ValueError("Unexpected Error. Check html file.")
+    last_version = last_version_elt.firstChild.nodeValue
+    up_to_date = []
+    for line in lines[1:]:
+        cols = line.getElementsByTagName("td")
+        pkg = cols[0].getElementsByTagName("span")[0].firstChild.nodeValue
+        if cols[-1].attributes["class"].value != "none":
+            up_to_date.append(pkg)
+    return last_version, up_to_date
+
+def download(f):
+    c = HTTPConnection("pkg-ocaml-maint.alioth.debian.org")
+    c.request("GET", "/%s" % f)
+    r = c.getresponse().read()
+    c.close()
+    return r
+
 
 if __name__ == "__main__":
-    # Expects something like:
-    # http://pkg-ocaml-maint.alioth.debian.org/build_order.txt
-    f = file(sys.argv[1],"r")
-    raw_list = f.readlines()[1:]
-    f.close()
+    # Downloads:
+    #   http://pkg-ocaml-maint.alioth.debian.org/build_order.txt
+    #   http://pkg-ocaml-maint.alioth.debian.org/debian-ocaml-status.html
+    raw_list = download("build_order.txt").split("\n")
+    last_version, up_to_date = get_up_to_date(parseString(download("debian-ocaml-status.html")))
+
     pkg_list = []
-
     for x in raw_list:
-       l = redep.split(x)
-       pkg = l[2]
-       deps = l[3:-1]
-       deps.remove("ocaml")
-       pkg_list.append((pkg, deps))
+        if x:
+            l = redep.split(x)
+            pkg = l[2]
+            deps = l[3:-1]
+            if pkg not in up_to_date:
+                pkg_list.append((pkg, deps))
 
     next_dict = {}
-
     for pkg, deps in pkg_list:
         x = rmadison(pkg)
-        if not x: continue
-        source_version, numNMU, binary_package, archs = x
-        print "%s_%s, Rebuild with ocaml 3.10.1, %d, %s" % \
-          (pkg, source_version, numNMU, " ".join(archs))
-        for dep in deps:
-            binpkg, dep_ver = next_dict.get(dep, (None, None))
-            if dep_ver:
-                print "%s dep-wait %s (>= %s)" % (pkg, binpkg, dep_ver)
-        next_dict[pkg] = (binary_package, source_version + "+b%d" % numNMU)
+        if x:
+            source_version, numNMU, binary_package, archs = x
+            print "%s_%s, Rebuild with ocaml %s, %d, %s" % \
+                  (pkg, source_version, last_version, numNMU, " ".join(archs))
+            for dep in deps:
+                binpkg, dep_ver = next_dict.get(dep, (None, None))
+                if dep_ver:
+                    print "%s dep-wait %s (>= %s)" % (pkg, binpkg, dep_ver)
+                    next_dict[pkg] = (binary_package, source_version + "+b%d" % numNMU)




More information about the Pkg-ocaml-maint-commits mailing list