summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2016-11-01 12:41:47 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2016-11-01 12:41:47 +0000
commit6cf7290dcfcd4b2cb95a089650c75a2446756230 (patch)
treef316157a75b6bcbecb198adecc31eea5e0280c03 /usr.sbin
parentd6386ca5f749d253900e6c84c6343d000d3b5c15 (diff)
Add a few error messages so we know where we fail.
Regular operation is mostly quiet, i.e: Applying syspatch-60-001_cp.tgz 100% |***********************| 65247 00:03 Move trap after we create the temporary directory so that we can remove it on failure and fix a typo in readonly vars.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syspatch/syspatch.sh25
1 files changed, 15 insertions, 10 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh
index c2faa583a4c..a6b62c57f6a 100644
--- a/usr.sbin/syspatch/syspatch.sh
+++ b/usr.sbin/syspatch/syspatch.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: syspatch.sh,v 1.17 2016/11/01 10:30:01 ajacoutot Exp $
+# $OpenBSD: syspatch.sh,v 1.18 2016/11/01 12:41:46 ajacoutot Exp $
#
# Copyright (c) 2016 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -18,8 +18,6 @@
set -e
-trap "rm -rf ${_TMP}; exit 1" 2 3 9 13 15 ERR
-
sp_err()
{
echo "${@}" 1>&2 && return 1
@@ -49,11 +47,13 @@ apply_patch()
for _file in ${_files}; do
if [[ ${_file} == @(bsd|bsd.mp) ]]; then
if ! install_kernel ${_explodir}/${_file}; then
- rollback_patch; return 1
+ rollback_patch
+ sp_err "Failed to apply ${_patch} (/${_file})"
fi
else
if ! install_file ${_explodir}/${_file} /${_file}; then
- rollback_patch; return 1
+ rollback_patch
+ sp_err "Failed to apply ${_patch} (/${_file})"
fi
fi
done
@@ -103,7 +103,8 @@ create_rollback()
${_rbfiles}
fi
); then
- rm ${_PDIR}/${_REL}/rollback-${_patch}.tgz; return 1
+ rm ${_PDIR}/${_REL}/rollback-${_patch}.tgz
+ sp_err "Failed to create rollback for ${_patch}"
fi
}
@@ -119,7 +120,7 @@ fetch_and_verify()
for _p in ${_patch}; do
_p=${_p}.tgz
- ${_FETCH} -mD "Get/Verify" -o "${_TMP}/${_p}" \
+ ${_FETCH} -mD "Applying" -o "${_TMP}/${_p}" \
"${PATCH_PATH}/${_p}"
(cd ${_TMP} &&
/usr/bin/signify -qC -p ${_key} -x SHA256.sig ${_p})
@@ -205,9 +206,11 @@ rollback_patch()
for _file in ${_files}; do
if [[ ${_file} == @(bsd|bsd.mp) ]]; then
- install_kernel ${_explodir}/${_file}
+ install_kernel ${_explodir}/${_file} ||
+ sp_err "Failed to rollback ${_patch} (/${_file})"
else
- install_file ${_explodir}/${_file} /${_file}
+ install_file ${_explodir}/${_file} /${_file} ||
+ sp_err "Failed to rollback ${_patch} (/${_file})"
fi
done
@@ -234,7 +237,9 @@ _PDIR="/var/syspatch"
_REL=${_KERNV[0]}
_RELINT=${_REL%\.*}${_REL#*\.}
_TMP=$(mktemp -d -p /tmp syspatch.XXXXXXXXXX)
-readonly _BSDMP _FETCH _PDIR _REL _RELINT_TMP
+readonly _BSDMP _FETCH _PDIR _REL _RELINT _TMP
+
+trap "rm -rf ${_TMP}; exit 1" 2 3 9 13 15 ERR
while getopts clr arg; do
case ${arg} in