Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] common/hooks/post-install/04-create-xbps-metadata-scripts.sh: fix return code of failed trigger runs
@ 2021-07-22  3:03 ahesford
  2021-07-22  3:26 ` [PR PATCH] [Updated] " ahesford
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ahesford @ 2021-07-22  3:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages trigger-fix
https://github.com/void-linux/void-packages/pull/32120

common/hooks/post-install/04-create-xbps-metadata-scripts.sh: fix return code of failed trigger runs
When a template defines `$triggers`, `xbps-src` writes an `INSTALL` script that will invoke the triggers. If the triggers fail, the test in

    [ $? -ne 0 ] && exit $?

will succeed and `exit` will be invoked. However, at the time `exit` is invoked, `$?` will take the value of *the test* `[ $? -ne 0 ]`, which is always `0` (or else the `&&` will short-circuit and the `exit` will not run).

The right thing to do is capture `$?` in a persistent variable, `$ret`, that can be tested and returned to properly forward the failure code through the trigger.

**NOTE**: This needs a bit of testing, because I don't yet understand the ramifications for `xbps-install` receiving a non-zero trigger return when all of them have returned `0` thus far.

A patch file from https://github.com/void-linux/void-packages/pull/32120.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-trigger-fix-32120.patch --]
[-- Type: text/x-diff, Size: 1393 bytes --]

From bfd6844d41351f6621cbce819cf305d65d30ae9b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 21 Jul 2021 22:57:10 -0400
Subject: [PATCH] common/hooks/post-install/04-create-xbps-metadata-scripts.sh:
   fix return code of failed trigger runs

---
 .../hooks/post-install/04-create-xbps-metadata-scripts.sh   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 8bb86c4487a5..406a6fc233f7 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -327,7 +327,8 @@ _EOF
 					continue
 				fi
 				printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE} \${CONF_FILE}\n" >> $tmpf
-				printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf
+				printf "\tret=\$?\n" >> $tmpf
+				printf "\t[ \$ret -ne 0 ] && exit \$ret\n" >> $tmpf
 			done
 		done
 		printf "\t;;\n" >> $tmpf
@@ -339,7 +340,8 @@ _EOF
 					continue
 				fi
 				printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE} \${CONF_FILE}\n" >> $tmpf
-				printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf
+				printf "\tret=\$?\n" >> $tmpf
+				printf "\t[ \$ret -ne 0 ] && exit \$ret\n" >> $tmpf
 			done
 		done
 		printf "\t;;\n" >> $tmpf

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-11 17:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22  3:03 [PR PATCH] common/hooks/post-install/04-create-xbps-metadata-scripts.sh: fix return code of failed trigger runs ahesford
2021-07-22  3:26 ` [PR PATCH] [Updated] " ahesford
2021-07-22  3:30 ` ahesford
2021-08-31 15:39 ` [PR PATCH] [Updated] " ahesford
2021-08-31 15:39 ` ahesford
2021-08-31 15:41 ` ahesford
2022-05-30  2:15 ` github-actions
2022-10-10 10:23 ` Duncaen
2022-10-11 17:48 ` [PR PATCH] [Closed]: " ahesford
2022-10-11 17:53 ` ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).