#/bin/sh

# Export LD_LIBRARY_PATH based on triplet
if [ "$SNAP_ARCH" = "amd64" ]; then
  ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" = "armhf" ]; then
  ARCH="arm-linux-gnueabihf"
elif [ "$SNAP_ARCH" = "arm64" ]; then
  ARCH="aarch64-linux-gnu"
else
  ARCH="$SNAP_ARCH-linux-gnu"
fi
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$ARCH:$SNAP/usr/lib/$ARCH"

# Set those environments here. If exported in snapcraft.yaml, they don't have any effect (while being exported) anymore.
export PYTHONUSERBASE=$SNAP
export PYTHONHOME=$SNAP/usr

# We need to set our local python3 binary in PATH so that system one isn't used (especially when executing subprocess if sudo needed)
export PATH=$SNAP/usr/bin/:$PATH

exec "$SNAP/bin/umake" "$@"

