[Pkg-ocaml-maint-commits] [SCM] oasis2debian project branch, master, updated. a85c25dc2305eccf3507acf59d7cbbc09b4201dc
Sylvain Le Gall
gildor at debian.org
Wed Feb 9 15:58:52 UTC 2011
The following commit has been merged in the master branch:
commit a85c25dc2305eccf3507acf59d7cbbc09b4201dc
Author: Sylvain Le Gall <gildor at debian.org>
Date: Wed Feb 9 15:58:21 2011 +0000
Compute differences in build depends for upgrade
diff --git a/src/ActUpdate.ml b/src/ActUpdate.ml
index bdb93fa..ac5d3c0 100644
--- a/src/ActUpdate.ml
+++ b/src/ActUpdate.ml
@@ -2,22 +2,51 @@
(** Update action
*)
+open OASISMessage
+open OASISTypes
open DebianFormats
open Common
+module S = BuildDepends.SetDepends
+
+let diff_depends ~ctxt lst1 lst2 =
+ let to_set lst =
+ List.fold_left (fun st e -> S.add e st) S.empty lst
+ in
+ (* Compute dependency added/removed *)
+ let st1 = to_set lst1 in
+ let st2 = to_set lst2 in
+ let adds = S.diff st2 st1 in
+ let dels = S.diff st1 st2 in
+
+ (* TODO: compute dependency upgraded/downgraded *)
+ S.iter
+ (fun b ->
+ warning ~ctxt
+ "New dependency: %s"
+ (BuildDepends.to_string b))
+ adds;
+ S.iter
+ (fun b ->
+ warning ~ctxt
+ "Dependency removed: %s"
+ (BuildDepends.to_string b))
+ dels
+
let run ~ctxt args =
let t =
Load.load ~ctxt args
in
- let ctl_source, ctl_binaries =
+ (* TODO: move this to debian-formats *)
+ let with_fn fn f =
let chn =
- open_in "debian/control"
+ open_in fn
in
try
let res =
- Control.parse (IO.input_channel chn)
+ f (IO.input_channel chn)
in
close_in chn;
res
@@ -25,14 +54,43 @@ let run ~ctxt args =
close_in chn;
raise e
in
+
+ let ctl_source, ctl_binaries =
+ with_fn "debian/control" Control.parse
+ in
+
+ let changelog =
+ with_fn "debian/changelog" Changelog.head
+ in
+
let ctl_build_depends =
List.map
(function
- | ((pkg, None), _) :: _ -> pkg
- | ((pkg, Some (op, ver)), _) :: _ -> pkg^" ("^op^" "^ver^")"
- | [] -> "<unknown>")
+ | ((pkg, None), _) :: _ ->
+ pkg, None, `All
+ | ((pkg, Some (op, ver)), _) :: _ ->
+ pkg,
+ Some (OASISVersion.comparator_of_string (op^" "^ver)),
+ `All
+ | [] ->
+ invalid_arg "ctl_build_depends")
ctl_source.Control.build_depends
in
- prerr_endline ("oasis: "^(String.concat ", " t.build_depends));
- prerr_endline ("control: "^(String.concat ", " ctl_build_depends))
+ let () =
+ diff_depends ~ctxt ctl_build_depends t.build_depends
+ in
+
+ let () =
+ let oasis_version =
+ OASISVersion.string_of_version t.pkg_generic.version
+ in
+ (* TODO: take into account EPOCH et al *)
+ if oasis_version <> changelog.Changelog.version then
+ warning ~ctxt
+ "New version '%s', run 'dch -v %s-1 \"New upstream release\"'"
+ oasis_version oasis_version
+ in
+
+ ()
+
diff --git a/src/BuildDepends.ml b/src/BuildDepends.ml
index 05fe4a9..b81f2fc 100644
--- a/src/BuildDepends.ml
+++ b/src/BuildDepends.ml
@@ -75,7 +75,7 @@ let add_depends ?(arch_spec=`All) nm ver_opt st =
SetDepends.add (nm, ver_opt, arch_spec) st
-let string_of_depends ~ctxt (nm, ver_opt, arch_spec) =
+let to_string (nm, ver_opt, arch_spec) =
let arch_str =
Arch.Spec.to_string_build_depends arch_spec
in
@@ -90,10 +90,11 @@ let string_of_depends ~ctxt (nm, ver_opt, arch_spec) =
| VEqual _ ->
()
| VOr _ | VAnd _ ->
- error ~ctxt
- "Version constraint '%s' on build depends '%s' is too complex"
- (string_of_comparator v)
- nm
+ failwith
+ (Printf.sprintf
+ "Version constraint '%s' on build depends '%s' is too complex"
+ (string_of_comparator v)
+ nm)
end;
Printf.sprintf " (%s)"
(string_of_comparator v)
@@ -429,9 +430,7 @@ let get ~ctxt pkg =
lst
in
- (* Translate depends into string *)
SetDepends.fold
- (fun dep lst ->
- string_of_depends ~ctxt dep :: lst)
+ (fun dep lst -> dep :: lst)
debian_depends
diff --git a/src/Common.ml b/src/Common.ml
index 4bb60de..8354ccf 100644
--- a/src/Common.ml
+++ b/src/Common.ml
@@ -30,9 +30,12 @@ type deb_pkg =
arch: string;
}
+type build_depend =
+ string * OASISVersion.comparator option * [ `All | `Only of Arch.t * Arch.t list ]
+
type t =
{
- build_depends: string list;
+ build_depends: build_depend list;
description: string;
homepage: string;
uploader: string;
diff --git a/src/Control.ml b/src/Control.ml
index c54e9b9..a2a125f 100644
--- a/src/Control.ml
+++ b/src/Control.ml
@@ -29,10 +29,10 @@ let create t =
in
let build_depends =
- match t.build_depends with
- | [] -> ""
- | lst ->
- String.concat sep t.build_depends
+ String.concat sep
+ (List.map
+ BuildDepends.to_string
+ t.build_depends)
in
let src_name =
--
oasis2debian project
More information about the Pkg-ocaml-maint-commits
mailing list