The following commit has been merged in the master branch:
commit e3c5eeff1d5cb819eaa91a331451ad213cf0200d
Author: Ralf Treinen <[email protected]>
Date:   Tue Aug 18 23:33:37 2009 +0200

    sync distcheck with upstream (implements src:p)
    update manpage with src:p notation

diff --git a/debian/changelog b/debian/changelog
index cb8f5dd..fb2a0d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,11 @@ pkglab (1.4.2-5) unstable; urgency=low
     Breaks is treated like Conflicts.
   * Do not use xml entities when printing version constraints unless 
     xml mode has been required (closes: #539211).
+  * Packages to be checked can now be listed in the form "src:p",
+    which will be expanded to the list of all packages that stem
+    from source package p (closes:  #516587).
 
- -- Ralf Treinen <[email protected]>  Mon, 17 Aug 2009 21:18:58 +0200
+ -- Ralf Treinen <[email protected]>  Tue, 18 Aug 2009 23:26:13 +0200
 
 pkglab (1.4.2-4) unstable; urgency=low
 
diff --git a/debian/manpages/edos-debcheck.1 b/debian/manpages/edos-debcheck.1
index 705f184..d8c93ff 100644
--- a/debian/manpages/edos-debcheck.1
+++ b/debian/manpages/edos-debcheck.1
@@ -1,4 +1,4 @@
-.TH EDOS-DEBCHECK 1 2006-05-20 EDOS
+.TH EDOS-DEBCHECK 1 2009-08-18 EDOS
 
 .SH NAME
 Edos-debcheck \- Check satisfiability of Debian package dependencies
@@ -65,6 +65,9 @@ available version). This means that if a package does not 
exist in
 the input pool then the test passes (since all available versions are
 in that case installable). However, a warning is issued in case a package
 mentionend in \fIlist\fR is not available.
+
+In the context of this option, a package of the form src:\fIp\fR expands
+to the list of all packages that stem from the source package \fIp\fR.
 .TP
 .B -quiet
 Supress warnings and progress/timing messages
@@ -98,6 +101,11 @@ distribution described by the file Packages:
 
   edos-debcheck -explain -checkonly xemacs21,debhelper < Packages
 
+Check whether the package bibtex2html, and all binary packages stemming
+from the ocaml source package, are installable
+
+ edos-debcheck -explain -checkonly bibtex2html,src:ocaml < Packages
+
 
 .SH AUTHOR
 Edos-debcheck has been written by Jerome Vouillon for the EDOS project. This
diff --git a/distcheck/common.ml b/distcheck/common.ml
index dfa5baa..544c2cc 100644
--- a/distcheck/common.ml
+++ b/distcheck/common.ml
@@ -13,18 +13,22 @@ and show_failures = ref true
 and explain_results = ref false
 and quiet = ref false
 and output_xml= ref false
-and dist_type = ref `Debian
-and source_added = ref false
-and pkgs_to_check_only = ref []
-  (* indicates that some packages that were asked to be checked are *)
-  (* not available. *)
-and packages_are_missing = ref false;;
+and dist_type = ref `Debian;;
+let pkgs_to_check = ref Package_set.empty;;
+let units_to_check = ref []         (* units given by command line argument *)
+and units_to_check_set = ref false  (* indicates whether units_to check set on 
command line *)
+and packages_are_missing = ref false;; (* indicates that some packages that 
were asked to be *)
+                                       (* checked are not available. *)
+let checklist = ref [];;
 let rpm_synthesis = ref false;;
 
 let db = create_database ();;
 let architecture_index = get_architecture_index db;;
 let unit_index = get_unit_index db;;
 let package_index = get_package_index db;;
+let version_index = get_version_index db;;
+let release_index = get_release_index db;;
+let source_index = get_source_index db;;
 let not_to_check = ref Package_set.empty;;
 
 let add_source add_to_check s =
@@ -33,7 +37,6 @@ let merge x = if !quiet then
 else
        Waterway.merge db x in
 begin
-  source_added := true;
        (* This is not very effective, but hey... *)
        let pkgs_old = Functions.packages db in
        (let s2 = if s = "-" then
@@ -59,8 +62,33 @@ begin
                not_to_check := Package_set.union !not_to_check new_packages    
 end;;
 
+let add_pkg_to_check s =
+begin
+  try
+    let eq = String.index s '=' in 
+    let u = String.sub s 0 eq in
+    let unit_id = Unit_index.search unit_index u in
+    let v = String.sub s (eq+1) (String.length s-eq-1) in
+    let (v_id, r_id) = 
+    try
+      let dash = String.rindex v '-' in
+      let rv = String.sub v 0 dash
+      and r = String.sub v (dash+1) (String.length v-dash-1) in
+      (Version_index.search version_index rv,
+      Release_index.search release_index (Some r))
+    with Not_found -> (Version_index.search version_index v, 
+      Release_index.search release_index None) in
+    let ps = Functions.unit_id_to_package_set db unit_id in
+    Package_set.iter (fun p_id ->
+      let pkg = Functions.get_package_from_id db p_id in
+      if pkg.pk_version = (v_id, r_id) then
+        pkgs_to_check := Package_set.add p_id !pkgs_to_check
+    ) ps;
+  with Not_found -> ()
+end;;
+
 let unit_name_of u_id =
-  Unit_index.find unit_index u_id;;
+       Unit_index.find unit_index u_id;;
 
 let pkg_name_of p_id = 
        let (_, pkg) = Package_index.find package_index p_id in
@@ -76,6 +104,11 @@ let myunit_name_of p_id =
   let (_, pkg) = Package_index.find package_index p_id in
     Unit_index.find unit_index pkg.pk_unit 
 
+(* gives the name of the source of a package *)
+let source_name_of p_id = 
+  let (_, pkg) = Package_index.find package_index p_id in
+    fst (Source_index.find source_index pkg.pk_source)
+
 let pkg_xml_of p_id =
        let (_, pkg) = Package_index.find package_index p_id in
        let unit_name = Unit_index.find unit_index pkg.pk_unit 
@@ -112,35 +145,7 @@ let spec_string s =
        | Sel_GT v -> Printf.sprintf " (> %s)"  (version_string v) 
 ;;
 
-(* the check will be restricted to the packages whose names are in pkgs_only, 
*)
-(* in case pkgs_to_check_set is true *)
-let check pkgs_only =
-let pkgs_to_check =
-  if pkgs_only = [] 
-  then ref (Package_set.diff (Functions.packages db) !not_to_check)
-  else
-    let filtered_packages =
-      (Package_set.filter
-        (fun p -> List.mem  (myunit_name_of p) pkgs_only)
-        (Functions.packages db))
-    in let found_package_names =
-       List.map myunit_name_of (Package_set.elements filtered_packages)
-    in let missing_package_names =   
-       List.filter
-         (fun pn -> not (List.mem pn found_package_names))
-         pkgs_only
-    in if missing_package_names <> []
-      then begin
-       packages_are_missing := true;
-       prerr_string "Warning: some packages not found:";
-       List.iter
-         (fun pn -> prerr_char ' '; prerr_string pn) 
-         missing_package_names;
-       prerr_newline ();
-       flush stderr
-      end;
-      ref filtered_packages
-in
+let check () =
 let result_ht = Hashtbl.create (Package_set.cardinal !pkgs_to_check) in
 let progress =
        if !quiet then Progress.dummy
@@ -158,6 +163,7 @@ begin
 end;;
 
 let show_results ht =
+  (* returns true when all checks successful, otherwise false *)
 begin
        if !output_xml then print_endline "<results>";
        Hashtbl.iter  
@@ -234,7 +240,7 @@ begin
                end
        ) ht;
        if !output_xml then print_endline "</results>";
-       (* we return true when all checks have been successful *)
+       (* we return true when all checks have been successful, otherwise false 
*)
        Hashtbl.fold
          (fun _ (result,_) accumulator -> result && accumulator)
          ht
@@ -245,12 +251,13 @@ let speclist = ref [
        ("-explain", Set explain_results, "Explain the results");
        ("-failures", Clear show_successes, "Only show failures");
        ("-successes", Clear show_failures, "Only show successes");
-       ("-base", String (add_source false), "Additional binary package control 
file providing packages that are not checked but used for resolving 
dependencies");
-       ("-checkonly", String (fun s -> pkgs_to_check_only := Util.split_at ',' 
s),
-        "Check only these packages");
+       ("-base FILE", String (add_source false), "Additional binary package 
control file providing packages that are not checked but used for resolving 
dependencies");
+       ("-add-source FILE", String (add_source true), "Additional binary 
package control file providing packages that ARE checked and used for resolving 
dependencies");
+       ("-checkonly", 
+         String (fun s -> units_to_check := Util.split_at ',' s; 
units_to_check_set := true),
+         "Check only these packages");
        ("-quiet", Set quiet, "Do not emit warnings nor progress/timing 
information");
        ("-xml", Set output_xml, "Output results in XML format");
-       ("-", Unit (fun () -> add_source true "-"), "");
 ];;    
 
 let _ =
@@ -264,8 +271,49 @@ let _ =
        else if Util.string_contains Sys.argv.(0) "pscheck" then
                dist_type := `Pkgsrc
        else (Printf.eprintf "Warning: unknown name '%s', behaving like 
debcheck\n%!" Sys.argv.(0); dist_type := `Debian);
-       Arg.parse !speclist (add_source true) "Distcheck v1.4.1";
-  if not !source_added then add_source true "-";
-  exit (if (show_results (check !pkgs_to_check_only))
-       then if !packages_are_missing then 2 else 0
-       else 1);;
+       Arg.parse !speclist (fun s -> checklist := s::!checklist) "Distcheck 
$Revision$";
+  add_source true "-";
+  if !units_to_check_set
+  then
+    let rec separate_source_packages = function
+       [] -> [],[]
+      | h::r ->
+         let br,sr = separate_source_packages r 
+         and h_length = String.length h
+         in if h_length >= 5 && String.sub h 0 4 = "src:"
+           then br,(String.sub h 4 (h_length-4))::sr
+           else h::br,sr
+    in let bin_units_to_check, src_units_to_check = separate_source_packages 
!units_to_check
+    in let filtered_packages =
+      (Package_set.filter
+        (fun p -> List.mem  (myunit_name_of p) bin_units_to_check || List.mem 
(source_name_of p) src_units_to_check)
+        (Functions.packages db))
+    in let found_package_names =
+       List.map myunit_name_of (Package_set.elements filtered_packages)
+    in let missing_package_names =   
+       List.filter
+         (fun pn -> not (List.mem pn found_package_names))
+         bin_units_to_check
+    in if missing_package_names <> []
+      then begin
+       packages_are_missing := true;
+       prerr_string "Warning: some packages not found:";
+       List.iter
+         (fun pn -> prerr_char ' '; prerr_string pn) 
+         missing_package_names;
+       prerr_newline ();
+       flush stderr
+      end;
+      pkgs_to_check := filtered_packages
+  else begin
+    List.iter add_pkg_to_check !checklist;
+    if Package_set.is_empty !pkgs_to_check then
+      pkgs_to_check := Package_set.diff (Functions.packages db) !not_to_check;
+  end;
+  exit (if (show_results (check ()))
+       then 
+         if !packages_are_missing
+         then 2 (* some packages that were asked to be checked are missing *)
+         else 0 (* all checks successful *)
+       else 1 (* some package are not installable *)
+);;

-- 
pkglab packaging

_______________________________________________
Pkg-ocaml-maint-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to