Skip to content

Commit

Permalink
Fix the BlinkBoot upgrade checks.
Browse files Browse the repository at this point in the history
Fixes the BB version check, do not tell the customers that there is a new
version when there is not, do not let the users downgrade BB.
  • Loading branch information
loos-br committed Oct 21, 2021
1 parent 51564cb commit 2f5da8d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@
require_once("globals.inc");
require_once("system.inc");

function check_update($current, $new) {

# Do not update if we are missing any information.
if (!isset($current) || !isset($new) ||
!isset($current['version']) || !isset($new['version']) ||
!isset($new['platform'])) {
return false;
}

if ($new['platform'] != "6100") {
return ($current['version'] == $new['version']);
}

if (strlen($current['version']) != 18 ||
strlen($new['version']) != 18 ||
strpos($current['version'], 't-uc-') != 11 ||
strpos($new['version'], 't-uc-') != 11) {
return false;
}
$curver = str_replace(array(".", "t-uc-"), "", $current['version']);
$newver = str_replace(array(".", "t-uc-"), "", $new['version']);

return (intval($newver) > intval($curver));
}

function get_firmware_model() {
$specplatform = system_identify_specific_platform();

Expand Down Expand Up @@ -58,7 +83,10 @@ function get_firmware_details($firmware) {
if (preg_match('/^(CORDOBA)-([\d.]{11}\w-uc-\d*)/', $firmware,
$matches)) {

return(array('model' => $matches[1], 'version' => $matches[2]));
$details['platform'] = get_firmware_model();
$details['model'] = $matches[1];
$details['version'] = $matches[2];
return $details;
}

if (!preg_match('/^ADI_(RCC|RCCVE|DFF2|PLCC)-([\d.]{11})/',
Expand All @@ -70,6 +98,7 @@ function get_firmware_details($firmware) {
return $details;
}

$details['platform'] = get_firmware_model();
$details['model'] = $matches[1];
$details['version'] = $matches[2];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ if [ ! -f "${rom_path}" ]; then
fi

image=$(basename ${rom_path})
version="${image%-uc-*}"
cur_version=$(kenv -q smbios.bios.version 2>/dev/null)
version=$(echo ${image} | cut -d- -f2- | tr -d '[.|\-|a-z|A-Z]')
cur_version=$(kenv -q smbios.bios.version 2>/dev/null | cut -d- -f2- | tr -d '[.|a-z|A-Z]')
uc_cur_ver=$(sysctl -n dev.cordbuc.0.version 2> /dev/null)
cur_version=${cur_version}${uc_cur_ver}
product=$(kenv -q smbios.system.product 2>/dev/null)
base_dir=$(dirname $(realpath $0))

Expand Down Expand Up @@ -96,7 +98,7 @@ if [ "${product}" != "6100" ]; then
echo "Unsupported device ${product}. exiting."
exit 1
fi
if [ "${cur_version}" = "${version}" ]; then
if [ "${cur_version}" -ge "${version}" ]; then
echo "BlinkBoot is already at the latest version. exiting."
exit 0
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
$new['version']
));

if ($new['version'] != $current['version']) {
if (check_update($current, $new)) {
$section->addInput(new Form_Button(
'upgrade',
'Upgrade and Reboot',
Expand Down

0 comments on commit 2f5da8d

Please sign in to comment.