[Pkg-ocaml-maint-commits] r6296 - /trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll

glondu-guest at users.alioth.debian.org glondu-guest at users.alioth.debian.org
Sun Mar 1 18:59:40 UTC 2009


Author: glondu-guest
Date: Sun Mar  1 18:59:40 2009
New Revision: 6296

URL: http://svn.debian.org/wsvn/?sc=1&rev=6296
Log:
Generate also the binNMU request that would get everything green

 * The arch:all packages are not handled yet
 * Use https://buildd.debian.org/pkg.cgi?pkg=%s for buildd links
   (the other one doesn't show binNMUs)


Modified:
    trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll

Modified: trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll
URL: http://svn.debian.org/wsvn/trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll?rev=6296&op=diff
==============================================================================
--- trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll (original)
+++ trunk/tools/ocaml_transition_monitor/ocaml_transition_monitor.mll Sun Mar  1 18:59:40 2009
@@ -28,7 +28,6 @@
   module M = Map.Make(String)
 
   open Printf
-  open XHTML.M
 
   type source_package = {
     sname: string;
@@ -102,6 +101,12 @@
     match Unix.close_process_in chan with
       | Unix.WEXITED 0 -> r
       | _ -> failwith "unexpected return of date"
+
+  let list_iteri f xs =
+    let rec aux i = function
+      | [] -> ()
+      | x::xs -> f i x; aux (i+1) xs
+    in aux 0 xs
 }
 
 let name = ['A'-'Z' 'a'-'z' '0'-'9' '-' '.' ':' '~' '+']+
@@ -281,9 +286,6 @@
         progress "\n%!";
         r = 0)
 
-  let a_link href contents =
-    a ~a:[a_href (uri_of_string href)] [pcdata contents]
-
   let get_binary_status pkg =
     match runtime_depends_on_ocaml pkg with
       | None -> Unknown
@@ -304,6 +306,28 @@
             | Up_to_date -> aux Up_to_date xs
             | Unknown -> aux accu xs
     in aux Unknown source.sbins
