diff options
author | jlam <jlam> | 2005-07-27 16:18:54 +0000 |
---|---|---|
committer | jlam <jlam> | 2005-07-27 16:18:54 +0000 |
commit | d269a6cb6eb82948a0712b57da2865b52217836a (patch) | |
tree | 9b9f04a9c23a5f49002db90799835420a87cf343 | |
parent | fd33f6badffa4c16e0f8a111cadffef61f63bec0 (diff) | |
download | pkgsrc-d269a6cb6eb82948a0712b57da2865b52217836a.tar.gz |
Rewrite scripts to be more resilient to shells that exit immediately
if an untested command fails (see sh(1), "-e errexit"). Do this by
changing lines that look like:
test expression && command
to
test ! expression || command
so that the statement list always returns 0. Also, back out revision
1.38 of pkgsrc/mk/install/install and modify the if-test to branch
correctly if +USERGROUP doesn't exist.
-rw-r--r-- | mk/install/deinstall | 20 | ||||
-rw-r--r-- | mk/install/dirs | 8 | ||||
-rw-r--r-- | mk/install/files | 12 | ||||
-rw-r--r-- | mk/install/install | 34 | ||||
-rw-r--r-- | mk/install/usergroup | 6 |
5 files changed, 40 insertions, 40 deletions
diff --git a/mk/install/deinstall b/mk/install/deinstall index 9da0281929d..26f51d0b18a 100644 --- a/mk/install/deinstall +++ b/mk/install/deinstall @@ -1,7 +1,7 @@ # -*- sh -*- # start of deinstall # -# $NetBSD: deinstall,v 1.33 2005/03/21 19:29:46 wiz Exp $ +# $NetBSD: deinstall,v 1.34 2005/07/27 16:18:54 jlam Exp $ case ${STAGE} in VIEW-DEINSTALL) @@ -9,7 +9,7 @@ VIEW-DEINSTALL) YES) case ${PKG_SYSCONFDEPOTBASE} in "") - ${TEST} -x ./+FILES && + ${TEST} ! -x ./+FILES || ./+FILES VIEW-REMOVE ${PREFIX} ${PKG_PREFIX} ;; *) @@ -33,11 +33,11 @@ DEINSTALL) # config file. # case ${_PKG_CONFIG} in - YES) ${TEST} -x ./+FILES && + YES) ${TEST} ! -x ./+FILES || ./+FILES REMOVE ${PKG_METADATA_DIR} ;; esac case ${_PKG_CONFIG}${_PKG_RCD_SCRIPTS} in - YESYES) ${TEST} -x ./+RCD_SCRIPTS && + YESYES) ${TEST} ! -x ./+RCD_SCRIPTS || ./+RCD_SCRIPTS REMOVE ${PKG_METADATA_DIR} ;; esac ;; @@ -54,23 +54,23 @@ POST-DEINSTALL) # Remove empty directories and unused users/groups. # case ${_PKG_CONFIG} in - YES) ${TEST} -x ./+DIRS && + YES) ${TEST} ! -x ./+DIRS || ./+DIRS REMOVE ${PKG_METADATA_DIR} ;; esac case ${_PKG_CREATE_USERGROUP} in - YES) ${TEST} -x ./+USERGROUP && + YES) ${TEST} ! -x ./+USERGROUP || ./+USERGROUP REMOVE ${PKG_METADATA_DIR} ;; esac # # Check for any existing bits after we're finished de-installing. # - ${TEST} -x ./+USERGROUP && + ${TEST} ! -x ./+USERGROUP || ./+USERGROUP CHECK-REMOVE ${PKG_METADATA_DIR} - ${TEST} -x ./+FILES && + ${TEST} ! -x ./+FILES || ./+FILES CHECK-REMOVE ${PKG_METADATA_DIR} - ${TEST} -x ./+RCD_SCRIPTS && + ${TEST} ! -x ./+RCD_SCRIPTS || ./+RCD_SCRIPTS CHECK-REMOVE ${PKG_METADATA_DIR} - ${TEST} -x ./+DIRS && + ${TEST} ! -x ./+DIRS || ./+DIRS CHECK-REMOVE ${PKG_METADATA_DIR} ;; esac diff --git a/mk/install/dirs b/mk/install/dirs index 79a5ebb3e5a..81ba70aa022 100644 --- a/mk/install/dirs +++ b/mk/install/dirs @@ -1,6 +1,6 @@ #!@SH@ # -# $NetBSD: dirs,v 1.5 2005/01/31 21:41:06 jlam Exp $ +# $NetBSD: dirs,v 1.6 2005/07/27 16:18:54 jlam Exp $ # # +DIRS - reference-counted directory management script # @@ -73,7 +73,7 @@ ADD) token="$shadow_dir/${PKGNAME}" if ${TEST} ! -d "$shadow_dir"; then ${MKDIR} $shadow_dir - ${TEST} -d "$dir" && + ${TEST} ! -d "$dir" || ${ECHO} "${PKGNAME}" > $preexist fi ${MKDIR} $dir @@ -136,7 +136,7 @@ CHECK-ADD) { while read dir d_flags d_user d_group d_mode; do case $dir in ""|[!/]*) continue ;; - *) ${TEST} -d "$dir" && continue ;; + *) ${TEST} ! -d "$dir" || continue ;; esac case $d_flags in *m*) ;; @@ -180,7 +180,7 @@ CHECK-REMOVE) *) continue ;; esac shadow_dir="${PKG_REFCOUNT_DIRS_DBDIR}$dir" - ${TEST} -d "$shadow_dir" && continue # refcount isn't zero + ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero case "$printed_header" in yes) ;; *) printed_header=yes diff --git a/mk/install/files b/mk/install/files index 0e94bd9a56a..90372a349b3 100644 --- a/mk/install/files +++ b/mk/install/files @@ -1,6 +1,6 @@ #!@SH@ # -# $NetBSD: files,v 1.5 2005/04/20 17:13:28 seb Exp $ +# $NetBSD: files,v 1.6 2005/07/27 16:18:54 jlam Exp $ # # +FILES - reference-counted configuration file management script # @@ -86,7 +86,7 @@ ADD) token="$shadow_dir/${PKGNAME}" if ${TEST} ! -d "$shadow_dir"; then ${MKDIR} $shadow_dir - ${TEST} -f "$file" && + ${TEST} ! -f "$file" || ${ECHO} "${PKGNAME}" > $preexist fi if ${TEST} -f "$token" && \ @@ -163,7 +163,7 @@ REMOVE) if ${TEST} -f "$preexist"; then : elif ${TEST} -f "$file" -a -f "$f_eg" && \ - ${CMP} -s "$file" "$f_eg"; then + ${CMP} -s "$file" "$f_eg"; then ${RM} -f "$file" fi ${RM} -f $perms $preexist $token $token.tmp.* @@ -198,7 +198,7 @@ CHECK-ADD) { while read file f_flags f_eg f_mode f_user f_group; do case $file in ""|[!/]*) continue ;; - *) ${TEST} -f "$file" && continue ;; + *) ${TEST} ! -f "$file" || continue ;; esac case $f_flags in *c*) ;; @@ -226,7 +226,7 @@ CHECK-ADD) ${ECHO} " $file (o=$f_user, g=$f_group, m=$f_mode)" ;; esac - ${TEST} -f "$f_eg" && ${ECHO} " [$f_eg]" + ${TEST} ! -f "$f_eg" || ${ECHO} " [$f_eg]" done case "$printed_header" in yes) ${ECHO} "" @@ -245,7 +245,7 @@ CHECK-REMOVE) *) ${TEST} -f "$file" || continue ;; esac shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" - ${TEST} -d "$shadow_dir" && continue # refcount isn't zero + ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero case "$printed_header" in yes) ;; *) printed_header=yes diff --git a/mk/install/install b/mk/install/install index ae3daa576e5..6f9a51a5f48 100644 --- a/mk/install/install +++ b/mk/install/install @@ -1,7 +1,7 @@ # -*- sh -*- # start of install # -# $NetBSD: install,v 1.38 2005/07/27 11:54:03 tron Exp $ +# $NetBSD: install,v 1.39 2005/07/27 16:18:54 jlam Exp $ case ${STAGE} in PRE-INSTALL) @@ -9,15 +9,15 @@ PRE-INSTALL) # Require that necessary users and groups exist or else fail the # installation of the package. # - if [ -x ./+USERGROUP ]; then - case ${_PKG_CREATE_USERGROUP} in - YES) ./+USERGROUP ADD ${PKG_METADATA_DIR} ;; - esac - if ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then + case ${_PKG_CREATE_USERGROUP} in + YES) ${TEST} ! -x ./+USERGROUP || + ./+USERGROUP ADD ${PKG_METADATA_DIR} ;; + esac + if ${TEST} ! -x ./+USERGROUP || \ + ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then : - else - exit 1 - fi + else + exit 1 fi # # Create package directories at pre-install time. @@ -37,9 +37,9 @@ PRE-INSTALL) fi fi case ${_PKG_CONFIG} in - YES) ${TEST} -x ./+DIRS && + YES) ${TEST} ! -x ./+DIRS || ./+DIRS ADD ${PKG_METADATA_DIR} ;; - esac + esac ;; POST-INSTALL) @@ -47,26 +47,26 @@ POST-INSTALL) # Copy configuration/support files into place. # case ${_PKG_CONFIG} in - YES) ${TEST} -x ./+FILES && + YES) ${TEST} ! -x ./+FILES || ./+FILES ADD ${PKG_METADATA_DIR} ;; esac case ${_PKG_CONFIG}${_PKG_RCD_SCRIPTS} in - YESYES) ${TEST} -x ./+RCD_SCRIPTS && + YESYES) ${TEST} ! -x ./+RCD_SCRIPTS || ./+RCD_SCRIPTS ADD ${PKG_METADATA_DIR} ;; esac # # Set special permissions on any files/directories that need them. # - ${TEST} -x ./+PERMS && + ${TEST} ! -x ./+PERMS || ./+PERMS ${PKG_METADATA_DIR} # Check for any missing bits after we're finished installing. # - ${TEST} -x ./+DIRS && + ${TEST} ! -x ./+DIRS || ./+DIRS CHECK-ADD ${PKG_METADATA_DIR} - ${TEST} -x ./+FILES && + ${TEST} ! -x ./+FILES || ./+FILES CHECK-ADD ${PKG_METADATA_DIR} - ${TEST} -x ./+RCD_SCRIPTS && + ${TEST} ! -x ./+RCD_SCRIPTS || ./+RCD_SCRIPTS CHECK-ADD ${PKG_METADATA_DIR} ;; diff --git a/mk/install/usergroup b/mk/install/usergroup index 01fd92c7511..32e9d9310d1 100644 --- a/mk/install/usergroup +++ b/mk/install/usergroup @@ -1,6 +1,6 @@ #!@SH@ # -# $NetBSD: usergroup,v 1.8 2005/03/28 19:26:11 jlam Exp $ +# $NetBSD: usergroup,v 1.9 2005/07/27 16:18:54 jlam Exp $ # # +USERGROUP - users and groups management script # @@ -333,7 +333,7 @@ CHECK-REMOVE) *) user_exists $user || continue ;; esac shadow_dir="${PKG_REFCOUNT_USERS_DBDIR}/$user" - ${TEST} -d "$shadow_dir" && continue # refcount isn't zero + ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero existing_users="$existing_users $user" done case $existing_users in @@ -360,7 +360,7 @@ CHECK-REMOVE) *) group_exists $group || continue ;; esac shadow_dir="${PKG_REFCOUNT_GROUPS_DBDIR}/$group" - ${TEST} -d "$shadow_dir" && continue # refcount isn't zero + ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero existing_groups="$existing_groups $group" done case $existing_groups in |