aboutsummaryrefslogtreecommitdiffstats
path: root/packages-update
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-07-07 09:28:16 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-07-07 09:30:48 +0200
commitb31d1a0f0140a36c0b92b9fd6173db8fa978ef1f (patch)
tree73fc8567d45941e07321ac75e8ee96ce3b85febb /packages-update
parentc5767c8d23fea30371fa9f099310bd34d3d54360 (diff)
packages-update: do not install downgrade without confirmation
Diffstat (limited to 'packages-update')
-rw-r--r--packages-update33
1 files changed, 24 insertions, 9 deletions
diff --git a/packages-update b/packages-update
index ff683a2..c0a3c84 100644
--- a/packages-update
+++ b/packages-update
@@ -10,6 +10,7 @@
:global LogPrintExit;
:global ScriptFromTerminal;
:global ScriptLock;
+:global VersionToNum;
$ScriptLock "packages-update";
@@ -23,6 +24,23 @@ $ScriptLock "packages-update";
$LogPrintExit info ("Version " . $Update->"latest-version" . " is already installed.") true;
}
+:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
+:local NumLatest [ $VersionToNum ($Update->"latest-version") ];
+
+:local DoDowngrade false;
+:if ($NumInstalled > $NumLatest) do={
+ :if ([ $ScriptFromTerminal "packages-update" ] = true) do={
+ :put "Latest version is older than installed one. Want to downgrade? [y/N]";
+ :if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
+ :set DoDowngrade true;
+ } else={
+ :put "Canceled...";
+ }
+ } else={
+ $LogPrintExit warning ("Not installing downgrade automatically.") true;
+ }
+}
+
:foreach Package in=[ / system package find where !bundle ] do={
:local PkgName [ / system package get $Package name ];
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
@@ -34,16 +52,13 @@ $ScriptLock "packages-update";
/ system script run $Script;
}
-:if ([ $ScriptFromTerminal "packages-update" ] = true) do={
- :if (!([ /system resource get version ] ~ ($Update->"channel"))) do={
- :put "Update channel changed. Want to downgrade? [y/N]";
- :if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
- $LogPrintExit info ("Rebooting for downgrade.") false;
- :delay 1s;
- / system package downgrade;
- }
- }
+:if ($DoDowngrade = true) do={
+ $LogPrintExit info ("Rebooting for downgrade.") false;
+ :delay 1s;
+ / system package downgrade;
+}
+:if ([ $ScriptFromTerminal "packages-update" ] = true) do={
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
:if (([ :terminal inkey timeout=60 ] % 32) = 19) do={
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \