aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-10-18 15:12:33 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-10-18 15:12:33 +0200
commit64e4505a2f30b1ddf027ffd43898efa7bdfdd8d7 (patch)
tree28ee4b9c443b2e71f825f820f4e8e09e4345004c
parent190fbfc45fb1df608a34bd775b84564e872ab4dc (diff)
downloadapp.sh-64e4505a2f30b1ddf027ffd43898efa7bdfdd8d7.tar.gz
app.sh-64e4505a2f30b1ddf027ffd43898efa7bdfdd8d7.tar.bz2
app.sh-64e4505a2f30b1ddf027ffd43898efa7bdfdd8d7.tar.xz
app.sh-64e4505a2f30b1ddf027ffd43898efa7bdfdd8d7.zip
o Changing the current symlink before running postinstall.
-rw-r--r--.app/lib/app-instance24
-rwxr-xr-xapp17
-rwxr-xr-xtest/app-install.bats8
-rwxr-xr-xtest/app-list-versions.bats11
-rw-r--r--test/data/app-a/scripts/postinstall2
5 files changed, 36 insertions, 26 deletions
diff --git a/.app/lib/app-instance b/.app/lib/app-instance
index 5b34bf1..ce6ebeb 100644
--- a/.app/lib/app-instance
+++ b/.app/lib/app-instance
@@ -197,6 +197,18 @@ method_install() {
exit 1
fi
+ echo "Changing current symlink"
+ rm -f $apps/$name/$instance/current
+ ln -s versions/$resolved_version/root $apps/$name/$instance/current
+
+ if [ -d $name/$instance/current/bin ]
+ then
+ (
+ cd $name/$instance/current
+ find bin -type f | xargs chmod +x
+ )
+ fi
+
(
cd $name/$instance/versions/$resolved_version
if [ -d scripts ]
@@ -228,18 +240,6 @@ method_install() {
fi
)
- echo "Changing current symlink"
- rm -f $apps/$name/$instance/current
- ln -s versions/$resolved_version/root $apps/$name/$instance/current
-
- if [ -d $name/$instance/current/bin ]
- then
- (
- cd $name/$instance/current
- find bin -type f | xargs chmod +x
- )
- fi
-
if [ -r $apps/.app/var/list ]
then
sed "/^$name:$instance/d" $apps/.app/var/list > $apps/.app/var/list.new
diff --git a/app b/app
index 84f757d..a778e74 100755
--- a/app
+++ b/app
@@ -16,11 +16,18 @@ done
APPSH_HOME=`dirname "$PRG"`
APPSH_HOME=`cd "$APPSH_HOME" && pwd`
-if [ -z "$APPSH_APPS" ]
-then
- apps=`dirname $0`
- apps=`cd $apps; pwd`
-fi
+# Not sure this is useful
+#if [ -z "$APPSH_APPS" ]
+#then
+# apps=`dirname $0`
+# apps=`cd $apps; pwd`
+#fi
+
+apps=`dirname $0`
+apps=`cd $apps; pwd`
+
+# Ideally this should just do "cd /" to ensure that all paths are useful.
+cd $apps
mkdir -p $apps/.app/var/pid
mkdir -p $apps/.app/var/download
diff --git a/test/app-install.bats b/test/app-install.bats
index 7c7d642..38304be 100755
--- a/test/app-install.bats
+++ b/test/app-install.bats
@@ -16,11 +16,11 @@ load utils
[ $status -eq 0 ]
[ "$output" = "Creating instance 'prod' for 'app-a'
Unpacking...
+Changing current symlink
Running postinstall...
Hello World!
Creating logs directory
-Postinstall completed successfully
-Changing current symlink" ]
+Postinstall completed successfully" ]
[ ${#lines[*]} == 7 ]
}
@@ -34,6 +34,7 @@ Changing current symlink" ]
[ $status -eq 0 ]
[ "$output" = "Creating instance 'prod' for 'install-test-env'
Unpacking...
+Changing current symlink
Running postinstall...
APPSH_APPS=$APPSH_APPS
APPSH_HOME=$APPSH_HOME
@@ -44,8 +45,7 @@ PATH=/bin:/usr/bin
PWD=$APPSH_APPS_CANONICAL/install-test-env/prod/versions/1.0/root
SHLVL=1
_=/usr/bin/env
-Postinstall completed successfully
-Changing current symlink" ]
+Postinstall completed successfully" ]
[ ${#lines[*]} == 14 ]
# PWD=$APPSH_APPS_CANONICAL/install-test-env/prod/versions/1.0
}
diff --git a/test/app-list-versions.bats b/test/app-list-versions.bats
index 17fb2d2..de543eb 100755
--- a/test/app-list-versions.bats
+++ b/test/app-list-versions.bats
@@ -18,8 +18,11 @@ load utils
1.0
1.1" ]
- app instance list-versions -n app-a -i env-a -P; echo_lines
- [ $status -eq 0 ]
- [ "$output" = "1.0
-1.1" ]
+ expected="1.0
+1.1"
+
+set -x
+ app -n app-a instance -i env-a list-versions -P; [ "$output" = "$expected" ]; echo_lines;
+ app -n app-a instance list-versions -i env-a -P; [ "$output" = "$expected" ]; echo_lines;
+ app instance list-versions -n app-a -i env-a -P; [ "$output" = "$expected" ]; echo_lines;
}
diff --git a/test/data/app-a/scripts/postinstall b/test/data/app-a/scripts/postinstall
index c1a0cf1..dc176ff 100644
--- a/test/data/app-a/scripts/postinstall
+++ b/test/data/app-a/scripts/postinstall
@@ -4,7 +4,7 @@ echo "Hello World!"
if [ -d etc/$APPSH_INSTANCE ]
then
- find etc/$APPSH_INSTANCE -type f -maxdepth 1 | while read file
+ find etc/$APPSH_INSTANCE -maxdepth 1 -type f | while read file
do
cp $file .
done