Skip to content

Commit

Permalink
Allow remove and build to be a single list (for a single command) ar …
Browse files Browse the repository at this point in the history
…a list of string list (for a list of commands)
  • Loading branch information
samoht committed Jun 25, 2012
1 parent 7f2bfb1 commit 7d2b7a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/client.ml
Expand Up @@ -616,7 +616,7 @@ let proceed_todelete t nv =

(* Run the remove script *)
let opam = File.OPAM.read (Path.G.opam t.global nv) in
let remove = List.map (substitute_string t) (File.OPAM.remove opam) in
let remove = List.map (List.map (substitute_string t)) (File.OPAM.remove opam) in
let root_remove =
let p_build = Path.C.build t.compiler nv in
if Dirname.exists p_build then
Expand All @@ -626,7 +626,7 @@ let proceed_todelete t nv =
Path.G.root t.global in
(* We try to run the remove scripts in the folder where it was extracted
If it does not exist, we don't really care. *)
let err = Dirname.exec ~add_to_path:[Path.C.bin t.compiler] root_remove [remove] in
let err = Dirname.exec ~add_to_path:[Path.C.bin t.compiler] root_remove remove in
if err <> 0 then
Globals.error_and_exit "Cannot uninstall %s" (NV.to_string nv);

Expand Down
13 changes: 8 additions & 5 deletions src/file.ml
Expand Up @@ -325,7 +325,7 @@ module OPAM = struct
maintainer : string;
substs : basename list;
build : string list list;
remove : string list;
remove : string list list;
depends : Debian.Format822.vpkgformula;
depopts : Debian.Format822.vpkgformula;
conflicts : Debian.Format822.vpkglist;
Expand Down Expand Up @@ -449,7 +449,7 @@ module OPAM = struct
Variable (s_maintainer, String t.maintainer);
Variable (s_substs, make_list (Basename.to_string |> make_string) t.substs);
Variable (s_build, make_list (make_list make_string) t.build);
Variable (s_remove, make_list make_string t.remove);
Variable (s_remove, make_list (make_list make_string) t.remove);
Variable (s_depends, make_cnf_formula t.depends);
Variable (s_depopts, make_cnf_formula t.depopts);
Variable (s_conflicts, make_and_formula t.conflicts);
Expand All @@ -476,14 +476,17 @@ module OPAM = struct
let package = get_section_by_kind s.contents "package" in
let name = N.of_string package.File_format.name in
let s = package.items in
let parse_commands = parse_or [
"list", (fun x -> [parse_list parse_command x]);
"list-list", parse_list (parse_list parse_command);
] in
let version = assoc s s_version (parse_string |> V.of_string) in
let maintainer = assoc s s_maintainer parse_string in
let substs =
assoc_list s s_substs (parse_list (parse_string |> Basename.of_string)) in
let build =
assoc_default Globals.default_build_command
s s_build (parse_list (parse_list parse_command)) in
let remove = assoc_list s s_remove (parse_list parse_command) in
assoc_default Globals.default_build_command s s_build parse_commands in
let remove = assoc_list s s_remove parse_commands in
let depends = assoc_list s s_depends parse_cnf_formula in
let depopts = assoc_list s s_depopts parse_cnf_formula in
let conflicts = assoc_list s s_conflicts parse_and_formula in
Expand Down
4 changes: 2 additions & 2 deletions src/file.mli
Expand Up @@ -96,7 +96,7 @@ module OPAM: sig
val build: t -> string list list

(** Command to run to remove the package *)
val remove: t -> string list
val remove: t -> string list list

(** Package dependencies *)
val depends: t -> Debian.Format822.vpkgformula
Expand Down Expand Up @@ -126,7 +126,7 @@ module OPAM: sig
val with_build: t -> string list list -> t

(** Construct as [remove] *)
val with_remove : t -> string list -> t
val with_remove : t -> string list list -> t
end

(** Package descriptions: [$opam/descr/] *)
Expand Down

0 comments on commit 7d2b7a9

Please sign in to comment.