-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn if GNU patch is not detected when using patch #5893
Conversation
d4d6d85
to
0c02ebf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the idea and the code, lgtm!
Can you explain in the main comment why this is applied only on updating opam repositories ?
Also, a precision in the changes/PR/commits, it is not specific to opam update
, but more generally opam repositories updating. These updates can be launched by opam update
, opam switch
, and opam init
.
bc57e7b
to
3fce7b6
Compare
3fce7b6
to
3596c61
Compare
3596c61
to
1322219
Compare
1322219
to
c1d240d
Compare
I do understand the logic to look for "gpatch" .. "patch" -- but I'd do it differently:
Of course your PR is fine, but I wonder in terms of lines of code and code understandability whether it is worth it (my experience is if you have the least platform-specific conditionals, the easiest it is to debug). But these are only my 2 cents... thanks for your work on this. |
| DragonFly | ||
| FreeBSD | ||
| NetBSD | ||
| OpenBSD -> ("gpatch", ["patch"]) | ||
| Cygwin | ||
| Darwin | ||
| Linux | ||
| Unix | ||
| Win32 | ||
| Other _ -> ("patch", ["gpatch"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hannesm like this?
| DragonFly | |
| FreeBSD | |
| NetBSD | |
| OpenBSD -> ("gpatch", ["patch"]) | |
| Cygwin | |
| Darwin | |
| Linux | |
| Unix | |
| Win32 | |
| Other _ -> ("patch", ["gpatch"]) | |
| Darwin | |
| DragonFly | |
| FreeBSD | |
| NetBSD | |
| OpenBSD -> ("gpatch", ["patch"]) | |
| Cygwin | |
| Linux | |
| Unix | |
| Win32 | |
| Other _ -> ("patch", []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem with that is that it changes the behaviour compared to 2.1.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, well, or even:
let default_cmd, other_cmds = "gpatch", [ "patch" ]
avoiding the match on the os type at all. But I hear your "changes the behaviour". With that in mind, I like your PR very much.
The only suggestion left is:
let default_cmd, other_cmds =
match OpamStd.Sys.os () with
| DragonFly
| FreeBSD
| NetBSD
| OpenBSD
| Darwin -> ("gpatch", ["patch"])
| Cygwin
| Linux
| Unix
| Win32
| Other _ -> ("patch", [])
so, put Darwin into the pot where gpatch is tried first, and don't try gpatch on Linux & Windows.
But as said, maybe the current state is best for avoiding too much trouble / regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually considering the code and platforms, maybe
let default_cmd, other_cmds = "patch", [ "gpatch" ]
is suitable? This would on OpenBSD and FreeBSD call patch --version
, and then go to using gpatch
...
c1d240d
to
fdd7d90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! tiny formatting remark that you can ignore :)
related to #3639 |
Lightweight alternative to #5892
See #5400
In this PR, once per process if a patch is going to be applied (either a patch application in a package or a repository update) we first check which patch executable to use. If no GNU patch is detected we display a warning.
On some platforms the name of the
patch
command can change depending on the context (e.g. macOS where Homebrew providespatch
but Macports providesgpatch
), so to handle that we simply check bothpatch
andgpatch
and detect which one is GNU patch. On the platforms more likely to havepatch
as GNU patch we checkpatch
first and default to it if none were found, and inversely on the platforms that are more likely to havegpatch
as GNU patch.