diff --git a/Makefile b/Makefile index 5f7473c65..0590fb634 100644 --- a/Makefile +++ b/Makefile @@ -44,19 +44,15 @@ _CORE_NEXT= ${CORE_ABI:C/\./ /} .if ${_CORE_NEXT:[2]} == 7 # community CORE_NEXT!= expr ${_CORE_NEXT:[1]} + 1 CORE_NEXT:= ${CORE_NEXT}.1 -CORE_ALTABI?= ${CORE_ABI} .elif ${_CORE_NEXT:[2]} == 10 # business CORE_NEXT!= expr ${_CORE_NEXT:[1]} + 1 CORE_NEXT:= ${CORE_NEXT}.4 -CORE_ALTABI?= ${_CORE_NEXT:[1]}.7 .elif ${_CORE_NEXT:[2]} == 1 # community CORE_NEXT= ${_CORE_NEXT:[1]} CORE_NEXT:= ${CORE_NEXT}.7 -CORE_ALTABI?= ${CORE_ABI} .elif ${_CORE_NEXT:[2]} == 4 # business CORE_NEXT= ${_CORE_NEXT:[1]} CORE_NEXT:= ${CORE_NEXT}.10 -CORE_ALTABI?= ${_CORE_NEXT:[1]}.1 .else .error Unsupported minor version for CORE_ABI=${CORE_ABI} .endif diff --git a/Mk/defaults.mk b/Mk/defaults.mk index 480808e1e..9c4e1190e 100644 --- a/Mk/defaults.mk +++ b/Mk/defaults.mk @@ -76,7 +76,6 @@ CORE_SYSLOGNG?= ${_CORE_SYSLOGNG:S/./ /g:[1..2]:tW:S/ /./g} .endif REPLACEMENTS= CORE_ABI \ - CORE_ALTABI \ CORE_ARCH \ CORE_COMMIT \ CORE_COPYRIGHT_HOLDER \ diff --git a/src/man/man8/opnsense-version.8 b/src/man/man8/opnsense-version.8 index 5add9c196..1eb2f99ab 100644 --- a/src/man/man8/opnsense-version.8 +++ b/src/man/man8/opnsense-version.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 17, 2021 +.Dd November 9, 2021 .Dt OPNSENSE-VERSION 8 .Os .Sh NAME @@ -93,8 +93,12 @@ Return the package series. Return the package version. .It Fl w Return the product version website. -.It Fl a -Return the firmware ALTABI string. +.It Fl x +Return the required ABI string. +This is necessary for detecting an ABI-crossing that +requires a clean reinstall of all packages and for +manipulating the target ABI going to and away from +the business mirror. .El .Sh FILES .Bl -tag -width Ds diff --git a/src/opnsense/version/core.in b/src/opnsense/version/core.in index 2ce7bf159..e7aa1b5c9 100644 --- a/src/opnsense/version/core.in +++ b/src/opnsense/version/core.in @@ -1,6 +1,5 @@ { "product_abi": "%%CORE_ABI%%", - "product_altabi": "%%CORE_ALTABI%%", "product_arch": "%%CORE_ARCH%%", "product_copyright_owner": "%%CORE_COPYRIGHT_HOLDER%%", "product_copyright_url": "%%CORE_COPYRIGHT_WWW%%", diff --git a/src/sbin/opnsense-version b/src/sbin/opnsense-version index 9d4b29486..7fb38cd95 100755 --- a/src/sbin/opnsense-version +++ b/src/sbin/opnsense-version @@ -25,6 +25,7 @@ DEFAULTS="\${product_name} \${product_version}" VERSIONDIR="/usr/local/opnsense/version" +PLUGINCTL="/usr/local/sbin/pluginctl" OPENSSL="/usr/local/bin/openssl" PKG="/usr/local/sbin/pkg-static" TARGET="core" @@ -74,7 +75,7 @@ while getopts AacefHiNnsVvwx OPT; do OUTPUT="${OUTPUT} \${product_website}" ;; x) - OUTPUT="${OUTPUT} \${product_altabi}" + OUTPUT="${OUTPUT} \${target_abi_major}.\${target_abi_minor}" ;; *) echo "Usage: man ${0##*/}" >&2 @@ -128,6 +129,36 @@ core) RESULT=$(${PKG} info -s ${product_id}) product_size=${RESULT##* } fi + if [ -z "${OUTPUT%%*target_abi*}" -a -f ${PLUGINCTL} ]; then + target_abi_major=${product_abi%%.*} + target_abi_minor=${product_abi#*.} + + IS_BUSINESS=$(echo ${product_name} | grep -c -- '-business') + WANT_BUSINESS=$(${PLUGINCTL} -g system.firmware.mirror | \ + grep -c 'opnsense-update\.deciso\.com') + + if [ "${IS_BUSINESS}${WANT_BUSINESS}" = "01" -o ]; then + case ${target_abi_minor} in + 1[0-2]) + target_abi_major=$((target_abi_major + 1)) + target_abi_minor=$((target_abi_minor - 9)) + ;; + *) + target_abi_minor=$((target_abi_minor + 3)) + ;; + esac + elif [ "${IS_BUSINESS}${WANT_BUSINESS}" = "10" ]; then + case ${target_abi_minor} in + [1-3]) + target_abi_major=$((target_abi_major - 1)) + target_abi_minor=$((target_abi_minor + 9)) + ;; + *) + target_abi_minor=$((target_abi_minor - 3)) + ;; + esac + fi + fi ;; *) if [ -z "${OUTPUT}" ]; then