From 7b10faf47aa46e3bbcff87acafed7ac4710c2139 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Thu, 5 Jul 2018 09:18:41 +0200 Subject: [PATCH] scripts: enable linker debugging when running in debug mode --- scripts/container-manager.sh | 8 +++++--- scripts/snap-wrapper.sh | 3 ++- snap/hooks/configure | 8 +++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/container-manager.sh b/scripts/container-manager.sh index b67d614..7eda23e 100755 --- a/scripts/container-manager.sh +++ b/scripts/container-manager.sh @@ -61,8 +61,10 @@ start() { $SNAP/sbin/apparmor_parser -r $SNAP/apparmor/anbox-container.aa fi - if [ -e "$SNAP_COMMON"/.enable_debug ]; then + enable_debug="$(snapctl get debug.enable)" + if [ "$enable_debug" = true ]; then export ANBOX_LOG_LEVEL=debug + export LD_DEBUG=libs fi EXTRA_ARGS= @@ -71,8 +73,8 @@ start() { EXTRA_ARGS="$EXTRA_ARGS --use-rootfs-overlay" fi - privileged_container="$(snapctl get container.privileged)" - if [ "$privileged_container" = true ]; then + enable_privileged_container="$(snapctl get container.privileged)" + if [ "$enable_privileged_container" = true ]; then EXTRA_ARGS="$EXTRA_ARGS --privileged" fi diff --git a/scripts/snap-wrapper.sh b/scripts/snap-wrapper.sh index 60877db..e0e2e80 100755 --- a/scripts/snap-wrapper.sh +++ b/scripts/snap-wrapper.sh @@ -29,7 +29,8 @@ export XDG_DATA_HOME="$SNAP_USER_COMMON/app-data" # configured but the actual EGL implementation is missing. export __EGL_VENDOR_LIBRARY_DIRS="$SNAP/glvnd" -if [ -e "$SNAP_COMMON"/.enable_debug ]; then +enable_debug="$(snapctl get debug.enable)" +if [ "$enable_debug" = true ]; then export ANBOX_LOG_LEVEL=debug fi diff --git a/snap/hooks/configure b/snap/hooks/configure index 89dea03..0677cf6 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -1,9 +1,7 @@ #!/bin/sh -if [ "$(snapctl get debug.enable)" = true ]; then - touch "$SNAP_COMMON"/.enable_debug -else - rm -f "$SNAP_COMMON"/.enable_debug -fi +# We need to have something for snapd in place in order to +# allow configuration options for our snap even if the items +# are read via snapctl elsewhere in the code. exit 0