mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 00:07:27 +00:00
firmware: firmware-product, src/opnsense/version/opnsense, etc.
Now that we have metadata injection at build time read it instead of its auxiliary files. Allow live-mount to snoop the metadata and afterwards we can start to marry the version and firmware-product file. Last puzzle piece will be a tool called "opnsense-version" to read the JSON metadata and return it in a piecemeal fashion of a part of the system requires that info, especially from the shell.
This commit is contained in:
parent
8d6a9b4197
commit
90296833f9
@ -33,9 +33,6 @@ rm -f /etc/rc.shutdown.bak
|
||||
|
||||
echo "Writing package metadata"
|
||||
mkdir -p /usr/local/opnsense/version
|
||||
if [ -f /usr/local/opnsense/version/opnsense ]; then
|
||||
mv /usr/local/opnsense/version/opnsense /usr/local/opnsense/version/opnsense.last
|
||||
fi
|
||||
echo "%%CORE_COMMIT%%" > /usr/local/opnsense/version/opnsense
|
||||
echo "%%CORE_NAME%%" > /usr/local/opnsense/version/opnsense.name
|
||||
echo "%%CORE_ABI%%" > /usr/local/opnsense/version/opnsense.abi
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
/usr/local/etc/rc.d/configd stop
|
||||
|
||||
cp /usr/local/opnsense/firmware-product /usr/local/opnsense/firmware-product.last
|
||||
|
||||
echo "Resetting root shell"
|
||||
pw usermod -n root -s /bin/csh
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,4 +11,5 @@
|
||||
/src/etc/ssh/**
|
||||
/src/lib/**
|
||||
/src/opnsense/changelog
|
||||
/src/opnsense/firmware-product
|
||||
/src/www/wpad.dat
|
||||
|
||||
3
Makefile
3
Makefile
@ -153,6 +153,8 @@ want-${WANT}:
|
||||
mount:
|
||||
@if [ ! -f ${WRKDIR}/.mount_done ]; then \
|
||||
echo -n "Enabling core.git live mount..."; \
|
||||
sed ${SED_REPLACE} ${.CURDIR}/src/opnsense/firmware-product.in > \
|
||||
${.CURDIR}/src/opnsense/firmware-product; \
|
||||
echo "${CORE_COMMIT}" > \
|
||||
${.CURDIR}/src/opnsense/version/opnsense; \
|
||||
mount_unionfs ${.CURDIR}/src ${LOCALBASE}; \
|
||||
@ -166,6 +168,7 @@ umount:
|
||||
echo -n "Disabling core.git live mount..."; \
|
||||
umount -f "<above>:${.CURDIR}/src"; \
|
||||
rm ${.CURDIR}/src/opnsense/version/opnsense; \
|
||||
rm ${.CURDIR}/src/opnsense/firmware-product; \
|
||||
rm ${WRKDIR}/.mount_done; \
|
||||
echo "done"; \
|
||||
service configd restart; \
|
||||
|
||||
@ -856,7 +856,7 @@ function get_memory() {
|
||||
|
||||
function system_firmware_configure($verbose = false)
|
||||
{
|
||||
global $config;
|
||||
global $config, $g;
|
||||
|
||||
if ($verbose) {
|
||||
echo 'Writing firmware setting...';
|
||||
@ -880,8 +880,7 @@ function system_firmware_configure($verbose = false)
|
||||
str_replace('/', '\/', sprintf(
|
||||
"%s{$config['system']['firmware']['flavour']}",
|
||||
/* if there is no directory slash we always treat it with default ABI prefix */
|
||||
strpos($config['system']['firmware']['flavour'], '/') === false ?
|
||||
trim(file_get_contents('/usr/local/opnsense/version/opnsense.abi')) . '/' : ''
|
||||
strpos($config['system']['firmware']['flavour'], '/') === false ? "${g['product_abi']}/" : ''
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,10 +104,12 @@ function merge_config_attributes(&$cnf_source, &$cnf_dest)
|
||||
*/
|
||||
function firmware_version_xmlrpc()
|
||||
{
|
||||
global $g;
|
||||
|
||||
return array(
|
||||
'firmware' => array('version' => file_get_contents('/usr/local/opnsense/version/opnsense')),
|
||||
'kernel' => array('version' => file_get_contents('/usr/local/opnsense/version/kernel')),
|
||||
'base' => array('version' => file_get_contents('/usr/local/opnsense/version/base')),
|
||||
'firmware' => array('version' => "{$g['product_version']}-{$g['product_arch']}"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ RETRIES=5
|
||||
|
||||
COMMAND=${1}
|
||||
|
||||
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null)
|
||||
SYS_ABI=$(opnsense-verify -a 2> /dev/null)
|
||||
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi)
|
||||
SYS_ABI=$(opnsense-verify -a)
|
||||
|
||||
URL="https://pkg.opnsense.org/${SYS_ABI}/${CORE_ABI}/sets/bogons.txz"
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ changelog_remove()
|
||||
|
||||
changelog_fetch()
|
||||
{
|
||||
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null)
|
||||
SYS_ABI=$(opnsense-verify -a 2> /dev/null)
|
||||
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi)
|
||||
SYS_ABI=$(opnsense-verify -a)
|
||||
|
||||
URL="https://pkg.opnsense.org/${SYS_ABI}/${CORE_ABI}/sets/changelog.txz"
|
||||
|
||||
|
||||
@ -34,12 +34,12 @@ require_once("interfaces.inc");
|
||||
require_once("util.inc");
|
||||
require_once("plugins.inc.d/openssh.inc");
|
||||
|
||||
$version = strtok(file_get_contents('/usr/local/opnsense/version/opnsense'), '-');
|
||||
$flavour = strtok(OPENSSL_VERSION_TEXT, ' ');
|
||||
$hostname = $config['system']['hostname'];
|
||||
$machine = trim(shell_exec('uname -p'));
|
||||
$domain = $config['system']['domain'];
|
||||
$version = $g['product_version'];
|
||||
$product = $g['product_name'];
|
||||
$machine = $g['product_arch'];
|
||||
|
||||
echo "\n*** {$hostname}.{$domain}: {$product} {$version} ({$machine}/${flavour}) ***\n";
|
||||
|
||||
|
||||
@ -1,32 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2015-2017 Franco Fichtner <franco@opnsense.org>
|
||||
Copyright (C) 2014 Deciso B.V.
|
||||
Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* Copyright (C) 2015-2018 Franco Fichtner <franco@opnsense.org>
|
||||
* Copyright (C) 2014 Deciso B.V.
|
||||
* Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
|
||||
@ -64,15 +64,15 @@ include('head.inc');
|
||||
|
||||
$plugins = implode(' ', explode("\n", shell_exec('pkg info -g "os-*"')));
|
||||
|
||||
$last_version = '/usr/local/opnsense/version/opnsense.last';
|
||||
$last = json_decode(@file_get_contents('/usr/local/opnsense/firmware-product.last'), true);
|
||||
$crash_report_header = sprintf(
|
||||
"%s\n%s %s%s %s (%s)\n%sTime %s\n",
|
||||
"%s\n%s %s%s (%s/%s)\n%sTime %s\n",
|
||||
php_uname('v'),
|
||||
$g['product_name'],
|
||||
trim(file_get_contents('/usr/local/opnsense/version/opnsense')),
|
||||
file_exists($last_version) ? sprintf(' [%s]', trim(file_get_contents($last_version))) : '',
|
||||
OPENSSL_VERSION_TEXT,
|
||||
trim(shell_exec('uname -p')),
|
||||
"{$g['product_version']}-{$g['product_hash']}",
|
||||
!empty($last['product_version']) ? sprintf(' [%s]', "{$last['product_version']}-{$last['product_hash']}") : '',
|
||||
$g['product_arch'],
|
||||
$g['product_flavour'],
|
||||
empty($plugins) ? '' : "Plugins $plugins\n",
|
||||
date('r')
|
||||
);
|
||||
@ -81,8 +81,7 @@ if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$crash_report_header = "User-Agent {$_SERVER['HTTP_USER_AGENT']}\n{$crash_report_header}";
|
||||
}
|
||||
|
||||
$pkgver = explode('-', trim(file_get_contents('/usr/local/opnsense/version/opnsense')));
|
||||
$user_agent = $g['product_name'] . '/' . $pkgver[0];
|
||||
$user_agent = "{$g['product_name']}/{$g['product_version']}";
|
||||
$crash_reports = array();
|
||||
$has_crashed = false;
|
||||
|
||||
|
||||
@ -1,29 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* Copyright (C) 2016 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function system_api_cpu_stats()
|
||||
{
|
||||
@ -145,7 +146,7 @@ function system_api_versions()
|
||||
|
||||
$result = array();
|
||||
|
||||
$result[] = sprintf('%s %s-%s', $g['product_name'], explode('-', trim(file_get_contents('/usr/local/opnsense/version/opnsense')))[0], trim(shell_exec('uname -p')));
|
||||
$result[] = sprintf('%s %s-%s', $g['product_name'], $g['product_version'], $g['product_arch']);
|
||||
$result[] = php_uname('s') . ' ' . php_uname('r');
|
||||
$result[] = OPENSSL_VERSION_TEXT;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user