* [Buildroot] [PATCH] support/scripts/apply-patches.sh: do not apply patches with renames
@ 2017-05-12 10:29 Thomas Petazzoni
2017-05-12 15:40 ` Yann E. MORIN
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2017-05-12 10:29 UTC (permalink / raw)
To: buildroot
Patches with renames apply properly with patch >= 2.7, but not with
older patch versions. Since "git format-patch" by default generates
patches with renames, Buildroot developers often don't realize that
their patches will not apply properly on build machines that have
patch < 2.7. In order to prevent such a situation from happening
again, this commit adds some logic in apply-patches.sh to refuse
applying patches that contain renames.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
support/scripts/apply-patches.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 7ccb39d..6f40280c 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -113,6 +113,11 @@ function apply_patch {
echo " to be applied : ${path}/${patch}"
exit 1
fi
+ if grep -q "^rename from" ${path}/${patch} -a
+ grep -q "^rename to" ${path}/${patch} ; 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 -d "${builddir}" -t -N $silent
if [ $? != 0 ] ; then
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] support/scripts/apply-patches.sh: do not apply patches with renames
2017-05-12 10:29 [Buildroot] [PATCH] support/scripts/apply-patches.sh: do not apply patches with renames Thomas Petazzoni
@ 2017-05-12 15:40 ` Yann E. MORIN
2017-05-12 15:53 ` Thomas Petazzoni
0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2017-05-12 15:40 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2017-05-12 12:29 +0200, Thomas Petazzoni spake thusly:
> Patches with renames apply properly with patch >= 2.7, but not with
> older patch versions. Since "git format-patch" by default generates
> patches with renames, Buildroot developers often don't realize that
> their patches will not apply properly on build machines that have
> patch < 2.7. In order to prevent such a situation from happening
> again, this commit adds some logic in apply-patches.sh to refuse
> applying patches that contain renames.
Meh. path-2.7 was released 5 years ago. Oh well, let's be kind for those
stuck with ancient entreprise-grade distros... ;-)
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> support/scripts/apply-patches.sh | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> index 7ccb39d..6f40280c 100755
> --- a/support/scripts/apply-patches.sh
> +++ b/support/scripts/apply-patches.sh
> @@ -113,6 +113,11 @@ function apply_patch {
> echo " to be applied : ${path}/${patch}"
> exit 1
> fi
> + if grep -q "^rename from" ${path}/${patch} -a
> + grep -q "^rename to" ${path}/${patch} ; then
Oh-oh... Not good: the '-a' will be passed as an option to grep; this
is not a [...] construct.
What you want instead is:
if grep -q "^rename from" ${path}/${patch} && \
grep -q "^rename to" ${path}/${patch} ; then
Regards,
Yann E. MORIN.
> + 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 -d "${builddir}" -t -N $silent
> if [ $? != 0 ] ; then
> --
> 2.7.4
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] support/scripts/apply-patches.sh: do not apply patches with renames
2017-05-12 15:40 ` Yann E. MORIN
@ 2017-05-12 15:53 ` Thomas Petazzoni
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2017-05-12 15:53 UTC (permalink / raw)
To: buildroot
Hello,
On Fri, 12 May 2017 17:40:39 +0200, Yann E. MORIN wrote:
> Meh. path-2.7 was released 5 years ago. Oh well, let's be kind for those
> stuck with ancient entreprise-grade distros... ;-)
Exactly :)
> Oh-oh... Not good: the '-a' will be passed as an option to grep; this
> is not a [...] construct.
>
> What you want instead is:
>
> if grep -q "^rename from" ${path}/${patch} && \
> grep -q "^rename to" ${path}/${patch} ; then
OK, will fix.
However, what bothers me with this is that if the patch description
contains "rename from" and "rename to" at the beginning of two lines,
then it will also trigger this condition.
But I'm not sure if it's a really realistic case, and if it ever
happens, we can always fix/improve the script. Unless there is a better
but still simple way to check if a patch uses renames. Ideally we would
want patch >= 2.7 to bail out if there's a rename, but I couldn't find
any option doing this... and this option would anyway not exist with
patch < 2.7.
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-12 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 10:29 [Buildroot] [PATCH] support/scripts/apply-patches.sh: do not apply patches with renames Thomas Petazzoni
2017-05-12 15:40 ` Yann E. MORIN
2017-05-12 15:53 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox