aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-11-01 16:24:26 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-11-01 19:58:08 +0100
commitba7820b18c0ee8631505f7a2a764f7222a732d44 (patch)
tree82bc1d530e1f815e8d8687fa642dd5c84a59c114 /libexec
parent93e2978fbe5582440d79c47b5975659d9cbf701b (diff)
downloadapp.sh-v0.2-dev.tar.gz
app.sh-v0.2-dev.tar.bz2
app.sh-v0.2-dev.tar.xz
app.sh-v0.2-dev.zip
bin/app-upgrade: Removing unreachable code. Fixing it so it comparesv0.2-dev
against the currently installed version instead of the last resolved version which makes it possible to retry installation of the same version. libexec/app-install-file: Allowing installation of the same file twice. Checks if the file has been unpacked earlier or not. Removes the unpacked version on failure.
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/app-install-file30
-rwxr-xr-xlibexec/app-resolver-file2
2 files changed, 20 insertions, 12 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" ]
diff --git a/libexec/app-resolver-file b/libexec/app-resolver-file
index 2b708e8..5972926 100755
--- a/libexec/app-resolver-file
+++ b/libexec/app-resolver-file
@@ -47,7 +47,7 @@ init() {
resolve_version() {
path=$(app-conf get file.path)
- local s=$(stat -c %Z $path)
+ local s=$(stat -c %Y $path)
app-conf set app.resolved_version "$s"
}