Permalink
Browse files

Manually merge #210

  • Loading branch information...
1 parent 3c5f4fc commit f2f9dd71b10c497a986056b19a227ec6112fb1b5 @samoht samoht committed Oct 4, 2012
Showing with 23 additions and 5 deletions.
  1. +2 −0 src/opamFile.ml
  2. +7 −0 src/opamFile.mli
  3. +1 −1 src/opamGlobals.ml.in
  4. +13 −4 src/opamSystem.ml
View
@@ -622,6 +622,8 @@ module OPAM = struct
let with_substs t substs = { t with substs }
let with_ocaml_version t ocaml_version = { t with ocaml_version }
let with_maintainer t maintainer = { t with maintainer }
+ let with_files t files = { t with files }
+ let with_patches t patches = { t with patches }
module D = Debian.Packages
View
@@ -151,6 +151,13 @@ module OPAM: sig
(** Construct as [maintainer] *)
val with_maintainer: t -> string -> t
+
+ (** Construct as [files] *)
+ val with_files: t -> (basename * filter option) list -> t
+
+ (** Construct as [patches] *)
+ val with_patches: t -> (basename * filter option) list -> t
+
end
(** Package descriptions: [$opam/descr/] *)
View
@@ -98,7 +98,7 @@ let os = match Sys.os_type with
| "Cygwin" -> Cygwin
| s -> Other s
-let os_string = match os with
+let string_of_os = match os with
| Darwin -> "darwin"
| Linux -> "linux"
| FreeBSD
View
@@ -446,7 +446,16 @@ let download ~filename:src ~dirname:dst =
);
dst_file
-let patch p =
- try command ["patch"; "-p1"; "-i"; p]
- with e ->
- command ["patch"; "-p0"; "-i"; p]
+let patch =
+ let max_trying = 20 in
+ fun p ->
+ let patch opts n =
+ command ("patch" :: ("-p" ^ string_of_int n) :: "-i" :: p :: opts) in
+ let rec aux n =
+ if n = max_trying then
+ OpamGlobals.error_and_exit "Patching failed, can not determine the '-p' level to patch."
+ else if None = try Some (patch ["--dry-run"] n) with _ -> None then
+ aux (succ n)
+ else
+ patch [] n in
+ aux 0

0 comments on commit f2f9dd7

Please sign in to comment.