aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-13 09:44:15 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-13 09:44:15 +0100
commitc361caee5b1996f0d7c6cc44c159f21b3f801e95 (patch)
treedae9e4e3415202baab203afa8d08af21b57a53b5
parent8537bbe19dab99a6943d7cdd3180f9d49394b518 (diff)
global-functions: introduce and use $CleanFilePath
-rw-r--r--global-functions25
1 files changed, 21 insertions, 4 deletions
diff --git a/global-functions b/global-functions
index d55d0a6..f1d9ba2 100644
--- a/global-functions
+++ b/global-functions
@@ -137,6 +137,25 @@
}
}
+# clean file path
+:global CleanFilePath do={
+ :local Path [ :tostr $1 ];
+
+ :global CharacterReplace;
+
+ :while ($Path ~ "//") do={
+ :set $Path [ $CharacterReplace $Path "//" "/" ];
+ }
+ :if ([ :pick $Path 0 ] = "/") do={
+ :set Path [ :pick $Path 1 [ :len $Path ] ];
+ }
+ :if ([ :pick $Path ([ :len $Path ] - 1) ] = "/") do={
+ :set Path [ :pick $Path 0 ([ :len $Path ] - 1) ];
+ }
+
+ :return $Path;
+}
+
# download package from upgrade server
:global DownloadPackage do={
:local PkgName [ :tostr $1 ];
@@ -145,16 +164,14 @@
:local PkgDir [ :tostr $4 ];
:global CertificateAvailable;
+ :global CleanFilePath;
:if ([ :len $PkgName ] = 0) do={ return false; }
:if ([ :len $PkgVer ] = 0) do={ :set PkgVer [ / system package update get installed-version ]; }
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
- :local PkgDest $PkgFile;
- :if ($PkgDir != "") do={
- :set PkgDest ($PkgDir . "/" . $PkgFile);
- }
+ :local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
:do {