From e8fa85304cc9f69fee09fa67c7b61e75cf8ba580 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 16 Feb 2024 16:08:23 +0100 Subject: [vmware.*] Try to avoid chroot in addon-required check script --- core/modules/vmware17/data/addon-required | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'core/modules/vmware17') diff --git a/core/modules/vmware17/data/addon-required b/core/modules/vmware17/data/addon-required index a86e41bc..a84bb7ff 100644 --- a/core/modules/vmware17/data/addon-required +++ b/core/modules/vmware17/data/addon-required @@ -1,19 +1,32 @@ #!/bin/bash -# the vmware helper needs the kmod msr and the tool rdmsr, -# /dev, /sys and /proc to properly detect the CPU info. +version=$( "$NEWROOT/opt/openslx/bin/vmware-get-supported-version" ) -bindmount=("/dev" "/proc" "/sys") +# Calling directly failed, try to chroot to $NEWROOT and call again -for bm in "${bindmount[@]}"; do - mount --bind "$bm" "${NEWROOT}/${bm}" -done +if [ -z "$version" ] || [ "$version" = "fail" ]; then + # the vmware helper needs the kmod msr and the tool rdmsr, + # /dev, /sys and /proc to properly detect the CPU info. -export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin" -version="$(chroot "$NEWROOT" vmware-get-supported-version)" + declare -a bindmount=( "/dev" "/proc" "/sys" ) + declare -a bound=() + echo "Direct version check failed, trying chroot..." -for bm in "${bindmount[@]}"; do - umount "${NEWROOT}/${bm}" -done + cleanup() { + for bm in "${bound[@]}"; do + umount "${NEWROOT}/${bm}" + done + } + trap cleanup EXIT + + for bm in "${bindmount[@]}"; do + mount --bind "$bm" "${NEWROOT}/${bm}" || exit 1 + bound+=( "$bm" ) + done + + export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin" + version="$( chroot "$NEWROOT" vmware-get-supported-version )" + +fi [ -n "$version" ] && [ "$version" = "new" ] -- cgit v1.2.3-55-g7522