aboutsummaryrefslogtreecommitdiffstats
path: root/remove-packages
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-09-03 17:30:47 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-09-03 17:30:47 +0200
commita1951cc86a206abd0b6d46d579a8247af42904f8 (patch)
tree2c3bc4c75f18946ba0f01acbdfd6bc12cad2c75d /remove-packages
parentd68a1def31e9001e4f7fdbab4a99443777cad3f2 (diff)
remove-packages: remove outdated packages only
Diffstat (limited to 'remove-packages')
-rw-r--r--remove-packages14
1 files changed, 12 insertions, 2 deletions
diff --git a/remove-packages b/remove-packages
index 1d7a595..cf449a0 100644
--- a/remove-packages
+++ b/remove-packages
@@ -2,6 +2,16 @@
# RouterOS script: remove-packages
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
-# remove packages (*.npk) from storage
+# remove packages (*.npk) not matching installed version
-/ file remove [ / file find type="package" ];
+:local version [ / system package update get installed-version ];
+
+:foreach package in=[ / file find type="package" ] do={
+ :local filename [ / file get $package name ];
+ :if ($filename~$version) do={
+ :log debug ("Package file " . $filename . " is up-to-date.");
+ } else={
+ :log debug ("Removing old packge file: " . $filename);
+ / file remove $package;
+ }
+}