Skip to contentSkip to conversation

support/apply-patches: re-instate set -e

PATCH New Yann E. MORIN 3 participants 3 messages Jul 5, 2016 – Jul 6, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/apply-patches: re-instate set -e

As reported by S?bastien Szymanski [1], the apply-patches script doesn't stop if a tar command can't extract an archive.

Use "set -e" to exit immediately if a command return an error.

Be sure to ignore any expected error: when we check if a patch to be applied has the same basename as an already applied patch, the grep would fail when no such patch was already applied. We should not fail in this case.

Cc S?bastien Szymanski <[email protected]>
Cc Romain Naour <[email protected]>

---
Tested with:
make defconfig
make allyespackageconfig
[remove luainterpreter to avoid multiple providers for
luainterpreter; disable qemu-user; disable tar rootfs]
make source
make $(make -s show-targets |sed -r -e 's/ |$/-patch /g')

---
 support/scripts/apply-patches.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
support/scripts/apply-patches.sh +3 -1
index 694302d..7ccb39d 100755
@@ -31,6 +31,8 @@
 # applied. The list of the patches applied is stored in '.applied_patches_list'
 # file in the build directory.
 
+set -e
+
 silent=
 if [ "$1" = "-s" ] ; then
     # add option to be used by the patch tool
@@ -103,7 +105,7 @@ function apply_patch {
         echo "Error: missing patch file ${path}/$patch"
         exit 1
     fi
-    existing="$(grep -E "/${patch}\$" ${builddir}/.applied_patches_list)"
+    existing="$(grep -E "/${patch}\$" ${builddir}/.applied_patches_list || true)"
     if [ -n "${existing}" ]; then
         echo "Error: duplicate filename '${patch}'"
         echo "Conflicting files are:"
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 support/apply-patches: re-instate set -e

Hi Yann,

Le 05/07/2016 ? 19:36, Yann E. MORIN a ?crit :

Quoted 9 lines

As reported by S?bastien Szymanski [1], the apply-patches script doesn't stop if a tar command can't extract an archive.

Use "set -e" to exit immediately if a command return an error.

Be sure to ignore any expected error: when we check if a patch to be applied has the same basename as an already applied patch, the grep would fail when no such patch was already applied. We should not fail in this case.

Thanks for the respin!

Sorry about the mess in the autobuilder yesterday.. lesson learned :)

Quoted 5 lines
Cc S?bastien Szymanski <[email protected]>
Cc Romain Naour <[email protected]>
Quoted 8 lines

---
Tested with:
make defconfig
make allyespackageconfig
[remove luainterpreter to avoid multiple providers for
luainterpreter; disable qemu-user; disable tar rootfs]
make source
make $(make -s show-targets |sed -r -e 's/ |$/-patch /g')

Tested with the commands above.

Best regards,
Romain

Quoted 27 lines
---
 support/scripts/apply-patches.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
support/scripts/apply-patches.sh +3 -1
index 694302d..7ccb39d 100755
@@ -31,6 +31,8 @@
 # applied. The list of the patches applied is stored in '.applied_patches_list'
 # file in the build directory.
 
+set -e
+
 silent=
 if [ "$1" = "-s" ] ; then
     # add option to be used by the patch tool
@@ -103,7 +105,7 @@ function apply_patch {
         echo "Error: missing patch file ${path}/$patch"
         exit 1
     fi
-    existing="$(grep -E "/${patch}\$" ${builddir}/.applied_patches_list)"
+    existing="$(grep -E "/${patch}\$" ${builddir}/.applied_patches_list || true)"
     if [ -n "${existing}" ]; then
         echo "Error: duplicate filename '${patch}'"
         echo "Conflicting files are:"
#2 lore raw

PATCH 1/1 support/apply-patches: re-instate set -e

In reply to Yann E. MORIN

Hello,

Quoted 22 lines · Yann E. MORIN

As reported by S?bastien Szymanski [1], the apply-patches script doesn't stop if a tar command can't extract an archive.

Use "set -e" to exit immediately if a command return an error.

Be sure to ignore any expected error: when we check if a patch to be applied has the same basename as an already applied patch, the grep would fail when no such patch was already applied. We should not fail in this case.

Cc S?bastien Szymanski <[email protected]>
Cc Romain Naour <[email protected]>

---
Tested with:
make defconfig
make allyespackageconfig
[remove luainterpreter to avoid multiple providers for
luainterpreter; disable qemu-user; disable tar rootfs]
make source
make $(make -s show-targets |sed -r -e 's/ |$/-patch /g')

Quoted 3 lines
---
 support/scripts/apply-patches.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com