I’ve also filled an enhancement request to get snapcraft to support ‘on’ for the environment keyword.
Note ‘tomcat-launch’ was the original launcher (providered by a third party plugin), so my new launcher effectively chains the original tomcat-launcher.
The plugin essentially writes out the new laucher which does the check for which architecture the app is running on and sets the appropriate environment vars.
apps:
pi-gation:
command: pi-gation-launch
daemon: simple
plugs: [network, network-bind]
pi-gation-launch:
plugin: dump
install: |
cat <<EOF > $SNAPCRAFT_PART_INSTALL/pi-gation-launch
#!/bin/sh
ARCH=`uname -m`
if [ "$SNAP_ARCH" = "arm64" ] || [ "$SNAP_ARCH" = "armhf" ]; then
# no action require.
else
# Run the simulator as we are not on RPi hardware
export PI4J_PLATFORM="Simulated"
export SimulatedPlatform="RaspberryPi GPIO Provider"
fi
./tomcat-launch
EOF
chmod +x $SNAPCRAFT_PART_INSTALL/pi-gation-launch