composer-patches
composer-patches copied to clipboard
Support busybox
busybox is a sized optimized toolbox of common unix utilities including a version of patch for alpine. This version doesn't support all parameters so applying patches will fail. This PR introduces another attempt to patch files with params supported by busybox version of patch.
Looks interesting, just not clear which restrictions (except no support for binary patches) should be noted in readme
I'm not excited about supporting weird versions of patch (BSD also has one of these that's been a persistent problem). Up to this point, I've been supporting GNU Patch (which is packaged for alpine -- apk add patch
). Is there some way to identify this version of patch
vs some other version of patch
? I'm thinking that 2.x is going to have extensible patch application, so if there's some way to determine what kind of patch
is installed, this would be possible.
Specific to this patch, I imagine that at least some flag will need to be passed to patch
. I know at least GNU Patch makes a mess if a patch doesn't apply correctly, sometimes creates backup files, etc.
/var/www/html $ patch -v
patch: unrecognized option: v
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.
Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]
-p N Strip N leading components from file names
-i DIFF Read DIFF instead of stdin
-R Reverse patch
-N Ignore already applied patches
-E Remove output files if they become empty
--dry-run Don't actually change files
/var/www/html $ echo $?
1
/var/www/html $
That would be one way, but the non-success status code needs to be handled.
/var/www/html $ ls -la `which patch`
lrwxrwxrwx 1 root root 12 Oct 21 2019 /usr/bin/patch -> /bin/busybox
/var/www/html $
That would be another.
Probably won't do this in 1.x, but in 2.x (and in particular in the 2.x-wip branch that #447 is using), individual versions of patch can be supported. Can you take a look at src/Patcher/*
in that PR and let me know if the BsdPatchPatcher
does what you need? I'm open to including a busybox patcher there if needed.