Suggestion to "support/scripts/apply-patches.sh: do not apply patches with renames"
Hi. Thank you for your great work, Buildroot team.
I'm writing this email for suggestions to support/scripts/apply-patches.sh.
Recently, I was working with buildroot to apply patches-4.14.164-rt73. It included a patch((patches-4.14.164-rt73/0462-..)) which renames a file. This caused the build to terminate with an error.
The reason for this is that apply-patches.sh exits when it finds a patch that contains a rename.
This feature is kind for users who use legacy patch commands, but not kind for current users.
So I'd like to suggest adding a kind of this line
grep -q "^BR2_*_LEGACY_PATCH_CMD=y" "$BR2_CONFIG" && \
to below if statement.
```
if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \
${uncomp} "${path}/$patch" | grep -q "^rename to" ; then
```Parsing the results of the patch is dependent on the implementation of it, so I think it would be better to get them who use legacy patch to set it explicitly.
(For considering backward compatibility,
(it might be better if the environment variable had the opposite meaning.
How about this idea?
In making this suggestion I have read the following two threads.
- http://lists.busybox.net/pipermail/buildroot/2017-May/191794.html
- http://lists.busybox.net/pipermail/buildroot/2017-June/195335.html
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210513/2cfdb0db/attachment.html>
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Ryota" == Ryota Kinukawa <[email protected]> writes:
Hi,
Quoted 21 lines
Hi. Thank you for your great work, Buildroot team.
I'm writing this email for suggestions tosupport/scripts/apply-patches.sh.Recently, I was working with buildroot to apply patches-4.14.164-rt73. It included a patch((patches-4.14.164-rt73/0462-..)) which renames a file. This caused the build to terminate with an error.
The reason for this is that
apply-patches.shexits when it finds a patch that contains a rename.
This feature is kind for users who use legacypatchcommands, but not kind for current users.So I'd like to suggest adding a kind of this line
grep -q "^BR2_*_LEGACY_PATCH_CMD=y" "$BR2_CONFIG" && \
to below if statement.``` if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then ```
Quoted 7 lines
Parsing the results of the
patchis dependent on the implementation of it, so I think it would be better to get them who uselegacy patchto set it explicitly.
(For considering backward compatibility,
(it might be better if the environment variable had the opposite meaning.How about this idea?
The problem with such an option is that it describes a property of the build host, not of the Buildroot configuration - And we still wouldn't be able to use rename patches as long as that option was supported.
So we want apply-patches.sh to work the same for everyone.
But we're now 4 years later, so perhaps it is time to unconditionally drop support for GNU patch < 2.7?
GNU patch 2.7 was released in September 2012, so 8.5 years ago:
https://savannah.gnu.org/forum/forum.php?forum_id=7361
Thomas, Yann - Any ideas how common such old patch version are nowadays?
Signature · 1 line
Bye, Peter Korsgaard
Peter, Ryota, All,
On 2021-05-15 08:44 +0200, Peter Korsgaard spake thusly:
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Ryota" == Ryota Kinukawa <[email protected]> writes:
Hi. Thank you for your great work, Buildroot team.
I'm writing this email for suggestions tosupport/scripts/apply-patches.sh.Recently, I was working with buildroot to apply patches-4.14.164-rt73. It included a patch((patches-4.14.164-rt73/0462-..)) which renames a file. This caused the build to terminate with an error.
[--SNIP--]
Quoted 6 lines
The problem with such an option is that it describes a property of the build host, not of the Buildroot configuration - And we still wouldn't be able to use rename patches as long as that option was supported.
So we want
apply-patches.shto work the same for everyone.
Quoted 8 lines
But we're now 4 years later, so perhaps it is time to unconditionally drop support for GNU patch < 2.7?
GNU patch 2.7 was released in September 2012, so 8.5 years ago:
https://savannah.gnu.org/forum/forum.php?forum_id=7361
Thomas, Yann - Any ideas how common such old patch version are nowadays?
One of the oldest supported distro that was rel;eased before patch 2.7, is RHEL 6. It has entered Extended Support in late 2020, and is expected to be supported until mid 2024. However, consdering this is an old distro, Iand that there were CVes on patch < 2.7 I'd expect that RHEL 6 now packages a newer patch that is >= 2.7.
People that do not update their systems, and are stuck on so old a host distro, will probably not update their Buildroot version either...
On the Ubuntu side (as another data point), the odest LTS is Trusty, 14.04, and it has patch 2.7.1.
As for Debian, the oldest still supported is Jessie, with Extended LTS until mid 2022, and it was released in 2015, so presumably has patch >= 2.7 too.
So, I would be OK for requiring patch >= 2.7.
So, lets do it that way;
1. add a check in support/dependencies/dependencies.sh that patch >=
2.7 (just after/before the check for --no-backup-if-mismatch)
2. drop the test for renames in support/scripts/apply-patches.sh
Ryota, would you care to work on that and send the patches to the list, please?
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. | '------------------------------^-------^------------------^--------------------'
Hello Yann, All,
Le 15/05/2021 ? 11:40, Yann E. MORIN a ?crit?:
Quoted 42 lines
Peter, Ryota, All,
On 2021-05-15 08:44 +0200, Peter Korsgaard spake thusly:
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Ryota" == Ryota Kinukawa <[email protected]> writes:
Hi. Thank you for your great work, Buildroot team.
I'm writing this email for suggestions tosupport/scripts/apply-patches.sh.Recently, I was working with buildroot to apply patches-4.14.164-rt73. It included a patch((patches-4.14.164-rt73/0462-..)) which renames a file. This caused the build to terminate with an error.
[--SNIP--]
Quoted 6 lines
The problem with such an option is that it describes a property of the build host, not of the Buildroot configuration - And we still wouldn't be able to use rename patches as long as that option was supported.
So we want
apply-patches.shto work the same for everyone.Quoted 8 lines
But we're now 4 years later, so perhaps it is time to unconditionally drop support for GNU patch < 2.7?
GNU patch 2.7 was released in September 2012, so 8.5 years ago:
https://savannah.gnu.org/forum/forum.php?forum_id=7361
Thomas, Yann - Any ideas how common such old patch version are nowadays?
One of the oldest supported distro that was rel;eased before patch 2.7, is RHEL 6. It has entered Extended Support in late 2020, and is expected to be supported until mid 2024. However, consdering this is an old distro, Iand that there were CVes on patch < 2.7 I'd expect that RHEL 6 now packages a newer patch that is >= 2.7.
People that do not update their systems, and are stuck on so old a host distro, will probably not update their Buildroot version either...
On the Ubuntu side (as another data point), the odest LTS is Trusty, 14.04, and it has patch 2.7.1.
As for Debian, the oldest still supported is Jessie, with Extended LTS until mid 2022, and it was released in 2015, so presumably has patch >= 2.7 too.
Quoted 6 lines
So, I would be OK for requiring patch >= 2.7.
So, lets do it that way;
1. add a check in
support/dependencies/dependencies.shthat patch >=2.7 (just after/before the check for --no-backup-if-mismatch)
Based on the host gcc requirement on gcc 4.9 (released the 22 April 2014), we already don't support such old distro. Ubuntu LTS Trusty provide gcc 4.8.
Best regards,
Romain
Quoted 9 lines
2. drop the test for renames in
support/scripts/apply-patches.shRyota, would you care to work on that and send the patches to the list, please?
Regards,
Yann E. MORIN.
Romain, All,
On 2021-05-15 12:57 +0200, Romain Naour spake thusly:
Quoted 5 lines
Le 15/05/2021 ? 11:40, Yann E. MORIN a ?crit?:
Quoted 2 lines
On the Ubuntu side (as another data point), the odest LTS is Trusty, 14.04, and it has patch 2.7.1.
Based on the host gcc requirement on gcc 4.9 (released the 22 April 2014), we already don't support such old distro. Ubuntu LTS Trusty provide gcc 4.8.
Ah, I don't thinks so. We still only require gcc >= 4.8:
- the manual still references gcc 4.8, even the nightly snapshots:
http://nightly.buildroot.org/#requirement
2.1. Mandatory packages
...
* gcc (version 4.8 or any later)
* g++ (version 4.8 or any later)
- support/dependencies/dependencies.sh still only checks for gcc >=
4.8:
if [ $COMPILER_MAJOR -lt 4 -o $COMPILER_MAJOR -eq 4 -a $COMPILER_MINOR -lt 8 ] ; then
The last time (that I remember of) when we bumped our host gcc requirement, was with those commits, dated October 2020:
* 5ee815ab6a docs/manual: bump our gcc/g++ requirements to 4.8
* 55fc80260b packages: host gcc >= 4.8 is now guaranteed
I could not find a reference to requiring host gcc >= 4.9 in the commit logs...
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. | '------------------------------^-------^------------------^--------------------'
Yann, All,
Le 15/05/2021 ? 13:19, Yann E. MORIN a ?crit?:
Quoted 10 lines
Romain, All,
On 2021-05-15 12:57 +0200, Romain Naour spake thusly:
Quoted 5 lines
Le 15/05/2021 ? 11:40, Yann E. MORIN a ?crit?:
Quoted 2 lines
On the Ubuntu side (as another data point), the odest LTS is Trusty, 14.04, and it has patch 2.7.1.
Based on the host gcc requirement on gcc 4.9 (released the 22 April 2014), we already don't support such old distro. Ubuntu LTS Trusty provide gcc 4.8.
Ah, I don't thinks so. We still only require gcc >= 4.8:
It seems the BR2_HOST_GCC_AT_LEAST_4_8 symbol has been removed with commit 55fc80260b packages: host gcc >= 4.8 is now guaranteed.
I just noticed it while looking at this discussion...
Quoted 13 lines
- the manual still references gcc 4.8, even the nightly snapshots:
http://nightly.buildroot.org/#requirement2.1. Mandatory packages
...
* gcc (version 4.8 or any later)
* g++ (version 4.8 or any later)-
support/dependencies/dependencies.shstill only checks for gcc >=
4.8:
if [ $COMPILER_MAJOR -lt 4 -o $COMPILER_MAJOR -eq 4 -a $COMPILER_MINOR -lt 8 ] ; then
Quoted 8 lines
The last time (that I remember of) when we bumped our host gcc requirement, was with those commits, dated October 2020:
*
5ee815ab6adocs/manual: bump our gcc/g++ requirements to 4.8
*55fc80260bpackages: host gcc >= 4.8 is now guaranteedI could not find a reference to requiring host gcc >= 4.9 in the commit logs...
Otherwise, agree gcc 4.8 should be the minimal supported version.
Best regards,
Romain
Quoted 4 lines
Regards,
Yann E. MORIN.
Romain, All,
On 2021-05-15 13:46 +0200, Romain Naour spake thusly:
Quoted 7 lines
Le 15/05/2021 ? 13:19, Yann E. MORIN a ?crit?:
Quoted 6 lines
Romain, All,
On 2021-05-15 12:57 +0200, Romain Naour spake thusly:
Quoted 3 lines
Le 15/05/2021 ? 11:40, Yann E. MORIN a ?crit?:
Quoted 2 lines
On the Ubuntu side (as another data point), the odest LTS is Trusty, 14.04, and it has patch 2.7.1.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Based on the host gcc requirement on gcc 4.9 (released the 22 April 2014), we already don't support such old distro. Ubuntu LTS Trusty provide gcc 4.8.
Ah, I don't thinks so. We still only require gcc >= 4.8:
It seems the
BR2_HOST_GCC_AT_LEAST_4_8symbol has been removed with commit55fc80260bpackages: host gcc >= 4.8 is now guaranteed.
Yes, the removal was on purpose: since gcc >= 4.8 is not guaranteed (with a check in dependencies.sh), BR2_HOST_GCC_AT_LEAST_4_8 would always be 'y'; there is no advantage to having a variable always set to 'y', so we dropped it.
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. | '------------------------------^-------^------------------^--------------------'
Yann-san
Quoted 6 lines
So, lets do it that way;
1. add a check insupport/dependencies/dependencies.shthat patch >=2.7 (just after/before the check for --no-backup-if-mismatch)2. drop the test for renames in
support/scripts/apply-patches.sh
Ryota, would you care to work on that and send the patches to the list, please?
Thank you for the opportunity to contribute buildroot.
This is my first time to contribute to buildroot,
so it may take me a while to learn how to do it. But I'd like to, please let me try.
Regards,
Ryota Kinukawa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210516/abefbef2/attachment.html>
Yann-san, All
Quoted 6 lines
So, lets do it that way;
1. add a check insupport/dependencies/dependencies.shthat patch >=2.7 (just after/before the check for --no-backup-if-mismatch)2. drop the test for renames in
support/scripts/apply-patches.sh
Ryota, would you care to work on that and send the patches to the list, please?
Here is the patch, could you confirm this?
(quoted diff) +0 -0
b/support/dependencies/dependencies.sh
index 1954f038be..030a2196f9 100755
support/dependencies/dependencies.sh +6 -1
@@ -163,7 +163,7 @@ fi # Check that a few mandatory programs are installed missing_progs="no" -for prog in patch perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do +for prog in perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do if ! which $prog > /dev/null ; then echo "You must install '$prog' on your build machine"; missing_progs="yes"
@@ -183,11 +183,24 @@ if test "${missing_progs}" = "yes" ; then exit 1 fi +# Check patch +if ! which patch > /dev/null ; then + echo "You must install GNU patch on your build machine"; + exit 1 +fi # apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU,
busybox w/DESKTOP)
if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then
echo "Your patch program does not support the
--no-backup-if-mismatch option. Install GNU patch"
exit 1
fi
+PATCH_VERSION=$(patch --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
+PATCH_MAJOR=$(echo $PATCH_VERSION | sed -e "s/\..*//g") +PATCH_MINOR=$(echo $PATCH_VERSION | sed -e "s/^$PATCH_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
+if [ $PATCH_MAJOR -lt 2 ] || [ $PATCH_MAJOR -eq 2 -a $PATCH_MINOR -lt 7 ] ; then
+ echo
+ echo "You have GNU patch '$PATCH_VERSION' installed. GNU patch
Quoted 1 line
=2.7 is required"
+ exit 1;
+fi
if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
if ! which locale > /dev/null ; then
(quoted diff) +0 -0
b/support/scripts/apply-patches.sh
index 9fb488c570..e5a2fdd09e 100755
support/scripts/apply-patches.sh +0 -3
@@ -113,11 +113,6 @@ function apply_patch { echo " to be applied : ${path}/${patch}" exit 1 fi - if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ - ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then - echo "Error: patch contains some renames, not supported by old
patch versions"
- exit 1
- fi
echo "${path}/${patch}" >> ${builddir}/.applied_patches_list
${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch
-d "${builddir}" -t -N $silent
if [ $? != 0 ] ; thenRegards,
Ryota Kinukawa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210516/07366cfd/attachment.html>
Ryota, All,
Thanks for sending a patch so quickly! :-)
On 2021-05-16 17:18 +0900, Ryota Kinukawa spake thusly:
Quoted 8 lines
Quoted 6 lines
So, lets do it that way;
?1. add a check insupport/dependencies/dependencies.shthat patch >= ? ? 2.7 (just after/before the check for --no-backup-if-mismatch) ?2. drop the test for renames insupport/scripts/apply-patches.shRyota, would you care to work on that and send the patches to the list, please?Here is the patch, could you confirm this?
Please see my comments below. Also, please send it directly as its own mail; using "git send-email" makes it easy to send a patch.
Also, please provide an actual commit log. For example:
support/apply-patches: accept patches with renames
Currently, patches with renames are refused, as they reqire patch >= 2.7. So far, we did not require that version because it was too recent to be widely available.
But patch 2.7 has been released in 2012, almost 9 years ago now; it is old enough that we can start relying on it.
Add a check that patch is 2.7 or newer, and drop the check about renames in apply-patches.sh.
Quoted 17 lines
support/dependencies/dependencies.sh +0
-0@@ -163,7 +163,7 @@ fi?# Check that a few mandatory programs are installed ?missing_progs="no"
support/dependencies/dependencies.sh +1
-1-for prog in patch perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do +for prog in perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do? ? ? ? if ! which $prog >
/dev/null; then
? ? ? ? ? ? ? ? echo "You must install '$prog' on your build machine"; ? ? ? ? ? ? ? ? missing_progs="yes"support/dependencies/dependencies.sh +0
-0@@ -183,11 +183,24 @@ if test "${missing_progs}" = "yes" ; then? ? ? ? exit 1
?fi
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 190
Quoted 5 lines
support/dependencies/dependencies.sh +5
-0+# Check patch +if ! which patch > /dev/null ; then + ? ? ? echo "You must install GNU patch on your build machine"; + ? ? ? exit 1 +fi
There is no need for a dedicated check for patch; just leave it in the list, above.
support/dependencies/dependencies.sh
Quoted 8 lines
?#
apply-patches.shneeds patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP) ?if ! patch --no-backup-if-mismatch </dev/null2>/dev/null; then
? ? ? ? echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch" ? ? ? ? exit 1
?fisupport/dependencies/dependencies.sh +3
-0+PATCH_VERSION=$(patch --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q') +PATCH_MAJOR=$(echo $PATCH_VERSION | sed -e "s/\..*//g") +PATCH_MINOR=$(echo $PATCH_VERSION | sed -e "s/^$PATCH_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
Although I pretty much like regular expressions, I prefer that we do without when needed, which is the case here:
PATCH_VERSION="$(patch -v |awk '{ print $(3); exit; }')"
PATCH_VERSION_MAJOR="$(cut -d . -f 1 <<<"${PATCH_VERSION}")"
PATCH_VERSION_MINOR="$(cut -d . -f 2 <<<"${PATCH_VERSION}")"(note: quote all your expansions, both variable expansion and shell expansion).
Quoted 1 line
+if [ $PATCH_MAJOR -lt 2 ] || [ $PATCH_MAJOR -eq 2 -a $PATCH_MINOR -lt 7 ] ; then
Quote your variable expansion, and expand variables with curly braces;
"${PATCH_MAJOR}"Note: I know you got inspiration from the rest of the script, which was a good idea, but the script has been inherited from way back then a long time ago, when we did not have coding rules... No reason not to do better nowadays! ;-)
Quoted 12 lines
+ ? ? ? echo
+ ? ? ? echo "You have GNU patch '$PATCH_VERSION' installed.? GNU patch >=2.7 is required"
+ ? ? ? exit 1;
+fi?if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG >
/dev/null; then ? ? ? ? if ! which locale >/dev/null; thensupport/scripts/apply-patches.sh +0
-0@@ -113,11 +113,6 @@ function apply_patch {
Quoted 8 lines
? ? ? ? ?echo " ?to be applied ?: ${path}/${patch}"
? ? ? ? ?exit 1
? ? ?fi
- ? ?if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \
- ? ? ? ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then
- ? ? ? ?echo "Error: patch contains some renames, not supported by old patch versions"
- ? ? ? ?exit 1
- ? ?fi
ACK.
Care to resend with the above changes, please?
Quoted 5 lines
? ? ?echo "${path}/${patch}" >> ${builddir}/.applied_patches_list
? ? ?${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent ? ? ?if [ $? != 0 ] ; then
Regards,
Ryota Kinukawa
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. | '------------------------------^-------^------------------^--------------------'
Hi Ryota,
In addition to Yann's comments, I have two of my own:
On 16/05/2021 10:18, Ryota Kinukawa wrote:
[snip]
Quoted 7 lines
?#
apply-patches.shneeds patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP)
?if ! patch --no-backup-if-mismatch </dev/null2>/dev/null; then ? ? ? ? echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch"
? ? ? ? exit 1
?fi
This test is no longer needed, the version test covers it.
Quoted 2 lines
+PATCH_VERSION=$(patch --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
Non-GNU patch implementations may not accept --version or produce otherwise
different output. I think a better sed expression would be:
patch --version | sed -n '/GNU patch \(.*\)/s//\1/p'
and add a check that PATCH_VERSION is not empty.
With Yann's cut-based extraction of MAJOR and MINOR, this will work even if there's other distro-specific stuff at the end of the version.
Regards,
Arnout
Quoted 39 lines
(quoted diff) +2
-0+PATCH_MAJOR=$(echo $PATCH_VERSION | sed -e "s/\..*//g") +PATCH_MINOR=$(echo $PATCH_VERSION | sed -e "s/^$PATCH_MAJOR\.//g" -e"s/\..*//g" -e "s/[a-zA-Z].*//g")
+if [ $PATCH_MAJOR -lt 2 ] || [ $PATCH_MAJOR -eq 2 -a $PATCH_MINOR -lt 7 ] ; then
+ ? ? ? echo
+ ? ? ? echo "You have GNU patch '$PATCH_VERSION' installed.? GNU patch >=2.7 is required"
+ ? ? ? exit 1;
+fi?if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG >
/dev/null; then ? ? ? ? if ! which locale >/dev/null; thensupport/scripts/apply-patches.sh +0
-0@@ -113,11 +113,6 @@ function apply_patch {? ? ? ? ?echo " ?to be applied ?: ${path}/${patch}"
? ? ? ? ?exit 1
? ? ?fi
- ? ?if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \
- ? ? ? ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then
- ? ? ? ?echo "Error: patch contains some renames, not supported by old patch versions"
- ? ? ? ?exit 1
- ? ?fi
? ? ?echo "${path}/${patch}" >> ${builddir}/.applied_patches_list ? ? ?${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent
? ? ?if [ $? != 0 ] ; thenRegards,
Ryota Kinukawa_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 1/1 support/dependencies, scripts: accept patches with renames
In reply to Yann E. MORINFrom: Ryota Kinukawa <[email protected]>
Currently, patches with renames are refused, as they reqire patch >= 2.7. So far, we did not require that version because it was too recent to be widely available.
But patch 2.7 has been released in 2012, almost 9 years ago now; it is old enough that we can start relying on it.
Add a check that patch is 2.7 or newer, and drop the check about renames in apply-patches.sh.
--- support/dependencies/dependencies.sh | 12 +++++++++++- support/scripts/apply-patches.sh | 5 ----- 2 files changed, 11 insertions(+), 6 deletions(-)
support/dependencies/dependencies.sh +11 -1
@@ -183,11 +183,21 @@ if test "${missing_progs}" = "yes" ; then exit 1 fi +PATCH_VERSION="$(patch -v | sed -n 's/^GNU patch \(.*\)/\1/p')" # apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP) -if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then +if [ -z "${PATCH_VERSION}" ] ; then + echo echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch" exit 1 fi +PATCH_VERSION_MAJOR="$(echo "${PATCH_VERSION}" | cut -d . -f 1)" +PATCH_VERSION_MINOR="$(echo "${PATCH_VERSION}" | cut -d . -f 2)" +if [ "${PATCH_VERSION_MAJOR}" -lt 2 ] || \ + [ "${PATCH_VERSION_MAJOR}" -eq 2 -a "${PATCH_VERSION_MINOR}" -lt 7 ] ; then + echo + echo "You have GNU patch '$PATCH_VERSION' installed. GNU patch >=2.7 is required" + exit 1; +fi if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then if ! which locale > /dev/null ; then
support/scripts/apply-patches.sh +0 -5
@@ -113,11 +113,6 @@ function apply_patch { echo " to be applied : ${path}/${patch}" exit 1 fi - if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ - ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then - echo "Error: patch contains some renames, not supported by old patch versions" - exit 1 - fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list ${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent if [ $? != 0 ] ; then
Signature · 1 line
2.25.1
Yann E. MORIN
AppliedPATCH 1/1 support/dependencies, scripts: accept patches with renames
Ryota, All,
On 2021-05-19 12:28 +0900, pojiro.jp at gmail.com spake thusly:
Quoted 5 lines
From: Ryota Kinukawa <[email protected]>
Currently, patches with renames are refused, as they reqire patch >= 2.7. So far, we did not require that version because it was too recent to be widely available.
Quoted 7 lines
But patch 2.7 has been released in 2012, almost 9 years ago now; it is old enough that we can start relying on it.
Add a check that patch is 2.7 or newer, and drop the check about renames in
apply-patches.sh.Signed-off-by Ryota Kinukawa <[email protected]>
Thanks for the respin! :-)
Following Arnouts comments, some of my previous ones no longer applied, so I did a few rework, see below...
Quoted 10 lines
--- support/dependencies/dependencies.sh | 12 +++++++++++- support/scripts/apply-patches.sh | 5 ----- 2 files changed, 11 insertions(+), 6 deletions(-)support/dependencies/dependencies.sh +0
-0
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 186
Quoted 4 lines
support/dependencies/dependencies.sh +1
-0@@ -183,11 +183,21 @@ if test "${missing_progs}" = "yes" ; then exit 1 fi +PATCH_VERSION="$(patch -v | sed -n 's/^GNU patch \(.*\)/\1/p')"
Since we now have an explicit check like that one, dropping the common one, as you did initially, was indeed a good idea; I've done that Sorry for misleading you on that part.
It also needs redirection 2>/dev/null to ignore errors (e.g. missing patch, or patch that does not know of -v).
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 187
Quoted 1 line
support/dependencies/dependencies.sh +0
-0# apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP)
This comment is now incorrect, because we no longer accept any patch that is not explicitly GNU patch, so busybox w/desktop is no longer accepted.
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 190
Quoted 4 lines
support/dependencies/dependencies.sh +2
-1-if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then +if [ -z "${PATCH_VERSION}" ] ; then + echo echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch"
The error message is now explicitlely about not being GNU patch, so I've shorten it to: "You must install GNU patch"
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 196
Quoted 6 lines
support/dependencies/dependencies.sh +4
-0exit 1 fi +PATCH_VERSION_MAJOR="$(echo "${PATCH_VERSION}" | cut -d . -f 1)" +PATCH_VERSION_MINOR="$(echo "${PATCH_VERSION}" | cut -d . -f 2)" +if [ "${PATCH_VERSION_MAJOR}" -lt 2 ] || \ + [ "${PATCH_VERSION_MAJOR}" -eq 2 -a "${PATCH_VERSION_MINOR}" -lt 7 ] ; then
Aha, I see you used the long variable names I used in my review, and now the line is too long. ;-) I've reverted to the original names you were using, because they are explicit enough, and they also match other parts of the script, and makes the line short enough again. :-)
support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 198
Quoted 2 lines
support/dependencies/dependencies.sh +2
-0+ echo + echo "You have GNU patch '$PATCH_VERSION' installed. GNU patch >=2.7 is required"
You forgot to use curly braces for the expansion here.
Applied to next, with the few changes above, thanks! :-)
Regards,
Yann E. MORIN.
Quoted 28 lines
support/dependencies/dependencies.sh +2
-0+ exit 1; +fi if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then if ! which locale > /dev/null ; thensupport/scripts/apply-patches.sh +0
-5@@ -113,11 +113,6 @@ function apply_patch { echo " to be applied : ${path}/${patch}" exit 1 fi - if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ - ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then - echo "Error: patch contains some renames, not supported by old patch versions" - exit 1 - fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list ${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent if [ $? != 0 ] ; thenSignature · 6 lines
2.25.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 v2 1/1 support/dependencies, scripts: accept patches with renames
In reply to Yann E. MORINFrom: Ryota Kinukawa <[email protected]>
Currently, patches with renames are refused, as they reqire patch >= 2.7. So far, we did not require that version because it was too recent to be widely available.
But patch 2.7 has been released in 2012, almost 9 years ago now; it is old enough that we can start relying on it.
Add a check that patch is 2.7 or newer, and drop the check about renames in apply-patches.sh.
--- support/dependencies/dependencies.sh | 16 ++++++++++++---- support/scripts/apply-patches.sh | 5 ----- 2 files changed, 12 insertions(+), 9 deletions(-)
support/dependencies/dependencies.sh +12 -4
@@ -163,7 +163,7 @@ fi # Check that a few mandatory programs are installed missing_progs="no" -for prog in patch perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do +for prog in perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do if ! which $prog > /dev/null ; then echo "You must install '$prog' on your build machine"; missing_progs="yes"
@@ -183,11 +183,19 @@ if test "${missing_progs}" = "yes" ; then exit 1 fi -# apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP) -if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then - echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch" +PATCH_VERSION="$(patch -v 2> /dev/null | sed -n 's/^GNU patch \(.*\)/\1/p')" +if [ -z "${PATCH_VERSION}" ] ; then + echo + echo "You must install GNU patch" exit 1 fi +PATCH_MAJOR="$(echo "${PATCH_VERSION}" | cut -d . -f 1)" +PATCH_MINOR="$(echo "${PATCH_VERSION}" | cut -d . -f 2)" +if [ "${PATCH_MAJOR}" -lt 2 ] || [ "${PATCH_MAJOR}" -eq 2 -a "${PATCH_MINOR}" -lt 7 ] ; then + echo + echo "You have GNU patch "${PATCH_VERSION}" installed. GNU patch >=2.7 is required" + exit 1; +fi if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then if ! which locale > /dev/null ; then
support/scripts/apply-patches.sh +0 -5
@@ -113,11 +113,6 @@ function apply_patch { echo " to be applied : ${path}/${patch}" exit 1 fi - if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ - ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then - echo "Error: patch contains some renames, not supported by old patch versions" - exit 1 - fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list ${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent if [ $? != 0 ] ; then
Signature · 1 line
2.25.1
PATCH v2 1/1 support/dependencies, scripts: accept patches with renames
Ryota, All,
On 2021-05-19 17:34 +0900, pojiro.jp at gmail.com spake thusly:
Quoted 5 lines
From: Ryota Kinukawa <[email protected]>
Currently, patches with renames are refused, as they reqire patch >= 2.7. So far, we did not require that version because it was too recent to be widely available.
Quoted 7 lines
But patch 2.7 has been released in 2012, almost 9 years ago now; it is old enough that we can start relying on it.
Add a check that patch is 2.7 or newer, and drop the check about renames in
apply-patches.sh.Signed-off-by Ryota Kinukawa <[email protected]>
Thanks for the respin! However, there must have been a misunderstanding :I already applied your previous patch with the few tweaks I pointed out. See the git tree:
https://git.buildroot.org/buildroot/commit/?h=next&id=f46e13f05fa04a180a416876cf1dd4252dd841ad
Thanks again for following up on this! :-)
Regards,
Yann E. MORIN.
Quoted 64 lines
--- support/dependencies/dependencies.sh | 16 ++++++++++++---- support/scripts/apply-patches.sh | 5 ----- 2 files changed, 12 insertions(+), 9 deletions(-)support/dependencies/dependencies.sh +12
-4@@ -163,7 +163,7 @@ fi # Check that a few mandatory programs are installed missing_progs="no" -for prog in patch perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do +for prog in perl tar wget cpio unzip rsync bc ${DL_TOOLS} ; do if ! which $prog > /dev/null ; then echo "You must install '$prog' on your build machine"; missing_progs="yes"@@ -183,11 +183,19 @@ if test "${missing_progs}" = "yes" ; then exit 1 fi -# apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP) -if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then - echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch" +PATCH_VERSION="$(patch -v 2> /dev/null | sed -n 's/^GNU patch \(.*\)/\1/p')" +if [ -z "${PATCH_VERSION}" ] ; then + echo + echo "You must install GNU patch" exit 1 fi +PATCH_MAJOR="$(echo "${PATCH_VERSION}" | cut -d . -f 1)" +PATCH_MINOR="$(echo "${PATCH_VERSION}" | cut -d . -f 2)" +if [ "${PATCH_MAJOR}" -lt 2 ] || [ "${PATCH_MAJOR}" -eq 2 -a "${PATCH_MINOR}" -lt 7 ] ; then + echo + echo "You have GNU patch "${PATCH_VERSION}" installed. GNU patch >=2.7 is required" + exit 1; +fi if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then if ! which locale > /dev/null ; thensupport/scripts/apply-patches.sh +0
-5@@ -113,11 +113,6 @@ function apply_patch { echo " to be applied : ${path}/${patch}" exit 1 fi - if ${uncomp} "${path}/$patch" | grep -q "^rename from" && \ - ${uncomp} "${path}/$patch" | grep -q "^rename to" ; then - echo "Error: patch contains some renames, not supported by old patch versions" - exit 1 - fi echo "${path}/${patch}" >> ${builddir}/.applied_patches_list ${uncomp} "${path}/$patch" | patch -g0 -p1 -E --no-backup-if-mismatch -d "${builddir}" -t -N $silent if [ $? != 0 ] ; thenSignature · 6 lines
2.25.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. | '------------------------------^-------^------------------^--------------------'