firmware: rework opnsense-version again

This commit is contained in:
Franco Fichtner 2018-11-29 08:22:50 +00:00
parent 453946df33
commit c95c82cb87
4 changed files with 46 additions and 52 deletions

View File

@ -279,7 +279,7 @@ if [ "$pkg_running" == "" ]; then
fi
if [ -n "$base_to_reboot" ]; then
base_to_delete="$(opnsense-version -vp base)"
base_to_delete="$(opnsense-version -v base)"
base_is_size="$(opnsense-update -bfSr $base_to_reboot)"
if [ "$base_to_reboot" != "$base_to_delete" -a -n "$base_is_size" ]; then
if [ "$packages_upgraded" == "" ]; then
@ -307,7 +307,7 @@ if [ "$pkg_running" == "" ]; then
fi
if [ -n "$kernel_to_reboot" ]; then
kernel_to_delete="$(opnsense-version -vp kernel)"
kernel_to_delete="$(opnsense-version -v kernel)"
kernel_is_size="$(opnsense-update -fkSr $kernel_to_reboot)"
if [ "$kernel_to_reboot" != "$kernel_to_delete" -a -n "$kernel_is_size" ]; then
if [ "$packages_upgraded" == "" ]; then

View File

@ -71,7 +71,7 @@ set_check()
return
fi
VER=$(opnsense-version -p ${SET})
VER=$(opnsense-version -v ${SET})
echo ">>> Check installed ${SET} version" >> ${PKG_PROGRESS_FILE}
if [ -z "${VER}" -o -z "${VERSION}" ]; then

View File

@ -28,11 +28,11 @@ LIC="BSD2CLAUSE"
OS="HardenedBSD"
SEP=${1:-","}
BV=$(opnsense-version -vp base)
KV=$(opnsense-version -vp kernel)
BV=$(opnsense-version -v base)
KV=$(opnsense-version -v kernel)
BS=$(opnsense-version -sp base)
KS=$(opnsense-version -sp kernel)
BS=$(opnsense-version -s base)
KS=$(opnsense-version -s kernel)
BL=0
KL=0

View File

@ -25,17 +25,13 @@
VERSIONDIR="/usr/local/opnsense/version"
OPENSSL="/usr/local/bin/openssl"
TARGET="core"
OUTPUT=
DO_ARCH=
DO_PKG="-p core"
DO_SIZE=
while getopts AaefHNnp:svw OPT; do
while getopts AaefHNnsvw OPT; do
case ${OPT} in
A)
OUTPUT="${OUTPUT} \${product_arch}"
DO_ARCH="-A"
;;
a)
OUTPUT="${OUTPUT} \${product_abi}"
@ -55,11 +51,8 @@ while getopts AaefHNnp:svw OPT; do
n)
OUTPUT="${OUTPUT} \${product_id}"
;;
p)
DO_PKG="-p ${OPTARG}"
;;
s)
DO_SIZE="-s"
OUTPUT="${OUTPUT} \${product_size}"
;;
v)
OUTPUT="${OUTPUT} \${product_version}"
@ -76,53 +69,54 @@ done
shift $((${OPTIND} - 1))
if [ -n "${1}" ]; then
TARGET=${1}
shift
fi
if [ -n "${*}" ]; then
echo "Arguments are not supported" >&2
echo "Additional arguments are not supported" >&2
exit 1
fi
VERSION="${VERSIONDIR}/${DO_PKG#"-p "}"
if [ "${DO_PKG}" != "-p core" ]; then
if [ -n "${DO_SIZE}" ]; then
VERSION="${VERSION}.size"
elif [ -n "${DO_ARCH}" ]; then
VERSION="${VERSION}.arch"
fi
if [ ! -f ${VERSION} ]; then
echo "Missing ${VERSION}" >&2
exit 1
fi
OUTPUT=$(cat ${VERSION})
# XXX this is only required for base/kernel
# with old version number that has arch in it
echo ${OUTPUT%-*}
exit 0
fi
VERSION="${VERSIONDIR}/${TARGET}"
if [ ! -f ${VERSION} ]; then
echo "Missing ${VERSION}" >&2
exit 1
fi
if [ -n "${DO_SIZE}" ]; then
# unsupported
echo "Missing ${VERSION}.size" >&2
exit 1
fi
case "${TARGET}" in
core)
eval "$(grep -v '[{}]' ${VERSION} | sed 's/[^"]*"\([^"]*\)"[^"]*"\([^"]*\)".*/\1="\2"/')"
eval "$(grep -v '[{}]' ${VERSION} | sed 's/[^"]*"\([^"]*\)"[^"]*"\([^"]*\)".*/\1="\2"/')"
if [ -z "${OUTPUT}" ]; then
OUTPUT="\${product_name} \${product_version} \(\${product_arch}/\${product_flavour}\)"
fi
if [ -z "${OUTPUT}" ]; then
OUTPUT="\${product_name} \${product_version} \(\${product_arch}/\${product_flavour}\)"
fi
if [ -z "${OUTPUT%%*product_flavour*}" -a -f ${OPENSSL} ]; then
RESULT=$(${OPENSSL} version)
product_flavour=${RESULT%% *}
fi
;;
*)
if [ -z "${OUTPUT}" ]; then
OUTPUT="\${product_version}"
fi
if [ -z "${OUTPUT%%*product_flavour*}" -a -f ${OPENSSL} ]; then
RESULT=$(${OPENSSL} version)
product_flavour=${RESULT%% *}
fi
if [ -z "${OUTPUT%%*product_version*}" -a -f ${VERSION} ]; then
RESULT=$(cat ${VERSION})
# XXX this is only required for base/kernel
# with old version number that has arch in it
product_version=${RESULT%-*}
fi
if [ -z "${OUTPUT%%*product_size*}" -a -f ${VERSION}.size ]; then
product_size=$(cat ${VERSION}.size)
fi
if [ -z "${OUTPUT%%*product_arch*}" -a -f ${VERSION}.arch ]; then
product_arch=$(cat ${VERSION}.arch)
fi
;;
esac
eval echo ${OUTPUT}