summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syspatch
diff options
context:
space:
mode:
authorajacoutot <ajacoutot@openbsd.org>2017-07-04 20:25:53 +0000
committerajacoutot <ajacoutot@openbsd.org>2017-07-04 20:25:53 +0000
commit09585cb75a41e8f9af1c1a201e3314b324ef5808 (patch)
tree38bb7523f1a248bd43544c2230f4d959528147db /usr.sbin/syspatch
parentmake relayd not crash in relay_udp_server() when using a dns relay. (diff)
downloadwireguard-openbsd-09585cb75a41e8f9af1c1a201e3314b324ef5808.tar.xz
wireguard-openbsd-09585cb75a41e8f9af1c1a201e3314b324ef5808.zip
Detect upfront whether we have a particular set installed and if not, do *not*
list a matching syspatch as available. This will allow to skip the syspatches for the X sets for example if we don't have them installed. If we do install these sets a posteriori, then syspatch *will* list the X syspatches if there are any. req. by many ok robert@
Diffstat (limited to 'usr.sbin/syspatch')
-rw-r--r--usr.sbin/syspatch/syspatch.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh
index a4eb76b43f3..fcc9790c4f2 100644
--- a/usr.sbin/syspatch/syspatch.sh
+++ b/usr.sbin/syspatch/syspatch.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: syspatch.sh,v 1.114 2017/06/09 07:37:38 ajacoutot Exp $
+# $OpenBSD: syspatch.sh,v 1.115 2017/07/04 20:25:53 ajacoutot Exp $
#
# Copyright (c) 2016, 2017 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -48,12 +48,6 @@ apply_patch()
checkfs ${_files}
create_rollback ${_patch} "${_files}"
- # create_rollback(): tar(1) was fed with an empty list of files; that is
- # not an error but no tarball is created; this happens if no earlier
- # version of the files contained in the syspatch exists on the system
- [[ ! -f ${_PDIR}/${_patch}/rollback.tgz ]] && unset _files &&
- echo "Missing set, skipping patch ${_patch##${_OSrev}-}"
-
for _file in ${_files}; do
((_ret == 0)) || break
if [[ ${_file} == @(bsd|bsd.mp) ]]; then
@@ -188,7 +182,7 @@ ls_installed()
ls_missing()
{
- local _c _l="$(ls_installed)" _sha=${_TMP}/SHA256
+ local _c _f _cmd _l="$(ls_installed)" _p _r _sha=${_TMP}/SHA256
# return inmediately if we cannot reach the mirror server
[[ -d ${_MIRROR#file://*} ]] ||
@@ -201,9 +195,17 @@ ls_missing()
unpriv -f "${_sha}" signify -Veq -x ${_sha}.sig -m ${_sha} -p \
/etc/signify/openbsd-${_OSrev}-syspatch.pub >/dev/null
+ # if no earlier version of all files contained in the syspatch exists
+ # on the system, it means a missing set so skip it
grep -Eo "syspatch${_OSrev}-[[:digit:]]{3}_[[:alnum:]_]+" ${_sha} |
while read _c; do _c=${_c##syspatch${_OSrev}-} &&
[[ -n ${_l} ]] && echo ${_c} | grep -qw -- "${_l}" || echo ${_c}
+ done | while read _p; do
+ _cmd="ftp -MVo - ${_MIRROR}/syspatch${_OSrev}-${_p}.tgz"
+ { unpriv ${_cmd} | tar tzf -; } 2>/dev/null | while read _f; do
+ [[ -f /${_f} ]] || continue && echo ${_p} && pkill -u \
+ _syspatch -xf "${_cmd}" || true && break
+ done
done | sort -V
}