Skip to content

Commit

Permalink
Merge pull request #6255 from kit-ty-kate/gpatch-homebrew
Browse files Browse the repository at this point in the history
Lookup at gpatch before patch on macOS now that both homebrew and macports expose gpatch as gpatch
  • Loading branch information
kit-ty-kate authored Dec 17, 2024
2 parents 6dfc1ec + 0f352f0 commit 68f993d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ let main_build_job ~analyse_job ~cygwin_job ?section runner start_version ~oc ~w
job ~oc ~workflow ~runs_on:(Runner [runner]) ?shell ?section ~needs ~matrix ("Build-" ^ name_of_platform platform)
++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"])
++ only_on Linux (run "Disable AppArmor" ["echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns"])
++ only_on MacOS (run "Install GNU patch" ["brew install gpatch"])
++ only_on Windows (git_lf_checkouts ~cond:(Predicate(true, EndsWith("matrix.host", "-pc-cygwin"))) ~shell:"cmd" ~title:"Configure LF checkout for Cygwin" ())
++ checkout ()
++ only_on Windows (cache ~cond:(Predicate(true, Compare("matrix.build", "x86_64-pc-cygwin"))) Cygwin)
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ jobs:
ocamlv: [ 4.14.2, 5.2.0 ]
fail-fast: true
steps:
- name: Install GNU patch
run: brew install gpatch
- name: Checkout tree
uses: actions/checkout@v4
- name: src_ext/archives and opam-repository Cache
Expand Down
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ users)

## External dependencies
* Add apt-rpm/ALTLinux family support for depext [#6207 @RiderALT]
* Lookup at `gpatch` before `patch` on macOS now that both homebrew and macports expose `gpatch` as `gpatch` since Homebrew/homebrew-core#174687 [#6255 @kit-ty-kate]

## Format upgrade

Expand Down
2 changes: 1 addition & 1 deletion src/client/opamInitDefaults.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let sandbox_filter = FOr (linux_filter, macos_filter)

let gpatch_filter =
FOr (FOr (openbsd_filter, netbsd_filter),
FOr (freebsd_filter, dragonflybsd_filter))
FOr (freebsd_filter, FOr (dragonflybsd_filter, macos_filter)))
let patch_filter = FNot gpatch_filter

let gtar_filter = openbsd_filter
Expand Down
2 changes: 1 addition & 1 deletion src/core/opamSystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,12 @@ let gpatch = lazy begin
in
let default_cmd, other_cmds =
match OpamStd.Sys.os () with
| Darwin
| DragonFly
| FreeBSD
| NetBSD
| OpenBSD -> ("gpatch", ["patch"])
| Cygwin
| Darwin
| Linux
| Unix
| Win32
Expand Down
8 changes: 7 additions & 1 deletion tests/lib/patcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ let generate_patch () =
Printf.eprintf "Before patch state of c:\n";
print_directory ".";
flush stdout;
if Sys.command "patch -p1 -i ../output.patch" <> 0 then (Printf.eprintf "patch application failed\n%!"; exit 2);
let gpatch =
if Sys.command "sh -c \"command -v gpatch > /dev/null 2> /dev/null\"" = 0 then
"gpatch"
else
"patch"
in
if Sys.command (gpatch^" -p1 -i ../output.patch") <> 0 then (Printf.eprintf "patch application failed\n%!"; exit 2);
Printf.eprintf "After patch state of c:\n";
print_directory ".";
OpamSystem.chdir Filename.parent_dir_name
Expand Down
8 changes: 4 additions & 4 deletions tests/reftests/repository.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ some content
### sh hash.sh REPO foo.1
### : Internal repository storage as archive or plain directory :
### opam switch create tarring --empty
### opam update -vv | grep '^\+' | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch'
### opam update -vv | grep '^\+' | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch'
+ diff "-ruaN" "default" "default.new" (CWD=${BASEDIR}/OPAM/repo)
+ patch "--version"
+ patch "-p1" "-i" "${BASEDIR}/OPAM/log/patch" (CWD=${BASEDIR}/OPAM/repo/default)
Expand All @@ -38,7 +38,7 @@ build: ["test" "-f" "baz"]
### <REPO/packages/foo/foo.2/files/baz>
some content
### sh hash.sh REPO foo.2
### opam update default -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch'
### opam update default -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch'
+ diff "-ruaN" "default" "default.new" (CWD=${BASEDIR}/OPAM/repo)
+ patch "--version"
+ patch "-p1" "-i" "${BASEDIR}/OPAM/log/patch" (CWD=${BASEDIR}/OPAM/repo/default)
Expand Down Expand Up @@ -78,7 +78,7 @@ build: ["test" "-f" "baz"]
### <REPO/packages/foo/foo.4/files/baz>
some content
### sh hash.sh REPO foo.4
### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch'
### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch'
+ tar "xfz" "${BASEDIR}/OPAM/repo/tarred.tar.gz" "-C" "${OPAMTMP}"
+ diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP})
+ patch "--version"
Expand All @@ -102,7 +102,7 @@ build: ["test" "-f" "quux"]
### <REPO/packages/foo/foo.5/files/quux>
some content
### sh hash.sh REPO foo.5
### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | 'patch-[^"]+' -> 'patch'
### opam update -vv | grep '^\+' | sed-cmd tar | sed-cmd diff | sed-cmd patch | sed-cmd gpatch | '\+ gpatch ' -> '+ patch ' | 'patch-[^"]+' -> 'patch'
+ tar "xfz" "${BASEDIR}/OPAM/repo/tarred.tar.gz" "-C" "${OPAMTMP}"
+ diff "-ruaN" "tarred" "tarred.new" (CWD=${OPAMTMP})
+ patch "--version"
Expand Down

0 comments on commit 68f993d

Please sign in to comment.