summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syspatch
diff options
context:
space:
mode:
authorajacoutot <ajacoutot@openbsd.org>2017-08-29 10:21:23 +0000
committerajacoutot <ajacoutot@openbsd.org>2017-08-29 10:21:23 +0000
commit046212ab0b9f4e0d6726c57593108fc77a208983 (patch)
tree32d437f28667917aafb518ebc11fa7a10d8bc8ab /usr.sbin/syspatch
parentFix logic to not error out. (diff)
downloadwireguard-openbsd-046212ab0b9f4e0d6726c57593108fc77a208983.tar.xz
wireguard-openbsd-046212ab0b9f4e0d6726c57593108fc77a208983.zip
While failing to relink the kernel is not fatal to syspatch, we still need
to warn the user and return a proper error code.
Diffstat (limited to 'usr.sbin/syspatch')
-rw-r--r--usr.sbin/syspatch/syspatch.sh40
1 files changed, 26 insertions, 14 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh
index 2c65e8b5ed2..fdd7f82384f 100644
--- a/usr.sbin/syspatch/syspatch.sh
+++ b/usr.sbin/syspatch/syspatch.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: syspatch.sh,v 1.126 2017/08/29 10:18:07 ajacoutot Exp $
+# $OpenBSD: syspatch.sh,v 1.127 2017/08/29 10:21:23 ajacoutot Exp $
#
# Copyright (c) 2016, 2017 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -182,12 +182,6 @@ ls_missing()
done | sort -V
}
-reorder_kernel()
-{
- echo "Relinking to create unique kernel..."
- /usr/libexec/reorder_kernel
-}
-
rollback_patch()
{
local _edir _file _files _patch _ret=0
@@ -221,6 +215,30 @@ rollback_patch()
_KARL=true
}
+trap_handler()
+{
+ local _ret
+
+ set +e # we're trapped
+ rm -rf "${_TMP}"
+
+ # in case a patch added a new directory (install -D)
+ if [[ -n ${_PATCHES} ]]; then
+ mtree -qdef /etc/mtree/4.4BSD.dist -p / -U >/dev/null
+ [[ -f /var/sysmerge/xetc.tgz ]] &&
+ mtree -qdef /etc/mtree/BSD.x11.dist -p / -U >/dev/null
+ fi
+
+ if ${_KARL}; then
+ echo -n "Relinking to create unique kernel..."
+ if /usr/libexec/reorder_kernel; then
+ echo " done."
+ else
+ _ret=$?; echo " failed!"; exit ${_ret}
+ fi
+ fi
+}
+
unpriv()
{
local _file=$2 _user=_syspatch
@@ -260,7 +278,7 @@ _KARL=false
readonly _BSDMP _KERNV _MIRROR _OSrev _PDIR _TMP
-trap 'set +e; ${_KARL} && reorder_kernel; rm -rf "${_TMP}"' EXIT
+trap 'trap_handler' EXIT
trap exit HUP INT TERM
while getopts clRr arg; do
@@ -289,10 +307,4 @@ if ((OPTIND == 1)); then
for _PATCH in ${_PATCHES}; do
apply_patch ${_OSrev}-${_PATCH}
done
- # in case a patch added a new directory (install -D)
- if [[ -n ${_PATCHES} ]]; then
- mtree -qdef /etc/mtree/4.4BSD.dist -p / -U >/dev/null
- [[ ! -f /var/sysmerge/xetc.tgz ]] ||
- mtree -qdef /etc/mtree/BSD.x11.dist -p / -U >/dev/null
- fi
fi