Skip to content

Commit

Permalink
Use gpatch on openBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Jul 12, 2018
1 parent 76eb00e commit 12a0f03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/client/opamInitDefaults.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ let eval_variables = [
"OCaml version present on your system independently of opam, if any";
]

let os_filter os =
FOp (FIdent ([], OpamVariable.of_string "os", None), `Eq, FString os)
let os_filter ?(not=false) os =
let op = if not then `Neq else `Eq in
FOp (FIdent ([], OpamVariable.of_string "os", None), op, FString os)

let linux_filter = os_filter "linux"
let macos_filter = os_filter "macos"
let openbsd_filter = os_filter "openbsd"
let not_openbsd_filter = os_filter ~not:true "openbsd"
let sandbox_filter = FOr (linux_filter, macos_filter)

let wrappers ~sandboxing () =
Expand Down Expand Up @@ -95,7 +98,8 @@ let required_tools ~sandboxing () =
Some "A download tool is required, check env variables OPAMCURL or OPAMFETCH",
None;
["diff"], None, None;
["patch"], None, None;
["patch"], None, Some not_openbsd_filter;
["gpatch"], None, Some openbsd_filter;
["tar"], None, None;
["unzip"], None, None;
] @
Expand Down
7 changes: 6 additions & 1 deletion src/core/opamSystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,12 @@ let patch ?(preprocess=true) ~dir p =
else
p
in
make_command ~name:"patch" ~dir "patch" ["-p1"; "-i"; p'] @@> fun r ->
let patch_cmd =
match OpamStd.Sys.os () with
| OpamStd.Sys.OpenBSD -> "gpatch"
| _ -> "patch"
in
make_command ~name:"patch" ~dir patch_cmd ["-p1"; "-i"; p'] @@> fun r ->
if not (OpamConsole.debug ()) then Sys.remove p';
if OpamProcess.is_success r then Done None
else Done (Some (Process_error r))
Expand Down

0 comments on commit 12a0f03

Please # to comment.