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
1=== modified file 'config-example-bash/bin/hello'
2--- config-example-bash/bin/hello 2015-05-29 08:24:53 +0000
3+++ config-example-bash/bin/hello 2016-01-15 08:23:07 +0000
4@@ -1,7 +1,7 @@
5 #!/bin/sh
6
7-if [ -e ${SNAP_APP_DATA_PATH}/message ]; then
8- cat ${SNAP_APP_DATA_PATH}/message
9+if [ -e ${SNAP_DATA}/message ]; then
10+ cat ${SNAP_DATA}/message
11 else
12 cat <<EOF2
13 Hello from the bash config example!
14
15=== modified file 'config-example-bash/meta/hooks/config'
16--- config-example-bash/meta/hooks/config 2015-03-28 16:31:12 +0000
17+++ config-example-bash/meta/hooks/config 2016-01-15 08:23:07 +0000
18@@ -7,12 +7,12 @@
19 # read stdin with the "ypath" helper (if there is any input)
20 CFG="$($HELPER /config/${SNAP_NAME}/msg 2>/dev/null || true)"
21 if [ -n "$CFG" ]; then
22- printf "$CFG" > ${SNAP_APP_DATA_PATH}/message
23+ printf "$CFG" > ${SNAP_DATA}/message
24 fi
25
26 # read existing message
27-if [ -e "${SNAP_APP_DATA_PATH}/message" ]; then
28- msg=$(cat ${SNAP_APP_DATA_PATH}/message)
29+if [ -e "${SNAP_DATA}/message" ]; then
30+ msg=$(cat ${SNAP_DATA}/message)
31 fi
32
33 # output current config
34
35=== modified file 'config-example/bin/hello'
36--- config-example/bin/hello 2015-05-29 08:24:53 +0000
37+++ config-example/bin/hello 2016-01-15 08:23:07 +0000
38@@ -1,7 +1,7 @@
39 #!/bin/sh
40
41-if [ -e ${SNAP_APP_DATA_PATH}/message ]; then
42- cat ${SNAP_APP_DATA_PATH}//message
43+if [ -e ${SNAP_DATA}/message ]; then
44+ cat ${SNAP_DATA}/message
45 else
46 cat <<EOF2
47 Hello from the config example!
48
49=== modified file 'config-example/meta/hooks/config'
50--- config-example/meta/hooks/config 2015-05-29 08:24:53 +0000
51+++ config-example/meta/hooks/config 2016-01-15 08:23:07 +0000
52@@ -5,7 +5,7 @@
53 import yaml
54
55 PKGNAME = "config-example"
56-MSG_FILE = os.path.join(os.environ["SNAP_APP_DATA_PATH"], "message")
57+MSG_FILE = os.path.join(os.environ["SNAP_DATA"], "message")
58
59
60 def get_config():
61
62=== modified file 'go-example-webserver/magic-bin/go-example-webserver'
63--- go-example-webserver/magic-bin/go-example-webserver 2015-05-21 19:48:45 +0000
64+++ go-example-webserver/magic-bin/go-example-webserver 2016-01-15 08:23:07 +0000
65@@ -24,15 +24,9 @@
66 ;;
67 esac
68
69-# workaround that snappy services have bogus SNAP_ vars set; assume PWD is right
70-echo "$SNAP_APP_PATH" | grep -q SNAP_APP && SNAP_APP_PATH=$PWD
71-if test -z "$SNAP_APP_PATH"; then
72- SNAP_APP_PATH=$PWD
73-fi
74-
75 snapp_bin_path=$0
76 snapp_bin=`basename $snapp_bin_path`
77-snapp_dir=$SNAP_APP_PATH
78+snapp_dir=$SNAP
79 snapp_name=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\1/g'`
80 snapp_org_bin=`echo $snapp_bin | sed -e 's/\(.*\)[.]\([^.]*\)$/\2/g'`
81
82
83=== modified file 'hello-dbus/package-dir-app/bin/dbus_message.client'
84--- hello-dbus/package-dir-app/bin/dbus_message.client 2015-04-28 20:53:10 +0000
85+++ hello-dbus/package-dir-app/bin/dbus_message.client 2016-01-15 08:23:07 +0000
86@@ -1,8 +1,4 @@
87 #!/bin/sh
88 set -e
89
90-if [ -z "$SNAPPY_APP_ARCH" ]; then
91- SNAPPY_APP_ARCH=`$SNAP_APP_PATH/bin/get_arch`
92-fi
93-
94-$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+$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"
96
97=== modified file 'hello-dbus/package-dir-fwk/bin/dbus_service.start'
98--- hello-dbus/package-dir-fwk/bin/dbus_service.start 2015-04-28 20:53:10 +0000
99+++ hello-dbus/package-dir-fwk/bin/dbus_service.start 2016-01-15 08:23:07 +0000
100@@ -1,8 +1,8 @@
101 #!/bin/sh
102 set -e
103
104-if [ -z "$SNAPPY_APP_ARCH" ]; then
105- SNAPPY_APP_ARCH=`$SNAP_APP_PATH/bin/get_arch`
106+if [ -z "$SNAP_ARCH" ]; then
107+ SNAP_ARCH=`$SNAP/bin/get_arch`
108 fi
109
110-$SNAP_APP_PATH/bin/dbus_service.$SNAPPY_APP_ARCH --system --name="com.canonical.hello-dbus-fwk" "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv"
111+$SNAP/bin/dbus_service.$SNAP_ARCH --system --name="com.canonical.hello-dbus-fwk" "/com/canonical/HelloDbusFramework/DbusSrv" "com.canonical.HelloDbusFramework.DbusSrv"
112
113=== modified file 'hello-dbus/src/Makefile'
114--- hello-dbus/src/Makefile 2015-04-28 20:53:10 +0000
115+++ hello-dbus/src/Makefile 2016-01-15 08:23:07 +0000
116@@ -4,7 +4,7 @@
117 # make
118 # make install
119
120-# This should match SNAP_APP_ARCH
121+# This should match SNAP_ARCH
122 BUILD_ARCH := $(shell dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d '=')
123
124 CFLAGS += -g -O0 -Wall -Wstrict-prototypes
125
126=== modified file 'hello-world/bin/showdev'
127--- hello-world/bin/showdev 2015-04-22 16:59:33 +0000
128+++ hello-world/bin/showdev 2016-01-15 08:23:07 +0000
129@@ -10,7 +10,7 @@
130
131 find $findargs
132
133-APPNAME=`echo $SNAP_APP_PATH | cut -f 3 -d '/'`
134+APPNAME=`echo $SNAP | cut -f 3 -d '/'`
135 echo ""
136 echo "Here is hardware that has been assigned to me ($APPNAME):"
137 udevadm trigger --verbose --dry-run --tag-match=snappy-assign --property-match=SNAPPY_APP="$APPNAME"
138
139=== modified file 'hello-world/bin/usehw'
140--- hello-world/bin/usehw 2015-04-22 18:26:34 +0000
141+++ hello-world/bin/usehw 2016-01-15 08:23:07 +0000
142@@ -6,7 +6,7 @@
143 echo "This example demonstrates the app confinement for assigned hardware"
144 echo ""
145
146-APPNAME=`echo $SNAP_APP_PATH | cut -f 3 -d '/'`
147+APPNAME=`echo $SNAP | cut -f 3 -d '/'`
148 if [ -z "$APPNAME" ]; then
149 echo "Could not determine application name."
150 exit 1

Subscribers

People subscribed via source and target branches