Merge lp:~mvo/snappy-hub/snappy-examples-new-env-vars into lp:~snappy-dev/snappy-hub/snappy-examples

Proposed by Michael Vogt
Status: Merged
Merged at revision: 89
Proposed branch: lp:~mvo/snappy-hub/snappy-examples-new-env-vars
Merge into: lp:~snappy-dev/snappy-hub/snappy-examples
Diff against target: 150 lines (+16/-26)
10 files modified
config-example-bash/bin/hello (+2/-2)
config-example-bash/meta/hooks/config (+3/-3)
config-example/bin/hello (+2/-2)
config-example/meta/hooks/config (+1/-1)
go-example-webserver/magic-bin/go-example-webserver (+1/-7)
hello-dbus/package-dir-app/bin/dbus_message.client (+1/-5)
hello-dbus/package-dir-fwk/bin/dbus_service.start (+3/-3)
hello-dbus/src/Makefile (+1/-1)
hello-world/bin/showdev (+1/-1)
hello-world/bin/usehw (+1/-1)
To merge this branch: bzr merge lp:~mvo/snappy-hub/snappy-examples-new-env-vars
Reviewer Review Type Date Requested Status
Snappy Developers Pending
Review via email: mp+282700@code.launchpad.net

Description of the change

Update the examples for the new snappy environment variables

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config-example-bash/bin/hello'
--- config-example-bash/bin/hello 2015-05-29 08:24:53 +0000
+++ config-example-bash/bin/hello 2016-01-15 08:23:07 +0000
@@ -1,7 +1,7 @@
1#!/bin/sh1#!/bin/sh
22
3if [ -e ${SNAP_APP_DATA_PATH}/message ]; then3if [ -e ${SNAP_DATA}/message ]; then
4 cat ${SNAP_APP_DATA_PATH}/message4 cat ${SNAP_DATA}/message
5else5else
6 cat <<EOF26 cat <<EOF2
7Hello from the bash config example!7Hello from the bash config example!
88
=== modified file 'config-example-bash/meta/hooks/config'
--- config-example-bash/meta/hooks/config 2015-03-28 16:31:12 +0000
+++ config-example-bash/meta/hooks/config 2016-01-15 08:23:07 +0000
@@ -7,12 +7,12 @@
7# read stdin with the "ypath" helper (if there is any input)7# read stdin with the "ypath" helper (if there is any input)
8CFG="$($HELPER /config/${SNAP_NAME}/msg 2>/dev/null || true)"8CFG="$($HELPER /config/${SNAP_NAME}/msg 2>/dev/null || true)"
9if [ -n "$CFG" ]; then9if [ -n "$CFG" ]; then
10 printf "$CFG" > ${SNAP_APP_DATA_PATH}/message10 printf "$CFG" > ${SNAP_DATA}/message
11fi11fi
1212
13# read existing message13# read existing message
14if [ -e "${SNAP_APP_DATA_PATH}/message" ]; then14if [ -e "${SNAP_DATA}/message" ]; then
15 msg=$(cat ${SNAP_APP_DATA_PATH}/message)15 msg=$(cat ${SNAP_DATA}/message)
16fi16fi
1717
18# output current config18# output current config
1919
=== modified file 'config-example/bin/hello'
--- config-example/bin/hello 2015-05-29 08:24:53 +0000
+++ config-example/bin/hello 2016-01-15 08:23:07 +0000
@@ -1,7 +1,7 @@
1#!/bin/sh1#!/bin/sh
22
3if [ -e ${SNAP_APP_DATA_PATH}/message ]; then3if [ -e ${SNAP_DATA}/message ]; then
4 cat ${SNAP_APP_DATA_PATH}//message4 cat ${SNAP_DATA}/message
5else5else
6 cat <<EOF26 cat <<EOF2
7Hello from the config example!7Hello from the config example!
88
=== modified file 'config-example/meta/hooks/config'
--- config-example/meta/hooks/config 2015-05-29 08:24:53 +0000
+++ config-example/meta/hooks/config 2016-01-15 08:23:07 +0000
@@ -5,7 +5,7 @@
5import yaml5import yaml
66
7PKGNAME = "config-example"7PKGNAME = "config-example"
8MSG_FILE = os.path.join(os.environ["SNAP_APP_DATA_PATH"], "message")8MSG_FILE = os.path.join(os.environ["SNAP_DATA"], "message")
99
1010
11def get_config():11def get_config():
1212
=== modified file 'go-example-webserver/magic-bin/go-example-webserver'
--- go-example-webserver/magic-bin/go-example-webserver 2015-05-21 19:48:45 +0000
+++ go-example-webserver/magic-bin/go-example-webserver 2016-01-15 08:23:07 +0000
@@ -24,15 +24,9 @@
24 ;;24 ;;
25esac25esac
2626
27# workaround that snappy services have bogus SNAP_ vars set; assume PWD is right
28echo "$SNAP_APP_PATH" | grep -q SNAP_APP && SNAP_APP_PATH=$PWD
29if test -z "$SNAP_APP_PATH"; then
30 SNAP_APP_PATH=$PWD
31fi
32
33snapp_bin_path=$027snapp_bin_path=$0
34snapp_bin=`basename $snapp_bin_path`28snapp_bin=`basename $snapp_bin_path`
35snapp_dir=$SNAP_APP_PATH29snapp_dir=$SNAP
36snapp_name=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\1/g'`30snapp_name=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\1/g'`
37snapp_org_bin=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\2/g'`31snapp_org_bin=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\2/g'`
3832
3933
=== modified file 'hello-dbus/package-dir-app/bin/dbus_message.client'
--- hello-dbus/package-dir-app/bin/dbus_message.client 2015-04-28 20:53:10 +0000
+++ hello-dbus/package-dir-app/bin/dbus_message.client 2016-01-15 08:23:07 +0000
@@ -1,8 +1,4 @@
1#!/bin/sh1#!/bin/sh
2set -e2set -e
33
4if [ -z "$SNAPPY_APP_ARCH" ]; then4$SNAP/bin/dbus_message.$SNAP_ARCH --system --name="com.canonical.hello-dbus-fwk" --type=method_call "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv.Method"
5 SNAPPY_APP_ARCH=`$SNAP_APP_PATH/bin/get_arch`
6fi
7
8$SNAP_APP_PATH/bin/dbus_message.$SNAPPY_APP_ARCH --system --name="com.canonical.hello-dbus-fwk" --type=method_call "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv.Method"
95
=== modified file 'hello-dbus/package-dir-fwk/bin/dbus_service.start'
--- hello-dbus/package-dir-fwk/bin/dbus_service.start 2015-04-28 20:53:10 +0000
+++ hello-dbus/package-dir-fwk/bin/dbus_service.start 2016-01-15 08:23:07 +0000
@@ -1,8 +1,8 @@
1#!/bin/sh1#!/bin/sh
2set -e2set -e
33
4if [ -z "$SNAPPY_APP_ARCH" ]; then4if [ -z "$SNAP_ARCH" ]; then
5 SNAPPY_APP_ARCH=`$SNAP_APP_PATH/bin/get_arch`5 SNAP_ARCH=`$SNAP/bin/get_arch`
6fi6fi
77
8$SNAP_APP_PATH/bin/dbus_service.$SNAPPY_APP_ARCH --system --name="com.canonical.hello-dbus-fwk" "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv"8$SNAP/bin/dbus_service.$SNAP_ARCH --system --name="com.canonical.hello-dbus-fwk" "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv"
99
=== modified file 'hello-dbus/src/Makefile'
--- hello-dbus/src/Makefile 2015-04-28 20:53:10 +0000
+++ hello-dbus/src/Makefile 2016-01-15 08:23:07 +0000
@@ -4,7 +4,7 @@
4# make4# make
5# make install5# make install
66
7# This should match SNAP_APP_ARCH7# This should match SNAP_ARCH
8BUILD_ARCH := $(shell dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d '=')8BUILD_ARCH := $(shell dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d '=')
99
10CFLAGS += -g -O0 -Wall -Wstrict-prototypes10CFLAGS += -g -O0 -Wall -Wstrict-prototypes
1111
=== modified file 'hello-world/bin/showdev'
--- hello-world/bin/showdev 2015-04-22 16:59:33 +0000
+++ hello-world/bin/showdev 2016-01-15 08:23:07 +0000
@@ -10,7 +10,7 @@
1010
11find $findargs11find $findargs
1212
13APPNAME=`echo $SNAP_APP_PATH | cut -f 3 -d '/'`13APPNAME=`echo $SNAP | cut -f 3 -d '/'`
14echo ""14echo ""
15echo "Here is hardware that has been assigned to me ($APPNAME):"15echo "Here is hardware that has been assigned to me ($APPNAME):"
16udevadm trigger --verbose --dry-run --tag-match=snappy-assign --property-match=SNAPPY_APP="$APPNAME"16udevadm trigger --verbose --dry-run --tag-match=snappy-assign --property-match=SNAPPY_APP="$APPNAME"
1717
=== modified file 'hello-world/bin/usehw'
--- hello-world/bin/usehw 2015-04-22 18:26:34 +0000
+++ hello-world/bin/usehw 2016-01-15 08:23:07 +0000
@@ -6,7 +6,7 @@
6echo "This example demonstrates the app confinement for assigned hardware"6echo "This example demonstrates the app confinement for assigned hardware"
7echo ""7echo ""
88
9APPNAME=`echo $SNAP_APP_PATH | cut -f 3 -d '/'`9APPNAME=`echo $SNAP | cut -f 3 -d '/'`
10if [ -z "$APPNAME" ]; then10if [ -z "$APPNAME" ]; then
11 echo "Could not determine application name."11 echo "Could not determine application name."
12 exit 112 exit 1

Subscribers

People subscribed via source and target branches