[Pkg-ocaml-maint-commits] r4037 - in /trunk/tools/ocaml-debian-status: debian-ocaml-status.genshi debian-ocaml-status.py ocaml-status.css

zack at users.alioth.debian.org zack at users.alioth.debian.org
Sun Jul 15 17:25:05 UTC 2007


Author: zack
Date: Sun Jul 15 17:25:04 2007
New Revision: 4037

URL: http://svn.debian.org/wsvn/?sc=1&rev=4037
Log:
- added support for showing the status of packages with build-time dependencies on OCaml but no runtime dependencies
- improved look and feel

Modified:
    trunk/tools/ocaml-debian-status/debian-ocaml-status.genshi
    trunk/tools/ocaml-debian-status/debian-ocaml-status.py
    trunk/tools/ocaml-debian-status/ocaml-status.css

Modified: trunk/tools/ocaml-debian-status/debian-ocaml-status.genshi
URL: http://svn.debian.org/wsvn/trunk/tools/ocaml-debian-status/debian-ocaml-status.genshi?rev=4037&op=diff
==============================================================================
--- trunk/tools/ocaml-debian-status/debian-ocaml-status.genshi (original)
+++ trunk/tools/ocaml-debian-status/debian-ocaml-status.genshi Sun Jul 15 17:25:04 2007
@@ -13,15 +13,23 @@
 
     <h1>Status of OCaml in Debian</h1>
 
-    <h2>Packages</h2>
+    <div id="navbar">
+      <ul>
+	<li> jump to: <a href="#runtime">packages with runtime deps on OCaml</a> </li>
+	<li> jump to: <a href="#buildtime">packages with build-time deps on OCaml</a> </li>
+      </ul>
+    </div>
 
     <div class="legend">
       <p>
         Legend: 
         <span class="inTesting">in testing</span>,
         <span class="inUnstable">in unstable</span>,
-	<span class="inExperimental">in experimental</span>. <br />
-	<small> <strong>Note:</strong> the table below looks at packages along
+        <span class="inExperimental">in experimental</span>,
+	<span class="inIncoming">in incoming</span>.
+      </p>
+      <p>
+	<small> <strong>Note:</strong> the tables below looks at packages along
 	  the axis of the corresponding OCaml version; this is for the sake of
 	  monitoring transitions between binary-incompatible OCaml versions.
 	  For each OCaml version and for each package in the archive, only the
@@ -32,18 +40,20 @@
       </p>
     </div>
 
+    <h3><a name="runtime" />Packages with Runtime Dependencies on OCaml</h3>
+
     <div class="status">
       <table>
         <thead>
           <tr>
-            <th>Package</th>
-            <th py:for="version in ocaml_versions">
-              OCaml <span class="version" py:content="version">x.y.z</span>
+            <th>Source Package</th>
+            <th py:for="version in ocaml_versions['bin']">
+              <span class="version" py:content="version">x.y.z</span>
             </th>
           </tr>
         </thead>
         <tbody>
-	  <tr py:for="(src, ocaml_versions) in packages"
+	  <tr py:for="(src, ocaml_versions) in packages['bin']"
 	      py:choose="">
 	    <td>
 	      <a href="http://packages.qa.debian.org/${src}"><span
@@ -61,6 +71,57 @@
 	      </td>
 	      <td py:when="versions.has_key('experimental')" class="inExperimental">
 		<span py:content="versions['experimental']">x.y.z (experimental)</span>
+	      </td>
+	      <td py:when="versions.has_key('incoming')" class="inIncoming">
+		<span py:content="versions['incoming']">x.y.z (incoming)</span>
+	      </td>
+	      <td py:otherwise="" class="error">(?)</td>
+	    </py:for>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+
+    <h3><a name="buildtime" />Packages with Build-Time (only) Dependencies on OCaml</h3>
+
+    <p> <small> <strong>Note:</strong> in this table the OCaml version can only
+	be guessed. Each package reported below has a <tt>&gt;=</tt> build
+	dependency on OCaml. The version number after the greater or equal sign
+	is considered here, so it is possible that the package has been already
+	rebuilt against a greater version of OCaml. </small> </p>
+
+    <div class="status">
+      <table>
+        <thead>
+          <tr>
+            <th>Source Package</th>
+            <th py:for="version in ocaml_versions['src']">
+              <span class="version" py:content="version">x.y.z</span>
+            </th>
+          </tr>
+        </thead>
+        <tbody>
+	  <tr py:for="(src, ocaml_versions) in packages['src']"
+	      py:choose="">
+	    <td>
+	      <a href="http://packages.qa.debian.org/${src}"><span
+		  class="package" py:content="src">pkg</span></a>
+	    </td>
+	    <py:for each="versions in ocaml_versions" py:choose="">
+	      <td py:when="versions is None" class="none"></td>
+	      <td py:when="versions.has_key('testing')" class="inTesting">
+		<span py:content="versions['testing']">x.y.z (testing)</span>
+	      </td>
+	      <td py:when="versions.has_key('unstable')" class="inUnstable">
+		<span py:content="versions['unstable']">x.y.z (unstable)</span>
+		<br />
+		<small>[<a href="http://bjorn.haxx.se/debian/testing.pl?package=${src}">excuses</a>]</small>
+	      </td>
+	      <td py:when="versions.has_key('experimental')" class="inExperimental">
+		<span py:content="versions['experimental']">x.y.z (experimental)</span>
+	      </td>
+	      <td py:when="versions.has_key('incoming')" class="inIncoming">
+		<span py:content="versions['incoming']">x.y.z (incoming)</span>
 	      </td>
 	      <td py:otherwise="" class="error">(?)</td>
 	    </py:for>

