Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement patch per packages

This should fix #33
  • Loading branch information...
commit 9a63490942da94b41456e3c82f48cb2830c8bb3e 1 parent 17e59bf
@samoht samoht authored
Showing with 31 additions and 15 deletions.
  1. +14 −8 src/client.ml
  2. +8 −6 src/opamFile.ml
  3. +6 −0 src/opamFile.mli
  4. +3 −1 src/run.ml
View
22 src/client.ml
@@ -727,8 +727,8 @@ let substitute_commands t c =
List.map (substitute_command t) c
let rec eval_filter t = function
- | Bool b -> string_of_bool b
- | String s -> s
+ | Bool b -> string_of_bool b
+ | String s -> substitute_string t s
| Op(e,s,f) ->
(* We are supposed to compare version strings *)
let s = match s with
@@ -1183,11 +1183,6 @@ let get_archive t nv =
None in
with_repo t nv aux
-let get_files t nv =
- let aux repo_p _ =
- Path.R.available_files repo_p nv in
- with_repo t nv aux
-
let extract_package t nv =
log "extract_package: %s" (NV.to_string nv);
let p_build = Path.C.build t.compiler nv in
@@ -1220,7 +1215,7 @@ let proceed_todelete ~rm_build t nv =
let opam = OpamFile.OPAM.read opam_f in
let remove = substitute_commands t (OpamFile.OPAM.remove opam) in
match filter_commands t remove with
-(* | [] -> () *)
+ | [] -> ()
| remove ->
let p_build = Path.C.build t.compiler nv in
(* We try to run the remove scripts in the folder where it was extracted
@@ -1400,6 +1395,17 @@ let proceed_tochange t nv_old nv =
let env_f = Path.C.build_env t.compiler nv in
OpamFile.Env.write env_f env.new_env;
+ (* Apply the patches *)
+ let patches = OpamFile.OPAM.patches opam in
+ List.iter (fun (base, filter) ->
+ with_repo t nv (fun repo _ ->
+ let root = Path.R.files repo nv in
+ let patch = root // Basename.to_string base in
+ if eval_filter t filter then (
+ Globals.msg "Applying %s\n" (Basename.to_string base);
+ Filename.patch patch p_build))
+ ) patches;
+
p_build in
(* Call the build script and copy the output files *)
View
14 src/opamFile.ml
@@ -504,8 +504,8 @@ module OPAM = struct
conflicts : and_formula;
libraries : section list;
syntax : section list;
- patches : filename list;
- files : filename list;
+ patches : (basename * filter option) list;
+ files : (basename * filter option) list;
others : (string * value) list;
ocaml_version: ocaml_constraint option;
}
@@ -636,6 +636,7 @@ module OPAM = struct
p
let to_string filename t =
+ let make_file = make_option (Basename.to_string |> make_string) make_filter in
let s = {
filename = Filename.to_string filename;
contents = [
@@ -652,8 +653,8 @@ module OPAM = struct
Variable (s_conflicts, make_and_formula t.conflicts);
Variable (s_libraries, make_list (Section.to_string |> make_string) t.libraries);
Variable (s_syntax, make_list (Section.to_string |> make_string) t.syntax);
- Variable (s_files, make_list (Filename.to_string |> make_string) t.files);
- Variable (s_patches, make_list (Filename.to_string |> make_string) t.patches);
+ Variable (s_files, make_list make_file t.files);
+ Variable (s_patches, make_list make_file t.patches);
] @ (
match t.ocaml_version with
| None -> []
@@ -711,8 +712,9 @@ module OPAM = struct
let libraries = assoc_list s s_libraries (parse_list (parse_string |> Section.of_string)) in
let syntax = assoc_list s s_syntax (parse_list (parse_string |> Section.of_string)) in
let ocaml_version = assoc_option s s_ocaml_version parse_constraint in
- let patches = assoc_list s s_patches (parse_list (parse_string |> Filename.raw)) in
- let files = assoc_list s s_files (parse_list (parse_string |> Filename.raw)) in
+ let parse_file = parse_option (parse_string |> Basename.of_string) parse_filter in
+ let patches = assoc_list s s_patches (parse_list parse_file) in
+ let files = assoc_list s s_files (parse_list parse_file) in
let others =
Utils.filter_map (function
| Variable (x,v) -> if List.mem x useful_fields then None else Some (x,v)
View
6 src/opamFile.mli
@@ -128,6 +128,12 @@ module OPAM: sig
(** deptopts (optional dependencies) string *)
val s_depopts: string
+ (** Files *)
+ val files: t -> (basename * filter option) list
+
+ (** Patches *)
+ val patches: t -> (basename * filter option) list
+
(** Construct as [depends] *)
val with_depends : t -> cnf_formula -> t
View
4 src/run.ml
@@ -447,4 +447,6 @@ let download ~filename:src ~dirname:dst =
dst_file
let patch p =
- command ["patch"; "-p0"; "-i"; p]
+ try command ["patch"; "-p1"; "-i"; p]
+ with e ->
+ command ["patch"; "-p0"; "-i"; p]
Please sign in to comment.
Something went wrong with that request. Please try again.