aboutsummaryrefslogtreecommitdiff
path: root/libexec/app-install-file
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/app-install-file')
-rwxr-xr-xlibexec/app-install-file30
1 files changed, 19 insertions, 11 deletions
diff --git a/libexec/app-install-file b/libexec/app-install-file
index c31f1f4..32b0407 100755
--- a/libexec/app-install-file
+++ b/libexec/app-install-file
@@ -48,21 +48,29 @@ then
usage
fi
-if [ -d versions/$version ]
+re="[.a-zA-Z0-9]"
+
+if [[ ! $version =~ $re ]]
then
- echo "Version $version is already installed"
- exit 1
+ fatal "Invalid version: $version"
fi
-mkdir -p versions/$version
-
-echo "Unpacking..."
-unzip -q -d versions/$version $file
-
-if [ ! -d versions/$version/root ]
+if [ -d versions/$version ]
then
- echo "Invalid zip file, did not contain a ./root directory." >&2
- exit 1
+ echo "Version $version is already unpacked"
+else
+ mkdir -p versions/$version.tmp
+
+ echo "Unpacking..."
+ unzip -q -d versions/$version.tmp $file
+
+ if [ ! -d versions/$version.tmp/root ]
+ then
+ echo "Invalid zip file, did not contain a 'root' directory." >&2
+ rm -rf versions/$version.tmp
+ exit 1
+ fi
+ mv versions/$version.tmp versions/$version
fi
if [ -n "$prepend_config" ]