Modified: trunk/tools/ocaml-debian-status/debian-ocaml-status.py
URL: http://svn.debian.org/wsvn/trunk/tools/ocaml-debian-status/debian-ocaml-status.py?rev=4037&op=diff
==============================================================================
--- trunk/tools/ocaml-debian-status/debian-ocaml-status.py (original)
+++ trunk/tools/ocaml-debian-status/debian-ocaml-status.py Sun Jul 15 17:25:04 2007
@@ -19,9 +19,11 @@
 import sys
 
 from debian_bundle import debian_support
+from debian_bundle.debian_support import version_compare
 from genshi.template import TemplateLoader
 
-ocaml_dep_RE = re.compile(r'\bocaml(-nox)?\b')
+ocaml_dep_RE = \
+    re.compile(r'\bocaml(-nox)?\b(\s*\(\s*>=\s*(?P<version>\d+(\.\d+)*)\s*\))?')
 ocaml_virtdep_RE = re.compile(r'\bocaml(-nox)?-(?P<version>\d+(\.\d+)*)\b')
 
 def patch_pkg_dict(entry):
@@ -55,18 +57,27 @@
     """Given a list of Sources files (encoded as PackageFile objects), yields
     all the "relevant" source package names.
     
-    'sources' arg is a PackageFile object built from a 'Sources' file."""
+    The actual yielded value is a tuple <source_name, source_version,
+    ocaml_build_dep_version>.  ocaml_build_dep_version might be None. 'sources'
+    arg is a PackageFile object built from a 'Sources' file."""
 
     for src in sources:
         src = patch_pkg_dict(src)
+        bd_match, bdi_match = None, None
+        if src.has_key('build-depends'):
+            bd_match = ocaml_dep_RE.search(src['build-depends'])
+        if src.has_key('build-depends-indep'):
+            bdi_match = ocaml_dep_RE.search(src['build-depends-indep'])
+
         if src['package'] == 'ocaml':
-            yield src['package']
-        elif src.has_key('build-depends') and \
-                ocaml_dep_RE.search(src['build-depends']):
-            yield src['package']
-        elif src.has_key('build-depends-indep') and \
-                ocaml_dep_RE.search(src['build-depends-indep']):
-            yield src['package']
+            yield src['package'], src['version'], None
+        elif bd_match or bdi_match:
+            ocaml_version = None
+            if bd_match and bd_match.groupdict()['version']:
+                ocaml_version = bd_match.groupdict()['version']
+            elif bdi_match and bdi_match.groupdict()['version']:
+                ocaml_version = bdi_match.groupdict()['version']
+            yield src['package'], src['version'], ocaml_version
 
 def eval_status(pkg):
     status = None
@@ -77,25 +88,45 @@
                     match.groupdict()['version'])
     return status
 
-def ocaml_summary(files):
+def add_incoming_info(status):
+    # TODO
+    return status
+
+def ocaml_status(files):
     sources = filter(lambda fname: re.search(r'-Sources\b', fname), files)
     packages = filter(lambda fname: re.search(r'-Packages\b', fname), files)
     distro_of_fname = lambda fname: os.path.basename(fname).split('-')[0]
+
+    def add_status_entry(status, pkg_entry):
+        ocaml_versions, pkg_status = status
+        src_name, src_version, ocaml_version = pkg_entry
+        if not ocaml_version in ocaml_versions:
+            ocaml_versions.append(ocaml_version)
+        if not pkg_status.has_key(src_name):
+            pkg_status[src_name] = {}
+        if not pkg_status[src_name].has_key(ocaml_version):
+            pkg_status[src_name][ocaml_version] = {}
+        distro = distro_of_fname(fname)
+        pkg_status[src_name][ocaml_version][distro] = src_version
+
+    # outcome of the status anlysis (bin dep): <ocaml_versions, pkg_status>
+    # pkg_status is a nested dictionary structure:
+    #   src_name -> (ocaml_version -> (distro -> src_version))
+    bin_status = ([], {})
+    src_status = ([], {})
 
     # STEP 1: find names of source packages we are interested in
     relevant_sources = set()
     for fname in sources:
         f = smart_open(fname)
         srcfile = debian_support.PackageFile('', fileObj=f)
-        relevant_sources = relevant_sources.union(set(grep_sources(srcfile)))
+        for src, src_version, ocaml_version in grep_sources(srcfile):
+            relevant_sources.add(src)
+            if ocaml_version:
+                add_status_entry(src_status, (src, src_version, ocaml_version))
         f.close()
-    #print relevant_sources
 
     # STEP 2: classify packages
-    status = {}
-    ocaml_versions = []
-        # nested dictionary structure:
-        #  src_name -> (ocaml_version -> (distro -> src_version))
     for fname in packages:
         f = smart_open(fname)
         pkgfile = debian_support.PackageFile('', fileObj=f)
@@ -104,46 +135,59 @@
             if not pkg.has_key('source'):
                 pkg['source'] = pkg['package']
             if normalize_src(pkg['source']) in relevant_sources:
-                pkg_status = eval_status(pkg)
-                if pkg_status:
-                    src_name, src_version, ocaml_version = pkg_status
-                    if not ocaml_version in ocaml_versions:
-                        ocaml_versions.append(ocaml_version)
-                    if not status.has_key(src_name):
-                        status[src_name] = {}
-                    if not status[src_name].has_key(ocaml_version):
-                        status[src_name][ocaml_version] = {}
-                    distro = distro_of_fname(fname)
-                    status[src_name][ocaml_version][distro] = src_version
+                pkg_entry = eval_status(pkg)
+                if pkg_entry:
+                    add_status_entry(bin_status, pkg_entry)
         f.close()
 
-    return status, ocaml_versions
+    # STEP 3: add guesses from incoming
+    add_incoming_info(bin_status)   # dummy implementation ATM ...
 
-def render_status(status, domain):
-    domain.sort(debian_support.version_compare)
+    # STEP 4: ensure the src_status contains only entries of packages with no
+    # runtime dep on ocaml
+    for src_name in bin_status[1]:
+        if src_status[1].has_key(src_name):
+            del src_status[1][src_name]
+    survived_versions = []
+    for versions in src_status[1].values():
+        survived_versions.extend(versions.keys())
+    src_status = list(set(survived_versions)), src_status[1]
 
-    pkg_rows = []
-    for src_name in status.iterkeys():
-        versions = status[src_name]
-        cells = []
-        for ocaml_version in domain:
-            if not versions.has_key(ocaml_version):
-                cells.append(None)
-            else:
-                cells.append(versions[ocaml_version])
-        pkg_rows.append((src_name, cells))
-    pkg_rows.sort(lambda (s1,c1),(s2,c2): cmp(s1, s2))
+    return {'bin': bin_status, 'src': src_status}
+
+def render_status(status):
+
+    def expand_cells(status):
+        status[0].sort(version_compare)
+        pkg_rows = []
+        for src_name in status[1].iterkeys():
+            versions = status[1][src_name]
+            cells = []
+            for ocaml_version in status[0]:
+                if not versions.has_key(ocaml_version):
+                    cells.append(None)
+                else:
+                    cells.append(versions[ocaml_version])
+            pkg_rows.append((src_name, cells))
+        pkg_rows.sort(lambda (s1,c1),(s2,c2): cmp(s1, s2))
+
+        return pkg_rows, status[0]
+
+    bin_rows, bin_versions = expand_cells(status['bin'])
+    src_rows, src_versions = expand_cells(status['src'])
+    packages = {'bin': bin_rows, 'src': src_rows}
+    ocaml_versions = {'bin': bin_versions, 'src': src_versions}
 
     loader = TemplateLoader(['.'])
     tmpl = loader.load('debian-ocaml-status.genshi')
-    stream = tmpl.generate(packages=pkg_rows, ocaml_versions=domain,
+    stream = tmpl.generate(packages=packages, ocaml_versions=ocaml_versions,
             timestamp=datetime.datetime.now())
 
     return stream
 
 if __name__ == '__main__':
-    status, domain = ocaml_summary(sys.argv[1:])
-    out = render_status(status, domain)
+    status = ocaml_status(sys.argv[1:])
+    out = render_status(status)
     for chunk in out.serialize():
         sys.stdout.write(chunk)
 

Modified: trunk/tools/ocaml-debian-status/ocaml-status.css
URL: http://svn.debian.org/wsvn/trunk/tools/ocaml-debian-status/ocaml-status.css?rev=4037&op=diff
==============================================================================
--- trunk/tools/ocaml-debian-status/ocaml-status.css (original)
+++ trunk/tools/ocaml-debian-status/ocaml-status.css Sun Jul 15 17:25:04 2007
@@ -24,15 +24,33 @@
 }
 
 .inTesting {
+  background: #89f;
+}
+.inTesting:after {
+  content: " [t]";
+}
+.inUnstable {
   background: #2f2;
 }
-.inUnstable {
+.inUnstable:after {
+  content: " [u]";
+}
+.inExperimental {
   background: #8f8;
 }
-.inExperimental {
+.inExperimental:after {
+  content: " [e]";
+}
+.inIncoming {
   background: #cfc;
 }
+.inIncoming:after {
+  content: " [i]";
+}
 .version {
+}
+div.status th span.version:before {
+  content: "v";
 }
 td {
   border-style: solid;




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