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

glondu-guest at users.alioth.debian.org glondu-guest at users.alioth.debian.org
Sun Mar 2 15:24:15 UTC 2008


Author: glondu-guest
Date: Sun Mar  2 15:24:15 2008
New Revision: 5243

URL: http://svn.debian.org/wsvn/?sc=1&rev=5243
Log:
Using the dot file to generate the binNMU request

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=5243&op=diff
==============================================================================
--- trunk/tools/gen-binNMU-request/gen-binNMU-request.py (original)
+++ trunk/tools/gen-binNMU-request/gen-binNMU-request.py Sun Mar  2 15:24:15 2008
@@ -14,16 +14,18 @@
 from xml.dom.minidom import parseString
 from httplib import HTTPConnection
 
-redep = sre.compile("[][ ;\n]+")
-madep = sre.compile("[ |,\n]+")
-nxdep = sre.compile("\+b([0-9]+)$")
+node_re = sre.compile('^node[ "]*([^ "]+)[ "]*[0-9.]+ *([0-9.]+).*$')
+edge_re = sre.compile('^edge[ "]*([^ "]+)[ "]*([^ "]+).*$')
+rmadison_re = sre.compile("[ |,\n]+")
+binNMU_re = sre.compile("\+b([0-9]+)$")
 
 excluded_archs = ("source", "all", "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)
+    """Returns the next binNMU number for version v"""
+    x = binNMU_re.findall(v)
     if x == []:
         return 1
     else:
@@ -38,7 +40,7 @@
     binary_package = pkg
     indep_packages = []
     for x in filter(None, r.split("\n")):
-        l = madep.split(x.strip())
+        l = rmadison_re.split(x.strip())
         binary_package_name = l[0]
         version = l[1]
         available_archs = l[3:]
@@ -61,8 +63,9 @@
         return None
 
 def get_up_to_date(status):
-    """Returns last_version, list_of_up_to_date_packages"""
+    """Takes DOM, returns last_version_of_ocaml, list_of_up_to_date_packages"""
     # Takes only run-time dependencies
+    # All packages with build-time only dependencies will be asked for binNMU
     deps = status.getElementsByTagName("table")[0]
     lines = deps.getElementsByTagName("tr")
     last_version_elt = lines[0].getElementsByTagName("th")[-1].getElementsByTagName("span")[0]
@@ -78,33 +81,53 @@
     return last_version, up_to_date
 
 def download(f):
+    """Returns the contents of http://pkg-ocaml-maint.alioth.debian.org/f"""
     c = HTTPConnection("pkg-ocaml-maint.alioth.debian.org")
     c.request("GET", "/%s" % f)
     r = c.getresponse().read()
     c.close()
     return r
 
+def process_dot(dot):
+    """Processes dot data into a topologically sorted list of (pkg, deps)"""
+    sin, sout, serr = os.popen3("dot -Tplain")
+    print >>sin, dot
+    sin.close()
+    lines = sout.readlines()
+    sout.close()
+    serr.close()
+    deps = {}
+    orders = {}
+    for x in lines:
+        m = edge_re.match(x)
+        if m:
+            pkg = m.group(1)
+            dep = m.group(2)
+            deps.setdefault(pkg, [])
+            deps[pkg].append(dep)
+        else:
+            m = node_re.match(x)
+            if m:
+                orders[m.group(1)] = float(m.group(2))
+    res = deps.items()
+    # Hack: the topological sort is done by sorting by y coordinates of nodes
+    res.sort(key=lambda x: orders[x[0]])
+    return res
+
 
 if __name__ == "__main__":
     # Downloads:
-    #   http://pkg-ocaml-maint.alioth.debian.org/build_order.txt
+    #   http://pkg-ocaml-maint.alioth.debian.org/ocaml_build_deps.dot
     #   http://pkg-ocaml-maint.alioth.debian.org/debian-ocaml-status.html
-    raw_list = download("build_order.txt").split("\n")
+    pkg_list = process_dot(download("ocaml_build_deps.dot"))
     last_version, up_to_date = get_up_to_date(parseString(download("debian-ocaml-status.html")))
-
-    pkg_list = []
-    for x in raw_list:
-        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 = {}
     indep_dict = {}
     for pkg, deps in pkg_list:
-        x = rmadison(pkg)
+        x = None
+        if pkg not in up_to_date:
+            x = rmadison(pkg)
         if x:
             source_version, numNMU, binary_package, archs, indep_packages = x
             print "%s_%s, Rebuild with ocaml %s, %d, %s" % \




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