# HG changeset patch # User Franz Glasner # Date 1568273642 -7200 # Node ID e8c422379abb77a588ade4aa43064cb77868a905 # Parent c9fb9e920a32a366fb2345537b617faab9088ce4 Do package checks only for jails with compatible (i.e. "equal") userland versions with the host diff -r c9fb9e920a32 -r e8c422379abb bin/fpkg --- a/bin/fpkg Mon Sep 09 09:43:13 2019 +0200 +++ b/bin/fpkg Thu Sep 12 09:34:02 2019 +0200 @@ -68,6 +68,31 @@ : ${UPDATE_FLAGS:=} : ${UPGRADE_FLAGS:=} : ${SIGN:='===> '} +: ${SKIPSIGN:='-----> '} + + +has_same_userland_version() { + : 'Check whether the jail `_jail` has the same FreeBSD userland version + as the host the the current process runs. + + Args: + _jail: the running jail to check for + + Returns: + 0 if the userland versions match, 1 otherwise + + ' + local _jail _host_version _jail_version + + _jail="$1" + + _host_version=$(/bin/freebsd-version -u) || exit 1 + _jail_version=$(jexec -l "${_jail}" /bin/freebsd-version -u) || exit 1 + if [ "${_host_version%%-*}" = "${_jail_version%%-*}" ]; then + return 0 + fi + return 1 +} command_audit() { @@ -79,7 +104,11 @@ for _j in $(jls -N | awk '{if(NR>1)print $1}' | sort); do echo "" echo "${SIGN}JAIL: ${_j}" - pkg -j "${_j}" audit ${AUDIT_FLAGS} + if has_same_userland_version "${_j}"; then + pkg -j "${_j}" audit ${AUDIT_FLAGS} + else + echo "${SKIPSIGN}SKIPPED because of different userland" + fi done } @@ -93,7 +122,11 @@ for _j in $(jls -N | awk '{if(NR>1)print $1}' | sort); do echo "" echo "${SIGN}JAIL: ${_j}" - pkg -j "${_j}" update ${UPDATE_FLAGS} + if has_same_userland_version "${_j}"; then + pkg -j "${_j}" update ${UPDATE_FLAGS} + else + echo "${SKIPSIGN}SKIPPED because of different userland" + fi done } @@ -107,7 +140,11 @@ for _j in $(jls -N | awk '{if(NR>1)print $1}' | sort); do echo "" echo "${SIGN}JAIL: ${_j}" - pkg -j "${_j}" upgrade ${UPGRADE_FLAGS} + if has_same_userland_version "${_j}"; then + pkg -j "${_j}" upgrade ${UPGRADE_FLAGS} + else + echo "${SKIPSIGN}SKIPPED because of different userland" + fi done } @@ -121,7 +158,11 @@ for _j in $(jls -N | awk '{if(NR>1)print $1}' | sort); do echo "" echo "${SIGN}JAIL: ${_j}" - pkg -j "${_j}" upgrade -n ${UPGRADE_FLAGS} + if has_same_userland_version "${_j}"; then + pkg -j "${_j}" upgrade -n ${UPGRADE_FLAGS} + else + echo "${SKIPSIGN}SKIPPED because of different userland" + fi done }