aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-14 09:43:38 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-14 09:43:38 +0200
commit7bb8f6710c94260f05f6d88910864e2b25484e6c (patch)
treebf93bbbe7d7f64130b2e712437e2f07287b91be3
parenta3db63fa62abee81e866fc2397c9302486a09cbb (diff)
downloadapp.sh-7bb8f6710c94260f05f6d88910864e2b25484e6c.tar.gz
app.sh-7bb8f6710c94260f05f6d88910864e2b25484e6c.tar.bz2
app.sh-7bb8f6710c94260f05f6d88910864e2b25484e6c.tar.xz
app.sh-7bb8f6710c94260f05f6d88910864e2b25484e6c.zip
o Setting a default PATH for postinstall.
-rw-r--r--.app/lib/app-app19
-rw-r--r--.gitignore2
-rwxr-xr-xtest/app-install.bats27
-rw-r--r--test/data/app-a.zipbin715 -> 0 bytes
-rw-r--r--test/data/install-test-env/root/keep0
-rw-r--r--test/data/install-test-env/scripts/postinstall3
-rw-r--r--test/utils.bash11
7 files changed, 50 insertions, 12 deletions
diff --git a/.app/lib/app-app b/.app/lib/app-app
index ae77298..c9da2d7 100644
--- a/.app/lib/app-app
+++ b/.app/lib/app-app
@@ -191,6 +191,12 @@ method_install() {
echo "Unpacking..."
unzip -q -d $name/$instance/versions/$resolved_version $zip_file
+ if [ ! -d $BASEDIR/$name/$instance/versions/$resolved_version/root ]
+ then
+ echo "Invalid zip file, did not contain a ./root directory." >&2
+ exit 1
+ fi
+
(
cd $name/$instance/versions/$resolved_version
if [ -d scripts ]
@@ -203,7 +209,7 @@ method_install() {
echo "Running postinstall..."
set +e
env -i \
- PATH=$PATH \
+ PATH=/bin:/usr/bin \
scripts/postinstall
set -e
ret=`echo $?`
@@ -220,10 +226,13 @@ method_install() {
rm -f $BASEDIR/$name/$instance/current
ln -s versions/$resolved_version/root $BASEDIR/$name/$instance/current
- (
- cd $name/$instance/current
- find bin -type f | xargs chmod +x
- )
+ if [ -d $name/$instance/current/bin ]
+ then
+ (
+ cd $name/$instance/current
+ find bin -type f | xargs chmod +x
+ )
+ fi
if [ -r $BASEDIR/.app/var/list ]
then
diff --git a/.gitignore b/.gitignore
index e80433c..b11d79c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ downloads
target
.app/var
/*/.gitignore
+
+/test/data/*.zip
diff --git a/test/app-install.bats b/test/app-install.bats
index 8f164bc..08c4a06 100755
--- a/test/app-install.bats
+++ b/test/app-install.bats
@@ -3,15 +3,15 @@
load utils
-@test "./app app install" {
- zip_app_a
+@test "./app app install app-a" {
+ mkzip "app-a"
app app install \
-r file \
-u $BATS_TEST_DIRNAME/data/app-a.zip \
-n app-a -i prod
echo_lines
- [ $status -eq $exit_usage ]
+ [ $status -eq 0 ]
[ "$output" = "Creating instance 'prod' for 'app-a'
Unpacking...
Running postinstall...
@@ -20,3 +20,24 @@ Postinstall completed successfully
Changing current symlink" ]
[ ${#lines[*]} == 6 ]
}
+
+@test "./app app install install-test-env" {
+ mkzip "install-test-env"
+ app app install \
+ -r file \
+ -u $BATS_TEST_DIRNAME/data/install-test-env.zip \
+ -n install-test-env -i prod -v 1.0
+
+ echo_lines
+ [ $status -eq 0 ]
+ [ "$output" = "Creating instance 'prod' for 'install-test-env'
+Unpacking...
+Running postinstall...
+PATH=/bin:/usr/bin
+PWD=$WORK/install-test-env/prod/versions/1.0
+SHLVL=1
+_=/usr/bin/env
+Postinstall completed successfully
+Changing current symlink" ]
+ [ ${#lines[*]} == 9 ]
+}
diff --git a/test/data/app-a.zip b/test/data/app-a.zip
deleted file mode 100644
index 7562ab6..0000000
--- a/test/data/app-a.zip
+++ /dev/null
Binary files differ
diff --git a/test/data/install-test-env/root/keep b/test/data/install-test-env/root/keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/data/install-test-env/root/keep
diff --git a/test/data/install-test-env/scripts/postinstall b/test/data/install-test-env/scripts/postinstall
new file mode 100644
index 0000000..ad40c95
--- /dev/null
+++ b/test/data/install-test-env/scripts/postinstall
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+env
diff --git a/test/utils.bash b/test/utils.bash
index eaa2580..418b962 100644
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -8,6 +8,7 @@ exit_usage_wrong=0
echo_lines() {
for line in "${lines[@]}"; do echo $line; done
+ echo status=$status
}
APPSH=$(pwd)/app
@@ -17,13 +18,15 @@ setup() {
mkdir $BATS_TMPDIR/app.sh
cd $BATS_TMPDIR/app.sh
ln -s $APPSH
+ WORK=$(cd -P $BATS_TMPDIR/app.sh; pwd)
+ echo WORK=$WORK
}
-zip_app_a() {
+mkzip() {
(
- cd $BATS_TEST_DIRNAME/data/app-a
- rm -f ../app-a.zip
- zip -qr ../app-a.zip *
+ cd $BATS_TEST_DIRNAME/data/$1
+ rm -f ../$1.zip
+ zip -qr ../$1.zip *
)
}