+
+  let binNMU_regexp = Str.regexp "^\\(.*\\)\\+b\\([0-9]+\\)$"
+
+  let get_binNMU_number_on_arch binaries source =
+    let sver = source.sversion in
+    let sbins = List.fold_left
+      (fun accu x -> try (M.find x binaries)::accu with Not_found -> accu)
+      [] source.sbins
+    in
+    List.fold_left
+      (fun accu pkg ->
+         let bver = pkg.bversion in
+         if Str.string_match binNMU_regexp bver 0 then begin
+           let v = Str.matched_group 1 bver in
+           if v = sver then
+             max accu (int_of_string (Str.matched_group 2 bver))
+           else accu
+         end else accu)
+      0 sbins
+
+  let get_next_binNMU_number xs =
+    succ (List.fold_left max 0 xs)
 
   (**
      @param xs outputs of [get_source_status_on_arch]
@@ -345,101 +369,169 @@
     let dep_graph = get_dep_graph sources src_of_bin_map in
     (* a section is a level in the dependency graph *)
     let sections = topo_split dep_graph in
-    progress "Generating XHTML...%!";
-    let format_package pkg = tr
-      (td
-         ~a:[a_class [(class_of_status (M.find pkg summary_status))^" src"]; a_id pkg]
-         [a
-            ~a:[a_href (uri_of_string ("http://packages.qa.debian.org/"^pkg));
-                a_title
-                  (let deps = S.elements (M.find pkg dep_graph) in
-                   if deps <> [] then
-                     "dependencies: "^(String.concat ", " deps)
-                   else
-                     "no dependencies");
-               ]
-            [pcdata pkg];
-          small [
-            pcdata " [ ";
-            a_link ("http://buildd.debian.org/~luk/status/package.php?p="^pkg) "buildd";
-            pcdata " ] "
-          ];
-          small [
-            pcdata " ( ";
-            a_link
-              (sprintf "http://packages.debian.org/changelogs/pool/main/%c/%s/current/changelog" pkg.[0] pkg)
-              (M.find pkg sources).sversion;
-            pcdata " ) ";
-          ];
-         ])
-      (List.map
-         (fun x ->
-            let x = class_of_status x and xx = string_of_status x
-            in td ~a:[a_class [x]] [small [pcdata xx]])
-         (M.find pkg sources_status))
-    in
-    let format_section section =
-      let thead = tr (th [pcdata "source"]) (List.map (fun arch -> th [small [pcdata arch]]) architectures) in
-      thead::(List.map format_package section)
-    in
-    let summary_contents = List.fold_left
-      (fun accu section -> section at accu)
-      [] (List.rev_map format_section sections)
-    in
-    let summary = match summary_contents with x::xs -> table x xs | _ -> assert false in
-    let page_title = "Monitoring OCaml transition to "^ocaml_version in
     let date = get_rfc2822_date () in
-    let footer = [
-      p [pcdata "Last generated: ";
-         span ~a:[a_class ["timestamp"]] [pcdata date];
-         pcdata " (page currently rebuilt every 6 hours).";
-         br ();
-         pcdata "Contact: ";
-         a_link "mailto:steph at glondu.net" "Stéphane Glondu";
-         pcdata "; the code that generates this page ";
-         a_link src_webbrowse_url "is available";
-         pcdata "."; br ();
-         pcdata "This page has been type-checked by OCaml using ";
-         a_link "http://ocsigen.org/docu/1.1.0/XHTML.M.html" "XHTML.M";
-         pcdata " and should be ";
-         a_link "http://validator.w3.org/check?uri=referer" "XHTML Valid";
-         pcdata "."; br ();
-         pcdata "Kudos: zack and his ";
-         a_link "http://pkg-ocaml-maint.alioth.debian.org/debian-ocaml-status.html" "OCaml Packages Status in Debian";
-         pcdata ", from which I shamelessly copied this page's CSS.";
-        ]] in
-    let html = html ~a:[a_xmlns `W3_org_1999_xhtml]
-      (head (title (pcdata page_title))
-         [link ~a:[a_rel [`Stylesheet]; a_href (uri_of_string (basename^".css"))] ();
-          script ~contenttype:"text/javascript" ~a:[a_src (uri_of_string "http://code.jquery.com/jquery-latest.js")] (pcdata "");
-          script ~contenttype:"text/javascript" ~a:[a_src (uri_of_string (basename^".js"))] (pcdata "");
-	  meta ~content:"text/html;charset=utf-8" ~a:[a_http_equiv "Content-Type"] ();
-         ])
-      (body [h1 [pcdata page_title];
-             div ~a:[a_id "navbar"]
-               [
-                 a_link "http://wiki.debian.org/Teams/OCamlTaskForce" "Home";
-                 pcdata " of the ";
-                 em [pcdata "OCaml Task Force"];
-                 pcdata " on ";
-                 a ~a:[a_href (uri_of_string "http://wiki.debian.org")] [tt [pcdata "wiki.d.o"]];
-                 pcdata ".";
-               ];
-             div
-               [
-                 pcdata "Filter by status: ";
-                 input ~a:[a_input_type `Checkbox; a_checked `Checked; a_id "good"] ();
-                 pcdata "good ";
-                 input ~a:[a_input_type `Checkbox; a_checked `Checked; a_id "bad"] ();
-                 pcdata "bad ";
-                 input ~a:[a_input_type `Checkbox; a_id "unknown"] (); pcdata "unknown";
-                 span ~a:[a_id "count"] [];
-               ];
-             div ~a:[a_class ["status"]] [summary];
-             div ~a:[a_class ["footer"]] footer])
-    in
-    with_out_file (basename^".html")
-      (fun chan -> pretty_print (fun s -> fprintf chan "%s%!" s) html);
+    progress "Generating XHTML summary page...%!";
+
+    let module XHTML = struct
+      open XHTML.M
+
+      let a_link href contents =
+        a ~a:[a_href (uri_of_string href)] [pcdata contents]
+
+      let format_package pkg = tr
+        (td
+           ~a:[a_class [(class_of_status (M.find pkg summary_status))^" src"]; a_id pkg]
+           [a
+              ~a:[a_href (uri_of_string ("http://packages.qa.debian.org/"^pkg));
+                  a_title
+                    (let deps = S.elements (M.find pkg dep_graph) in
+                     if deps <> [] then
+                       "dependencies: "^(String.concat ", " deps)
+                     else
+                       "no dependencies");
+                 ]
+              [pcdata pkg];
+            small [
+              pcdata " [ ";
+              a_link ("https://buildd.debian.org/pkg.cgi?pkg="^pkg) "buildd";
+              pcdata " ] "
+            ];
+            small [
+              pcdata " ( ";
+              a_link
+                (sprintf "http://packages.debian.org/changelogs/pool/main/%c/%s/current/changelog" pkg.[0] pkg)
+                (M.find pkg sources).sversion;
+              pcdata " ) ";
+            ];
+           ])
+        (List.map
+           (fun x ->
+              let x = class_of_status x and xx = string_of_status x
+              in td ~a:[a_class [x]] [small [pcdata xx]])
+           (M.find pkg sources_status))
+
+      let format_section section =
+        let thead = tr (th [pcdata "source"]) (List.map (fun arch -> th [small [pcdata arch]]) architectures) in
+        thead::(List.map format_package section)
+
+      let summary_contents = List.fold_left
+        (fun accu section -> section at accu)
+        [] (List.rev_map format_section sections)
+
+      let summary = match summary_contents with x::xs -> table x xs | _ -> assert false
+      let page_title = "Monitoring OCaml transition to "^ocaml_version
+
+      let footer = [
+        p [pcdata "Last generated: ";
+           span ~a:[a_class ["timestamp"]] [pcdata date];
+           pcdata " (page currently rebuilt every 6 hours).";
+           br ();
+           pcdata "Contact: ";
+           a_link "mailto:steph at glondu.net" "Stéphane Glondu";
+           pcdata "; the code that generates this page ";
+           a_link src_webbrowse_url "is available";
+           pcdata "."; br ();
+           pcdata "This page has been type-checked by OCaml using ";
+           a_link "http://ocsigen.org/docu/1.1.0/XHTML.M.html" "XHTML.M";
+           pcdata " and should be ";
+           a_link "http://validator.w3.org/check?uri=referer" "XHTML Valid";
+           pcdata "."; br ();
+           pcdata "Kudos: zack and his ";
+           a_link "http://pkg-ocaml-maint.alioth.debian.org/debian-ocaml-status.html" "OCaml Packages Status in Debian";
+           pcdata ", from which I shamelessly copied this page's CSS.";
+          ]]
+
+      let html = html ~a:[a_xmlns `W3_org_1999_xhtml]
+        (head (title (pcdata page_title))
+           [link ~a:[a_rel [`Stylesheet]; a_href (uri_of_string (basename^".css"))] ();
+            script ~contenttype:"text/javascript" ~a:[a_src (uri_of_string "http://code.jquery.com/jquery-latest.js")] (pcdata "");
+            script ~contenttype:"text/javascript" ~a:[a_src (uri_of_string (basename^".js"))] (pcdata "");
+	    meta ~content:"text/html;charset=utf-8" ~a:[a_http_equiv "Content-Type"] ();
+           ])
+        (body [h1 [pcdata page_title];
+               div ~a:[a_id "navbar"]
+                 [
+                   a_link "http://wiki.debian.org/Teams/OCamlTaskForce" "Home";
+                   pcdata " of the ";
+                   em [pcdata "OCaml Task Force"];
+                   pcdata " on ";
+                   a ~a:[a_href (uri_of_string "http://wiki.debian.org")] [tt [pcdata "wiki.d.o"]];
+                   pcdata ".";
+                 ];
+               div
+                 [
+                   pcdata "Filter by status: ";
+                   input ~a:[a_input_type `Checkbox; a_checked `Checked; a_id "good"] ();
+                   pcdata "good ";
+                   input ~a:[a_input_type `Checkbox; a_checked `Checked; a_id "bad"] ();
+                   pcdata "bad ";
+                   input ~a:[a_input_type `Checkbox; a_id "unknown"] (); pcdata "unknown";
+                   span ~a:[a_id "count"] [];
+                   br ();
+                   a_link "ocaml_transition_binNMU_request.txt" "BinNMU request";
+                   pcdata " for all bad source packages."
+                 ];
+               div ~a:[a_class ["status"]] [summary];
+               div ~a:[a_class ["footer"]] footer])
+
+      let generate chan = pretty_print (fun s -> fprintf chan "%s%!" s) html
+    end in
+
+    with_out_file (basename^".html") XHTML.generate;
+    progress "\nGenerating binNMU request...%!";
+
+    let module BinNMU = struct
+      let reason = "Recompile with OCaml "^ocaml_version
+
+      let sources_binNMU = M.map
+        (fun pkg -> List.map (fun x -> get_binNMU_number_on_arch x pkg) binaries)
+        sources
+      let summary_binNMU = M.map get_next_binNMU_number sources_binNMU
+
+      let next_version_map = M.map
+        (fun x ->
+           let sver = (M.find x sources).sversion in
+           if M.find x summary_status = Outdated then
+             sprintf "%s+b%d" sver (M.find x summary_binNMU)
+           else sver)
+        src_of_bin_map
+
+      let generate chan =
+        let format_package pkg =
+          let bad_architectures =
+            List.map fst
+              (List.filter (fun (_, status) -> status = Outdated)
+                 (List.combine architectures (M.find pkg sources_status)))
+          in
+          let src = M.find pkg sources in
+          let dep_waits = List.fold_left
+            (fun accu dep ->
+               try
+                 (sprintf "%s dep-wait %s (>= %s)\n" pkg dep (M.find dep next_version_map))::accu
+               with
+                 | Not_found -> accu)
+            [] src.sdeps
+          in
+          fprintf chan "%s_%s, %s, %d, %s\n"
+            pkg
+            src.sversion
+            reason
+            (M.find pkg summary_binNMU)
+            (String.concat " " bad_architectures);
+          List.iter (output_string chan) dep_waits
+        in
+        let format_section n section =
+          let section = List.filter (fun x -> M.find x summary_status = Outdated) section in
+          if section <> [] then begin
+            fprintf chan "\n# Dependency level %d: %d outdated source package(s)\n" n (List.length section);
+            List.iter format_package section;
+          end
+        in
+        fprintf chan "# Automatically generated on %s\n" date;
+        list_iteri format_section sections
+    end in
+
+    with_out_file "ocaml_transition_binNMU_request.txt" BinNMU.generate;
     progress "\n%!"
 
   let _ =




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