aboutsummaryrefslogtreecommitdiff
path: root/tmp
diff options
context:
space:
mode:
Diffstat (limited to 'tmp')
-rw-r--r--tmp/0001-o-Supporting-platforms-where-xmlstarlet-is-installed.patch62
-rw-r--r--tmp/0002-o-Supporting-older-versions-of-asciidoc.patch115
-rw-r--r--tmp/0003-app-resolver-maven-Adding-support-for-artifacts-with.patch133
-rw-r--r--tmp/0004-lib-common-Changing-run_app-to-not-check-for-a-curre.patch53
-rw-r--r--tmp/0005-bin-app-upgrade-Removing-unreachable-code.-Fixing-it.patch248
5 files changed, 611 insertions, 0 deletions
diff --git a/tmp/0001-o-Supporting-platforms-where-xmlstarlet-is-installed.patch b/tmp/0001-o-Supporting-platforms-where-xmlstarlet-is-installed.patch
new file mode 100644
index 0000000..dc82a70
--- /dev/null
+++ b/tmp/0001-o-Supporting-platforms-where-xmlstarlet-is-installed.patch
@@ -0,0 +1,62 @@
+From ed52962997364560d341e0197c20a616e9b0f03e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= <trygvis@inamo.no>
+Date: Wed, 30 Oct 2013 14:29:06 +0100
+Subject: [PATCH 1/5] o Supporting platforms where 'xmlstarlet' is installed as
+ 'xml' (At least Suse does that).
+
+---
+ libexec/app-resolver-maven | 38 ++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 38 insertions(+)
+
+diff --git a/libexec/app-resolver-maven b/libexec/app-resolver-maven
+index 419adcc..ec1ad6b 100755
+--- a/libexec/app-resolver-maven
++++ b/libexec/app-resolver-maven
+@@ -81,6 +81,44 @@ download_artifact() {
+ fi
+ }
+
++
++which() {
++ /usr/bin/which "$1" 2>/dev/null
++}
++
++# Wrapper to cache the lookup of the xmlstarlet command.
++# Remember that xmlstarlet on at least SLES requires single quotes
++# instead of double quotes when building the selector, e.g.:
++# use [text()='zip'] instead of [text()="zip"].
++
++_xmlstarlet=""
++xmlstarlet() {
++ if [ ! -z "$_xmlstarlet" ]
++ then
++ "$_xmlstarlet" "$@"
++ return
++ fi
++
++ _xmlstarlet="`which xmlstarlet`"
++
++ if [ ! -z "$_xmlstarlet" ]
++ then
++ "$_xmlstarlet" "$@"
++ return
++ fi
++
++ _xmlstarlet="`which xml`"
++
++ if [ ! -z "$_xmlstarlet" ]
++ then
++ "$_xmlstarlet" "$@"
++ return
++ fi
++
++ echo "Could not find xmlstarlet." >&2
++ exit 1
++}
++
+ resolve_version() {
+ local group_id=`app-conf get maven.group_id`
+ local artifact_id=`app-conf get maven.artifact_id`
+--
+1.8.4.rc3
+
diff --git a/tmp/0002-o-Supporting-older-versions-of-asciidoc.patch b/tmp/0002-o-Supporting-older-versions-of-asciidoc.patch
new file mode 100644
index 0000000..f9869dd
--- /dev/null
+++ b/tmp/0002-o-Supporting-older-versions-of-asciidoc.patch
@@ -0,0 +1,115 @@
+From c106046cbb0cdb590035fcd33f5fc6ce1a3b975c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= <trygvis@inamo.no>
+Date: Thu, 31 Oct 2013 14:30:13 +0100
+Subject: [PATCH 2/5] o Supporting older versions of asciidoc.
+
+---
+ .gitignore | 1 +
+ docs/Makefile | 9 +++++++--
+ docs/appinternals.txt | 4 ++++
+ docs/asciidoc.conf | 35 +++++++++++++++++++++++++++++++++++
+ 4 files changed, 47 insertions(+), 2 deletions(-)
+
+diff --git a/.gitignore b/.gitignore
+index b6d1d32..4acb46e 100644
+--- a/.gitignore
++++ b/.gitignore
+@@ -1,6 +1,7 @@
+ apps.list
+ downloads
+ target
++docs/*.xml
+ docs/*.html
+ docs/*.1
+ docs/*.7
+diff --git a/docs/Makefile b/docs/Makefile
+index f340323..355f0bc 100644
+--- a/docs/Makefile
++++ b/docs/Makefile
+@@ -3,11 +3,16 @@ TXT=$(wildcard *.txt)
+ MAN=$(shell ls *.txt|xargs -n 1 head -n 1|sed "s,\(.*\)(\([0-9]\)),\1.\2,")
+ HTML=$(patsubst %.txt,%.html,$(TXT))
+
+-all: $(HTML) $(MAN)
++all: html man
++
++html: $(HTML)
++man: $(MAN)
++
++.PHONY: html man
+
+ %.html: %.txt
+ @echo asciidoc $<
+- @asciidoc -f asciidoc.conf --backend=html5 $<
++ @asciidoc -f asciidoc.conf --backend=xhtml11 -aappsh_version=0.2-dev $<
+
+ %.1: %.txt
+ $(call man,$<)
+diff --git a/docs/appinternals.txt b/docs/appinternals.txt
+index ce19923..330d151 100644
+--- a/docs/appinternals.txt
++++ b/docs/appinternals.txt
+@@ -5,6 +5,10 @@ NAME
+ ----
+ appinternals - Appsh internals
+
++SYNOPSIS
++--------
++appinternals
++
+ DESCRIPTION
+ -----------
+
+diff --git a/docs/asciidoc.conf b/docs/asciidoc.conf
+index 724524a..57eaf59 100644
+--- a/docs/asciidoc.conf
++++ b/docs/asciidoc.conf
+@@ -1,6 +1,31 @@
++# https://github.com/marcelocantos/zeromq2-1/blob/master/doc/asciidoc.conf
++# http://lxr.free-electrons.com/source/tools/perf/Documentation/asciidoc.conf
++
+ [macros]
+ (?su)[\\]?(?P<name>linkman):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
+
++ifdef::doctype-manpage[]
++ifdef::backend-docbook[]
++[header]
++template::[header-declarations]
++<refentry>
++ <refmeta>
++ <refentrytitle>{mantitle}</refentrytitle>
++ <manvolnum>{manvolnum}</manvolnum>
++ <refmiscinfo class="source">app.sh</refmiscinfo>
++ <!-- doesn't seem to have any effect
++ <refmiscinfo class="version">version={appsh_version}</refmiscinfo>
++ -->
++ <refmiscinfo class="manual">App.sh Manual</refmiscinfo>
++ </refmeta>
++ <refnamediv>
++ <refname>{manname}</refname>
++ <refpurpose>{manpurpose}</refpurpose>
++ </refnamediv>
++# No ending refentry, asciidoc takes care of that.
++endif::backend-docbook[]
++endif::doctype-manpage[]
++
+ ifdef::backend-docbook[]
+ [linkman-inlinemacro]
+ {0%{target}}
+@@ -18,3 +43,13 @@ relative-ext=.html
+ <a href="{target}.html">{target}{0?({0})}</a>
+
+ endif::backend-html5[]
++
++ifdef::backend-xhtml11[]
++
++[attributes]
++relative-ext=.html
++
++[linkman-inlinemacro]
++<a href="{target}.html">{target}{0?({0})}</a>
++
++endif::backend-xhtml11[]
+--
+1.8.4.rc3
+
diff --git a/tmp/0003-app-resolver-maven-Adding-support-for-artifacts-with.patch b/tmp/0003-app-resolver-maven-Adding-support-for-artifacts-with.patch
new file mode 100644
index 0000000..2b7933f
--- /dev/null
+++ b/tmp/0003-app-resolver-maven-Adding-support-for-artifacts-with.patch
@@ -0,0 +1,133 @@
+From 746b90ad64e65b70bc902ed1bcd2c33ec7adf008 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= <trygvis@inamo.no>
+Date: Thu, 31 Oct 2013 16:27:09 +0100
+Subject: [PATCH 3/5] app-resolver-maven: Adding support for artifacts with
+ classifier.
+
+---
+ libexec/app-resolver-maven | 43 +++++++++++++++++++++++++++++++++----------
+ test/app-resolver-maven.bats | 27 +++++++++++++++++++++++++++
+ 2 files changed, 60 insertions(+), 10 deletions(-)
+ create mode 100755 test/app-resolver-maven.bats
+
+diff --git a/libexec/app-resolver-maven b/libexec/app-resolver-maven
+index ec1ad6b..4e21c4b 100755
+--- a/libexec/app-resolver-maven
++++ b/libexec/app-resolver-maven
+@@ -12,6 +12,8 @@ usage_text() {
+ echo "usage: $usage_app init -r <repo> <maven url>"
+ echo "usage: $usage_app resolve-version"
+ echo "usage: $usage_app download-version -v <version> -f <download target>"
++ echo "Maven url can be one of: <group id>:<artifact id>:<version> and"
++ echo "<group id>:<artifact id>:<classifier>:<version>"
+ }
+
+ slash() {
+@@ -122,6 +124,7 @@ xmlstarlet() {
+ resolve_version() {
+ local group_id=`app-conf get maven.group_id`
+ local artifact_id=`app-conf get maven.artifact_id`
++ local classifier=`app-conf get app.classifier`
+ local version=`app-conf get app.version`
+
+ repo=`app-conf get maven.repo`
+@@ -199,15 +202,17 @@ download_version() {
+ repo=`app-conf get maven.repo`
+ group_id=`app-conf get maven.group_id`
+ artifact_id=`app-conf get maven.artifact_id`
++ classifier=`app-conf get maven.classifier`
+ version=`app-conf get app.version`
+
+ group_id_slash=`slash $group_id`
+ base_path=$group_id_slash/$artifact_id/$version
++ file_name=$artifact_id-$resolved_version${classifier:+-}$classifier.zip
+
+ mkdir -p .app/cache/$base_path
+
+- l=.app/cache/$base_path/$artifact_id-$resolved_version.zip
+- r=$repo/$base_path/$artifact_id-$resolved_version.zip
++ l=.app/cache/$base_path/$file_name
++ r=$repo/$base_path/$file_name
+
+ echo "Downloading $group_id:$artifact_id:$resolved_version..."
+ get $r $l
+@@ -236,17 +241,35 @@ init() {
+ x=${x//:/ }
+ set -- $x
+
+- if [[ $# != 3 || $1 == "" || $2 == "" || $3 == "" ]]
+- then
+- usage "Invalid Maven coordinates: $coordinates"
+- fi
+-
+- group_id=$1
+- artifact_id=$2
+- version=$3
++ case $# in
++ 3)
++ if [[ $1 == "" || $2 == "" || $3 == "" ]]
++ then
++ usage "Invalid Maven coordinates: $coordinates"
++ fi
++ group_id=$1; shift
++ artifact_id=$1; shift
++ classifier=
++ version=$1; shift
++ ;;
++ 4)
++ if [[ $1 == "" || $2 == "" || $3 == "" || $4 == "" ]]
++ then
++ usage "Invalid Maven coordinates: $coordinates"
++ fi
++ group_id=$1; shift
++ artifact_id=$1; shift
++ classifier=$1; shift
++ version=$1; shift
++ ;;
++ *)
++ usage "Invalid Maven coordinates: $coordinates"
++ ;;
++ esac
+
+ app-conf set maven.group_id "$group_id"
+ app-conf set maven.artifact_id "$artifact_id"
++ [[ ! -z $classifier ]] && app-conf set maven.classifier "$classifier"
+ app-conf set app.version "$version"
+ }
+
+diff --git a/test/app-resolver-maven.bats b/test/app-resolver-maven.bats
+new file mode 100755
+index 0000000..e5a5474
+--- /dev/null
++++ b/test/app-resolver-maven.bats
+@@ -0,0 +1,27 @@
++#!/usr/bin/env bats
++# vim: set filetype=sh:
++
++load utils
++
++@test "plain init" {
++ mkdir .app
++ app resolver-maven init my-group:my-artifact:1.0-SNAPSHOT
++ app cat-conf
++ eq '${lines[0]}' "app.version=1.0-SNAPSHOT"
++ eq '${lines[1]}' "maven.artifact_id=my-artifact"
++ eq '${lines[2]}' "maven.group_id=my-group"
++ eq '${lines[3]}' "maven.repo=http://repo1.maven.org"
++ eq '${#lines[*]}' 4
++}
++
++@test "init with classifier" {
++ mkdir .app
++ app resolver-maven init my-group:my-artifact:app:1.0-SNAPSHOT
++ app cat-conf
++ eq '${lines[0]}' "app.version=1.0-SNAPSHOT"
++ eq '${lines[1]}' "maven.artifact_id=my-artifact"
++ eq '${lines[2]}' "maven.classifier=app"
++ eq '${lines[3]}' "maven.group_id=my-group"
++ eq '${lines[4]}' "maven.repo=http://repo1.maven.org"
++ eq '${#lines[*]}' 5
++}
+--
+1.8.4.rc3
+
diff --git a/tmp/0004-lib-common-Changing-run_app-to-not-check-for-a-curre.patch b/tmp/0004-lib-common-Changing-run_app-to-not-check-for-a-curre.patch
new file mode 100644
index 0000000..48e23de
--- /dev/null
+++ b/tmp/0004-lib-common-Changing-run_app-to-not-check-for-a-curre.patch
@@ -0,0 +1,53 @@
+From 90bc5af891b745f97196310f2bc4afd081daac3e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= <trygvis@inamo.no>
+Date: Fri, 1 Nov 2013 15:48:58 +0100
+Subject: [PATCH 4/5] lib/common: Changing run_app to not check for a 'current'
+ link if version is given. This will unbreak hooks that are run before a
+ current link is installed or if it has been removed.
+
+---
+ lib/common | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/lib/common b/lib/common
+index 369f0be..c2babd2 100755
+--- a/lib/common
++++ b/lib/common
+@@ -2,6 +2,7 @@
+
+ # Asserts that the cwd is an app directory.
+ # By default it checks that there is a 'current' link.
++# TODO: make check_link default to no if version is set
+ assert_is_app() {
+ local check_link=yes
+ local version=
+@@ -241,8 +242,8 @@ run_app() {
+ case $opt in
+ v)
+ version=$OPTARG
+- shift 2
+- OPTIND=1
++ shift 2
++ OPTIND=1
+ ;;
+ esac
+ done
+@@ -258,13 +259,13 @@ run_app() {
+ assert_is_app
+ cd current
+ else
+- assert_is_app -v "$version"
++ assert_is_app -C -v "$version"
+ cd "versions/$version"
+ fi
+
+ path=/bin:/usr/bin
+
+- # This magically get the expansion of $u correct.
++ # This will magically get the expansion of $u correct.
+ IFS="
+ "
+
+--
+1.8.4.rc3
+
diff --git a/tmp/0005-bin-app-upgrade-Removing-unreachable-code.-Fixing-it.patch b/tmp/0005-bin-app-upgrade-Removing-unreachable-code.-Fixing-it.patch
new file mode 100644
index 0000000..0123feb
--- /dev/null
+++ b/tmp/0005-bin-app-upgrade-Removing-unreachable-code.-Fixing-it.patch
@@ -0,0 +1,248 @@
+From 274b7d15a82351dfee32be32bade4e35246d5beb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= <trygvis@inamo.no>
+Date: Fri, 1 Nov 2013 16:24:26 +0100
+Subject: [PATCH 5/5] bin/app-upgrade: Removing unreachable code. Fixing it so
+ it compares 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.
+
+---
+ bin/app-upgrade | 36 +++++++++++++++---------------------
+ libexec/app-install-file | 30 +++++++++++++++++++-----------
+ libexec/app-resolver-file | 2 +-
+ test/app-init.bats | 14 ++++++++------
+ test/app-upgrade.bats | 30 ++++++++++++++++++++++++++++++
+ test/data/app-a/hooks/post-install | 8 +++++++-
+ test/data/app-a/hooks/pre-install | 11 +++++++++++
+ 7 files changed, 91 insertions(+), 40 deletions(-)
+ create mode 100755 test/data/app-a/hooks/pre-install
+
+diff --git a/bin/app-upgrade b/bin/app-upgrade
+index 1a8329a..db40f4e 100755
+--- a/bin/app-upgrade
++++ b/bin/app-upgrade
+@@ -19,40 +19,34 @@ fi
+
+ assert_is_app
+
++version=`app-conf get app.version`
++installed_version=`app-conf get app.installed_version`
++
++# TODO: should this explicitly check for a discrepancy between
++# resolved_version and installed_version? This indicates an app that's
++# not completely installed.
++
++# Find the resolver and resolve the version
+ resolver_name=`app-conf get app.resolver`
+ resolver=`find_resolver "$resolver_name"`
+
+-old_version=`app-conf get app.resolved_version`
+-echo "Resolving version $old_version"
++echo "Resolving version $version"
+ "$resolver" resolve-version
+-new_version=`app-conf get app.resolved_version`
++resolved_version=`app-conf get app.resolved_version`
+
+-if [[ $new_version == $old_version ]]
++if [[ $resolved_version == $installed_version ]]
+ then
+ echo "No new version available" 2>&1
+ exit
+ fi
+
+-echo "Resolved version to $new_version"
+-
+-if [ "$new_version" = "" ]
+-then
+- new_version=`app-conf get app.resolved_version`
+-fi
+-
+-if [ "$new_version" = "" ]
++if [ "$resolved_version" = "" ]
+ then
+ fatal "app.resolved_version is not set."
+ fi
+
+-installed_version=`app-conf get app.installed_version`
+-
+-if [ "$new_version" = "$installed_version" ]
+-then
+- echo "$new_version is already installed"
+- exit 0
+-fi
++echo "Resolved version to $resolved_version"
+
+-"$resolver" download-version -v "$new_version" -f .app/latest.zip
++"$resolver" download-version -v "$resolved_version" -f .app/latest.zip
+
+-app-install-file -v "$new_version" -f .app/latest.zip
++app-install-file -v "$resolved_version" -f .app/latest.zip
+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"
+ }
+diff --git a/test/app-init.bats b/test/app-init.bats
+index 8ffe1b6..e4dfeae 100755
+--- a/test/app-init.bats
++++ b/test/app-init.bats
+@@ -29,9 +29,10 @@ load utils
+ match '${lines[2]}' "Downloading org.example:app-a:1.0-*"
+ eq '${lines[3]}' "Unpacking..."
+ match '${lines[4]}' "Importing config from versions/1.0-*"
+- match '${lines[5]}' "Creating current symlink for version 1.0-*"
+- eq '${lines[6]}' "Post install"
+- eq '${#lines[*]}' 7
++ eq '${lines[5]}' "pre-install"
++ match '${lines[6]}' "Creating current symlink for version 1.0-*"
++ eq '${lines[7]}' "post-install"
++ eq '${#lines[*]}' 8
+
+ is_directory "my-app/.app"
+ # Created by post-install
+@@ -48,9 +49,10 @@ load utils
+ match '${lines[1]}' "Downloading org.example:app-a:1.0-*"
+ eq '${lines[2]}' "Unpacking..."
+ match '${lines[3]}' "Importing config from versions/1.0-*"
+- match '${lines[4]}' "Creating current symlink for version 1.0-*"
+- eq '${lines[5]}' "Post install"
+- eq '${#lines[*]}' 6
++ eq '${lines[4]}' "pre-install"
++ match '${lines[5]}' "Creating current symlink for version 1.0-*"
++ eq '${lines[6]}' "post-install"
++ eq '${#lines[*]}' 7
+
+ is_directory "my-app/.app"
+ # Created by post-install
+diff --git a/test/app-upgrade.bats b/test/app-upgrade.bats
+index d27c6e7..9a282e3 100755
+--- a/test/app-upgrade.bats
++++ b/test/app-upgrade.bats
+@@ -38,3 +38,33 @@ load utils
+ describe new_resolved_version = $new_resolved_version
+ neq $new_resolved_version $resolved_version
+ }
++
++@test "app-upgrade - when pre-install fails the first run" {
++ mkzip app-a
++ file=$APPSH_HOME/test/data/app-a.zip
++ touch -t 01010101 $file
++
++ app init -d my-app file $file
++
++ cd my-app
++
++ # A new version is available, but make sure pre-install fails.
++ touch -t 02020202 $file
++ touch fail-pre-install
++ check_status=no
++ app upgrade
++ eq '${status}' 1
++
++ # Try to reinstall the same file
++ rm fail-pre-install
++ app upgrade
++ eq '${lines[0]}' "Resolving version "
++ eq '${lines[1]}' "Resolved version to 1359766920"
++ eq '${lines[2]}' "Version 1359766920 is already unpacked"
++ eq '${lines[3]}' "Importing config from versions/1359766920/app.config"
++ eq '${lines[4]}' "pre-install"
++ eq '${lines[5]}' "Changing current symlink from 1356998460 to 1359766920"
++ eq '${lines[6]}' "post-install"
++
++ eq '${#lines[*]}' 7
++}
+diff --git a/test/data/app-a/hooks/post-install b/test/data/app-a/hooks/post-install
+index 1dfb7be..0717f2a 100755
+--- a/test/data/app-a/hooks/post-install
++++ b/test/data/app-a/hooks/post-install
+@@ -2,7 +2,13 @@
+
+ set -u
+
+-echo "Post install"
++echo "post-install"
++
++if [[ -e $APP_HOME/fail-post-install ]]
++then
++ echo "Simulating failure."
++ exit 1
++fi
+
+ NAME=`basename $APP_HOME`
+
+diff --git a/test/data/app-a/hooks/pre-install b/test/data/app-a/hooks/pre-install
+new file mode 100755
+index 0000000..4b95ac4
+--- /dev/null
++++ b/test/data/app-a/hooks/pre-install
+@@ -0,0 +1,11 @@
++#!/bin/bash -e
++
++set -u
++
++echo "pre-install"
++
++if [[ -e $APP_HOME/fail-pre-install ]]
++then
++ echo "Simulating failure."
++ exit 1
++fi
+--
+1.8.4.rc3
+