support/scripts/apply-patches.sh: do not blindly remove *.orig files
PATCH 1/1 support/scripts/apply-patches.sh: do not blindly remove *.orig files
apply-patches currently blindly removes *.orig / .*.orig files as GNU patch by default writes these as backup files when patches only apply with fuzz.
This is unfortunate as package sources may contain files ending in .orig as well, breaking the build. Luckily GNU patch can be told to not write these backup files using the --no-backup-if-mismatch option, so used that instead of the .orig removal step.
--no-backup-if-mismatch is supported since GNU patch 2.3.8 (1997-06-17) and busybox patch if built with CONFIG_DESKTOP, but E.G. isn't supported by the BSD patch, so add logic to detect support for the flag and only use it if supported.
---
Do we care about BSD patch / busybox patch w/ DESKTOP? Should we just unconditionally use the flag?
We have a similar issue with *.rej. GNU patch can be told to not write those with the -r - option (since GNU patch 2.6, Nov 2009), but it should normally also exit with a non-zero exit code for such sitations, so I am not sure the check is needed?
support/scripts/apply-patches.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
support/scripts/apply-patches.sh +7 -4
@@ -40,6 +40,12 @@ if [ "$1" = "-s" ] ; then shift fi +# does patch support --no-backup-if-mismatch (GNU, busybox w/DESKTOP) +if patch --no-backup-if-mismatch </dev/null 2>/dev/null; then + # don't write backup files + PATCH_ARGS="--no-backup-if-mismatch" +fi + # Set directories from arguments, or use defaults. builddir=${1-.} patchdir=${2-../kernel-patches}
@@ -119,7 +125,7 @@ function apply_patch { exit 1 fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list - ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}" -t -N $silent + ${uncomp} "${path}/$patch" | patch -g0 -p1 -E $PATCH_ARGS -d "${builddir}" -t -N $silent if [ $? != 0 ] ; then echo "Patch failed! Please fix ${patch}!" exit 1
@@ -168,6 +174,3 @@ if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then echo "Aborting. Reject files found." exit 1 fi - -# Remove backup files -find $builddir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
Signature · 1 line
2.20.1
PATCH 1/1 support/scripts/apply-patches.sh: do not blindly remove *.orig files
Peter, All,
On 2020-10-06 20:56 +0200, Peter Korsgaard spake thusly:
Quoted 14 lines
apply-patches currently blindly removes *.orig / .*.orig files as GNU patch by default writes these as backup files when patches only apply with fuzz.
This is unfortunate as package sources may contain files ending in .orig as well, breaking the build. Luckily GNU patch can be told to not write these backup files using the --no-backup-if-mismatch option, so used that instead of the .orig removal step.
--no-backup-if-mismatch is supported since GNU patch 2.3.8 (1997-06-17) and busybox patch if built with
CONFIG_DESKTOP, but E.G. isn't supported by the BSD patch, so add logic to detect support for the flag and only use it if supported.Signed-off-by Peter Korsgaard <[email protected]>
Quoted 8 lines
---
Do we care about BSD patch / busybox patch w/ DESKTOP? Should we just unconditionally use the flag?We have a similar issue with *.rej. GNU patch can be told to not write those with the -r - option (since GNU patch 2.6, Nov 2009), but it should normally also exit with a non-zero exit code for such sitations, so I am not sure the check is needed?
As discussed on IRC: I think we should require that patch suppot --no-backup-if-mismatch, and bail out if not:
- check for that in support/dependencies/check-host-patch.{mk.sh}
- always use --no-backup-if-mismatch in apply-patch.sh
Regards,
Yann E. MORIN.
Quoted 43 lines
support/scripts/apply-patches.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)support/scripts/apply-patches.sh +7
-4@@ -40,6 +40,12 @@ if [ "$1" = "-s" ] ; then shift fi +# does patch support --no-backup-if-mismatch (GNU, busybox w/DESKTOP) +if patch --no-backup-if-mismatch </dev/null 2>/dev/null; then + # don't write backup files + PATCH_ARGS="--no-backup-if-mismatch" +fi + # Set directories from arguments, or use defaults. builddir=${1-.} patchdir=${2-../kernel-patches}@@ -119,7 +125,7 @@ function apply_patch { exit 1 fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list - ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}" -t -N $silent + ${uncomp} "${path}/$patch" | patch -g0 -p1 -E $PATCH_ARGS -d "${builddir}" -t -N $silent if [ $? != 0 ] ; then echo "Patch failed! Please fix ${patch}!" exit 1@@ -168,6 +174,3 @@ if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then echo "Aborting. Reject files found." exit 1 fi - -# Remove backup files -find $builddir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;Signature · 6 lines
2.20.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 support/scripts/apply-patches.sh: do not blindly remove *.orig files
Quoted 27 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2020-10-06 20:56 +0200, Peter Korsgaard spake thusly:Quoted 14 lines
apply-patches currently blindly removes *.orig / .*.orig files as GNU patch by default writes these as backup files when patches only apply with fuzz.
This is unfortunate as package sources may contain files ending in .orig as well, breaking the build. Luckily GNU patch can be told to not write these backup files using the --no-backup-if-mismatch option, so used that instead of the .orig removal step.
--no-backup-if-mismatch is supported since GNU patch 2.3.8 (1997-06-17) and busybox patch if built with
CONFIG_DESKTOP, but E.G. isn't supported by the BSD patch, so add logic to detect support for the flag and only use it if supported.Signed-off-by Peter Korsgaard <[email protected]>Quoted 8 lines
---
Do we care about BSD patch / busybox patch w/ DESKTOP? Should we just unconditionally use the flag?We have a similar issue with *.rej. GNU patch can be told to not write those with the -r - option (since GNU patch 2.6, Nov 2009), but it should normally also exit with a non-zero exit code for such sitations, so I am not sure the check is needed?
Quoted 4 lines
As discussed on IRC: I think we should require that patch suppot --no-backup-if-mismatch, and bail out if not:
- check for that in support/dependencies/check-host-patch.{mk.sh}
You mean we should build our own host-patch? Sorry, I really find that overkill. People are very unlikely to use anything else than GNU patch, and the option is supported for more than 20 years.
But Ok, we can add a check for it in dependencies.sh, just like we do for the availability of patch.
Quoted 1 line
- always use --no-backup-if-mismatch in
apply-patch.sh
Ok.
I'll send a v2 doing that.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 support/scripts/apply-patches.sh: do not blindly remove *.orig files
Peter, All,
On 2020-10-06 22:34 +0200, Peter Korsgaard spake thusly:
Quoted 20 lines
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2020-10-06 20:56 +0200, Peter Korsgaard spake thusly:Quoted 17 lines
apply-patches currently blindly removes *.orig / .*.orig files as GNU patch by default writes these as backup files when patches only apply with fuzz.
This is unfortunate as package sources may contain files ending in .orig as well, breaking the build. Luckily GNU patch can be told to not write these backup files using the --no-backup-if-mismatch option, so used that instead of the .orig removal step.
--no-backup-if-mismatch is supported since GNU patch 2.3.8 (1997-06-17) and busybox patch if built with
CONFIG_DESKTOP, but E.G. isn't supported by the BSD patch, so add logic to detect support for the flag and only use it if supported.Signed-off-by Peter Korsgaard <[email protected]>---
Do we care about BSD patch / busybox patch w/ DESKTOP? Should we just unconditionally use the flag?
Quoted 6 lines
Quoted 3 lines
As discussed on IRC: I think we should require that patch suppot --no-backup-if-mismatch, and bail out if not:
- check for that in support/dependencies/check-host-patch.{mk.sh}You mean we should build our own host-patch? Sorry, I really find that overkill. People are very unlikely to use anything else than GNU patch, and the option is supported for more than 20 years.
No, sorry, I was thinking about dependencies.sh
Quoted 2 lines
But Ok, we can add a check for it in
dependencies.sh, just like we do for the availability of patch.
Yes.
Quoted 3 lines
Quoted 1 line
- always use --no-backup-if-mismatch in
apply-patch.shOk.
I'll send a v2 doing that.
Thanks.
\Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'