From fa7d0531bcfc7da3d6fbe7d1c801791530eac5c4 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" 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 This fixes an incorrect propagation of failed trigger return codes in INSTALL scripts. The prior behavior would cause XBPS to ignore any configuration errors and mark packages configured. Now, XBPS will report a failure and leave all packages in the transaction unconfigured. Return codes from triggers in REMOVE scripts are simply ignored. If a trigger fails to run in REMOVE and XBPS notices, the package will not be removal until (or if) the REMOVE script can be made to run error free. This could produce an unrecoverable situation, so it seems better just to ignore failures and proceed with removal (as happened before anyway). --- .../04-create-xbps-metadata-scripts.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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..4b4cd0efdb4c 100644 --- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh +++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh @@ -15,11 +15,13 @@ process_metadata_scripts() { local tmpf=$(mktemp) || exit 1 local fpattern="s|${PKGDESTDIR}||g;s|^\./$||g;/^$/d" local targets= f= _f= info_files= home= shell= descr= groups= - local found= triggers_found= _icondirs= _schemas= _mods= _tmpfiles= + local found= triggers_found= _icondirs= _schemas= _mods= _tmpfiles= trigguard= + # Trigger failures propagate on INSTALL but are ignored on REMOVE + # If REMOVE failures were propagated, packages would be uninstallable case "$action" in - install) ;; - remove) ;; + install) trigguard="exit" ;; + remove) trigguard="true" ;; *) return 1;; esac @@ -326,8 +328,7 @@ _EOF if ! [[ $j =~ pre-${action} ]]; then continue fi - printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE} \${CONF_FILE}\n" >> $tmpf - printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf + printf "\t\${TRIGGERSDIR}/$f run $j \"\${PKGNAME}\" \"\${VERSION}\" \"\${UPDATE}\" \"\${CONF_FILE}\" || ${trigguard}\n" >> $tmpf done done printf "\t;;\n" >> $tmpf @@ -338,8 +339,7 @@ _EOF if ! [[ $j =~ post-${action} ]]; then continue fi - printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION} \${UPDATE} \${CONF_FILE}\n" >> $tmpf - printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf + printf "\t\${TRIGGERSDIR}/$f run $j \"\${PKGNAME}\" \"\${VERSION}\" \"\${UPDATE}\" \"\${CONF_FILE}\" || ${trigguard}\n" >> $tmpf done done printf "\t;;\n" >> $tmpf