Permalink
Browse files

Replace SNAP envvars with the 16.04 ones.

LP: #1533552
  • Loading branch information...
1 parent fe9ca74 commit 04b1a13bc03305bc3180e71ede2f39b3183482d9 @sergiusens sergiusens committed Jan 15, 2016
View
@@ -160,7 +160,7 @@ We'll write a tiny little script that runs the server and `fswebcam` together:
#!/bin/sh
set -e
- cd "$SNAP_APP_DATA_PATH"
+ cd "$SNAP_DATA"
golang-static-http &
View
@@ -2,9 +2,9 @@
set -x
-cd $SNAP_APP_DATA_PATH
-cp $SNAP_APP_PATH/web.template .
-cp -r $SNAP_APP_PATH/static .
-export HOME=$SNAP_APP_DATA_PATH
+cd $SNAP_DATA
+cp $SNAP/web.template .
+cp -r $SNAP/static .
+export HOME=$SNAP_DATA
-exec $SNAP_APP_PATH/bin/gopasted -port 8080 -external-host snappy
+exec $SNAP/bin/gopasted -port 8080 -external-host snappy
@@ -6,7 +6,7 @@ icon: icon.png
apps:
server:
- command: bin/shout --home $SNAP_APP_DATA_PATH
+ command: bin/shout --home $SNAP_DATA
daemon: simple
parts:
@@ -4,9 +4,9 @@ set -e
set -x
# installation pathes are based of CATALINA_HOME
-export CATALINA_HOME="$SNAP_APP_PATH"
+export CATALINA_HOME="$SNAP"
# writable pathes are based of CATALINA_BASE
-export CATALINA_BASE="$SNAP_APP_DATA_PATH"
+export CATALINA_BASE="$SNAP_DATA"
# create runtime data
mkdir -p "$CATALINA_BASE/logs"
@@ -20,4 +20,3 @@ if ! [ -d $CATALINA_BASE/webapps ]; then
fi
$CATALINA_HOME/bin/catalina.sh run
-
@@ -11,7 +11,7 @@
def main():
- config_file = os.path.join(os.environ['SNAP_APP_DATA_PATH'], _CONFIG)
+ config_file = os.path.join(os.environ['SNAP_DATA'], _CONFIG)
config_yaml = yaml.load(sys.stdin)
if config_yaml:
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-cd "$SNAP_APP_DATA_PATH"
+cd "$SNAP_DATA"
[ -f configuration ] && interval=$(sed -n 's/.*interval: `\([0-9.]\+\).*/\1/p' configuration)
@@ -1,5 +1,5 @@
#!/bin/sh
-export PATH="$SNAP_APP_PATH/bin:$SNAP_APP_PATH/usr/bin:$PATH"
-export LD_LIBRARY_PATH="$SNAP_APP_PATH/lib:$SNAP_APP_PATH/usr/lib:$SNAP_APP_PATH/lib/@MULTIARCH@:$SNAP_APP_PATH/usr/lib/@MULTIARCH@:$LD_LIBRARY_PATH"
+export PATH="$SNAP/bin:$SNAP/usr/bin:$PATH"
+export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/@MULTIARCH@:$SNAP/usr/lib/@MULTIARCH@:$LD_LIBRARY_PATH"
-exec "$SNAP_APP_PATH/binary1" $*
+exec "$SNAP/binary1" $*
@@ -11,7 +11,7 @@
def main():
- config_file = os.path.join(os.environ['SNAP_APP_DATA_PATH'], _CONFIG)
+ config_file = os.path.join(os.environ['SNAP_DATA'], _CONFIG)
config_yaml = yaml.load(sys.stdin)
if config_yaml:
@@ -45,8 +45,8 @@ def test_snap_with_pypi_config(self):
FileExists())
expected_config = (
- 'exec "$SNAP_APP_PATH/usr/bin/python3" '
- '"$SNAP_APP_PATH/usr/bin/config.py" $*\n')
+ 'exec "$SNAP/usr/bin/python3" '
+ '"$SNAP/usr/bin/config.py" $*\n')
with open(os.path.join(
project_dir, 'snap', 'meta', 'hooks', 'config')) as config:
config_contents = config.read()
@@ -62,7 +62,7 @@ def test_snap(self):
self.useFixture(
fixtures.EnvironmentVariable(
- 'SNAP_APP_PATH', os.path.join(os.getcwd(), 'snap')))
+ 'SNAP', os.path.join(os.getcwd(), 'snap')))
binary_scenarios = (
('command-assemble-service.wrapper', 'service-start\n'),
('stop-command-assemble-service.wrapper', 'service-stop\n'),
View
@@ -157,18 +157,17 @@ def _write_wrap_exe(wrapexec, wrappath, shebang=None, args=None, cwd=None):
cwd = 'cd {}'.format(cwd) if cwd else ''
snap_dir = common.get_snapdir()
- assembled_env = common.assemble_env().replace(snap_dir, '$SNAP_APP_PATH')
+ assembled_env = common.assemble_env().replace(snap_dir, '$SNAP')
replace_path = r'{}/[a-z0-9][a-z0-9+-]*/install'.format(
common.get_partsdir())
- assembled_env = re.sub(replace_path, '$SNAP_APP_PATH', assembled_env)
+ assembled_env = re.sub(replace_path, '$SNAP', assembled_env)
executable = '"{}"'.format(wrapexec)
if shebang is not None:
- new_shebang = re.sub(replace_path, '$SNAP_APP_PATH', shebang)
+ new_shebang = re.sub(replace_path, '$SNAP', shebang)
if new_shebang != shebang:
# If the shebang was pointing to and executable within the
# local 'parts' dir, have the wrapper script execute it
- # directly, since we can't use $SNAP_APP_PATH in the shebang
- # itself.
+ # directly, since we can't use $SNAP in the shebang itself.
executable = '"{}" "{}"'.format(new_shebang, wrapexec)
script = ('#!/bin/sh\n' +
'{}\n'.format(assembled_env) +
@@ -194,7 +193,7 @@ def _wrap_exe(command, basename=None):
if os.path.exists(wrappath):
os.remove(wrappath)
- wrapexec = '$SNAP_APP_PATH/{}'.format(execparts[0])
+ wrapexec = '$SNAP/{}'.format(execparts[0])
if not os.path.exists(exepath) and '/' not in execparts[0]:
# If it doesn't exist it might be in the path
logger.debug('Checking to see if {!r} is in the $PATH'.format(
@@ -121,7 +121,7 @@ def env(self, root):
# Various ROS tools (e.g. rospack, roscore) keep a cache or a log,
# and use $ROS_HOME to determine where to put them.
- 'ROS_HOME=$SNAP_APP_USER_DATA_PATH/ros',
+ 'ROS_HOME=$SNAP_USER_DATA/ros',
# This environment variable points to where the setup.sh and
# _setup_util.py files are located. This is required at both build-
@@ -51,7 +51,7 @@ def __init__(self, name, options):
def build(self):
os.makedirs(os.path.join(self.installdir, 'bin'), exist_ok=True)
ros_dir = os.path.join(
- '$SNAP_APP_PATH',
+ '$SNAP',
'opt',
'ros',
self.options.rosdistro)
@@ -128,7 +128,7 @@ def test_create_meta_with_config_with_args(self):
expected_wrapper = [
'#!/bin/sh\n', '\n', '\n',
- 'exec "$SNAP_APP_PATH/config.sh" something $*\n']
+ 'exec "$SNAP/config.sh" something $*\n']
self.assertEqual(config_wrapper, expected_wrapper)
def test_create_meta_with_app_with_security_policy(self):
@@ -200,9 +200,9 @@ def test_wrap_exe_must_write_wrapper(self, mock_assemble_env):
wrapper_path = os.path.join(snapdir, relative_wrapper_path)
expected = ('#!/bin/sh\n'
- 'PATH=$SNAP_APP_PATH/usr/bin:$SNAP_APP_PATH/bin\n'
+ 'PATH=$SNAP/usr/bin:$SNAP/bin\n'
'\n\n'
- 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
+ 'exec "$SNAP/test_relexepath" $*\n')
with open(wrapper_path) as wrapper_file:
wrapper_contents = wrapper_file.read()
@@ -227,9 +227,9 @@ def test_wrap_exe_writes_wrapper_with_basename(self, mock_assemble_env):
self.assertEqual(relative_wrapper_path, 'new-name.wrapper')
expected = ('#!/bin/sh\n'
- 'PATH=$SNAP_APP_PATH/usr/bin:$SNAP_APP_PATH/bin\n'
+ 'PATH=$SNAP/usr/bin:$SNAP/bin\n'
'\n\n'
- 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
+ 'exec "$SNAP/test_relexepath" $*\n')
with open(wrapper_path) as wrapper_file:
wrapper_contents = wrapper_file.read()
@@ -244,8 +244,8 @@ def test_snap_shebangs_extracted(self):
The shebang needs to be an absolute path, and we don't know
in which directory the snap will be installed. Executing
- it in the wrapper script allows us to use the $SNAP_APP_PATH
- environment variable.
+ it in the wrapper script allows us to use the $SNAP environment
+ variable.
"""
snapdir = common.get_snapdir()
partsdir = common.get_partsdir()
@@ -264,8 +264,8 @@ def test_snap_shebangs_extracted(self):
expected = (
'#!/bin/sh\n'
'\n\n'
- 'exec "$SNAP_APP_PATH/snap_exe"'
- ' "$SNAP_APP_PATH/test_relexepath" $*\n')
+ 'exec "$SNAP/snap_exe"'
+ ' "$SNAP/test_relexepath" $*\n')
with open(wrapper_path) as wrapper_file:
wrapper_contents = wrapper_file.read()
@@ -294,7 +294,7 @@ def test_non_snap_shebangs_ignored(self):
expected = ('#!/bin/sh\n'
'\n\n'
- 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
+ 'exec "$SNAP/test_relexepath" $*\n')
with open(wrapper_path) as wrapper_file:
wrapper_contents = wrapper_file.read()
@@ -323,7 +323,7 @@ def test_non_shebang_binaries_ignored(self):
expected = ('#!/bin/sh\n'
'\n\n'
- 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
+ 'exec "$SNAP/test_relexepath" $*\n')
with open(wrapper_path) as wrapper_file:
wrapper_contents = wrapper_file.read()
@@ -533,7 +533,7 @@ def test_run_environment(self, run_mock):
self.assertTrue('ROS_MASTER_URI=http://localhost:11311' in environment)
- self.assertTrue('ROS_HOME=$SNAP_APP_USER_DATA_PATH/ros' in environment)
+ self.assertTrue('ROS_HOME=$SNAP_USER_DATA/ros' in environment)
self.assertTrue('_CATKIN_SETUP_DIR={}'.format(os.path.join(
'/foo', 'opt', 'ros', self.properties.rosdistro)) in environment)

0 comments on commit 04b1a13

Please sign in to comment.