diff options
Diffstat (limited to 'packages-update')
-rw-r--r-- | packages-update | 33 |
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 \ |