From 9a123792c2dc71213c41dc14cab984de84092dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Hohwiller?= Date: Tue, 25 Oct 2022 10:09:33 +0200 Subject: [PATCH] #940: fixes for MacOS workaround --- .../main/resources/scripts/command/eclipse | 6 +- .../src/main/resources/scripts/command/vscode | 6 -- scripts/src/main/resources/scripts/functions | 102 ++++++++++-------- 3 files changed, 61 insertions(+), 53 deletions(-) diff --git a/scripts/src/main/resources/scripts/command/eclipse b/scripts/src/main/resources/scripts/command/eclipse index 04c71f489..effbe3f7e 100755 --- a/scripts/src/main/resources/scripts/command/eclipse +++ b/scripts/src/main/resources/scripts/command/eclipse @@ -21,10 +21,10 @@ if [ -n "${EXTRA_JAVA_VERSION}" ] then ECLIPSE_JAVA_HOME="${DEVON_IDE_HOME}/software/extra/java" fi -ECLIPSE_PRODUCT="${ECLIPSE_HOME}/Eclipse.app/Contents/Eclipse/.eclipseproduct" -if [ ! -e "${ECLIPSE_PRODUCT}" ] +ECLIPSE_PRODUCT="${ECLIPSE_HOME}/.eclipseproduct" +if [ "${OSTYPE:0:6}" = "darwin" ] # cannot use doIsMacOs here then - ECLIPSE_PRODUCT="${ECLIPSE_HOME}/.eclipseproduct" + ECLIPSE_PRODUCT="${DEVON_IDE_HOME}/software/macos/eclipse/Eclipse.app/Contents/Eclipse/.eclipseproduct" fi TOOL_VERSION_COMMAND="cat '${ECLIPSE_PRODUCT}'" # shellcheck source=scripts/functions diff --git a/scripts/src/main/resources/scripts/command/vscode b/scripts/src/main/resources/scripts/command/vscode index d5522b9b7..23df03bed 100755 --- a/scripts/src/main/resources/scripts/command/vscode +++ b/scripts/src/main/resources/scripts/command/vscode @@ -25,12 +25,6 @@ function doSetup() { doInstall "vscode" "${VSCODE_VERSION}" "${1}" if [ "${?}" = 0 ] then - if doIsMacOs - then - mkdir "${VSCODE_HOME}/bin" - echo -e "#!/usr/bin/env bash\n\"${VSCODE_HOME}/Visual Studio Code.app/Contents/MacOS/Electron\" \$@" > "${VSCODE_HOME}/bin/code" - chmod a+x "${VSCODE_HOME}/bin/code" - fi cleanupPlugins doAddPlugins fi diff --git a/scripts/src/main/resources/scripts/functions b/scripts/src/main/resources/scripts/functions index d6942ed3f..d97034139 100755 --- a/scripts/src/main/resources/scripts/functions +++ b/scripts/src/main/resources/scripts/functions @@ -812,7 +812,7 @@ function doReplaceExtractedSkipSingleFolder() { local target_dir="${2}" local backup_dir="${3}" shift 3 - if [ "${#*}" = 1 ] && [ -d "${1}" ] + if [ "${#*}" = 1 ] && [ "${1%.app}" = "${1}" ] && [ -d "${1}" ] then doDebug "Changing source directory from ${source_dir} to ${1} due to single folder." source_dir="${1}" @@ -1206,6 +1206,10 @@ function doInstall() { if [ -z "${silent}" ] then doEcho "Version ${version} of ${software} is already installed." + if [ -n "${TOOL_VERSION_COMMAND}" ] && [ "${TOOL_VERSION_COMMAND}" != "-" ] && ! doIsQuiet + then + doRunCommand "${TOOL_VERSION_COMMAND}" "verify installation of ${software}" + fi fi return 1 else @@ -1307,55 +1311,65 @@ function doInstall() { fi # macos workaround - if [ ! -d "${target_path}/bin" ] && doIsMacOs && [ -d "${target_path}/Contents/" ] + if [ ! -d "${target_path}/bin" ] && doIsMacOs then - doDebug "Found MacOS app in ${target_path}" - local app_folder="-" - if [ -d "${target_path}/Contents/Resources/app/bin" ] + local contents="Contents" + if ! [ -d "${target_path}/${contents}" ] then - app_folder="Resources/app" - else - local folder - while IFS= read -r -d '' folder - do - folder="${folder/*\//}" - doDebug "Checking app sub-folder ${folder}" - if [ "${folder}" != "Contents" ] && [ "${folder}" != "Resources" ] && [ "${folder}" != "bin" ] && [ "${folder:0:1}" != "_" ] - then - if [ -d "${target_path}/Contents/${folder}/bin" ] - then - app_folder="${folder/*\//}" - doDebug "App folder with bin detected as ${app_folder}" - break - else - doDebug "Looking for executable in ${folder}" - local file - while IFS= read -r -d '' file - do - if [ -x "${file}" ] && [ "${file:(-4)}" != ".txt" ] - then - app_folder="${folder/*\//}" - doDebug "App folder with executable detected as ${app_folder}" - break - fi - done < <(find "${target_path}/Contents/${folder}/" -maxdepth 1 -type f -print0) - fi - fi - done < <(find "${target_path}/Contents" -maxdepth 1 -type d -print0) + pushd "${target_path}" > /dev/null || exit 255 + contents="$(doGetFirstExistingPath *.app/Contents)" + popd > /dev/null || exit 255 fi - if [ "${app_folder}" != "-" ] && [ -d "${target_path}/Contents/${app_folder}" ] + if [ -d "${target_path}/${contents}" ] then - doEcho "Creating symlink as workaround for ${software} on MacOS" - local target_software_macos=${target_path%\/*}/macos - if [ ! -d "${target_software_macos}" ] + doDebug "Found MacOS app in ${target_path}/${contents}" + local app_folder="-" + if [ -d "${target_path}/${contents}/Resources/app/bin" ] then - mkdir -p "${target_software_macos}" + app_folder="Resources/app" + else + local folder + while IFS= read -r -d '' folder + do + folder="${folder/*\//}" + doDebug "Checking app sub-folder ${folder}" + if [ "${folder}" != "Contents" ] && [ "${folder}" != "Resources" ] && [ "${folder}" != "bin" ] && [ "${folder:0:1}" != "_" ] + then + if [ -d "${target_path}/${contents}/${folder}/bin" ] + then + app_folder="${folder}" + doDebug "App folder with bin detected as ${app_folder}" + break + else + doDebug "Looking for executable in ${folder}" + local file + while IFS= read -r -d '' file + do + if [ -x "${file}" ] && [ "${file:(-4)}" != ".txt" ] + then + app_folder="${folder/*\//}" + doDebug "App folder with executable detected as ${app_folder}" + break + fi + done < <(find "${target_path}/${contents}/${folder}/" -maxdepth 1 -type f -print0) + fi + fi + done < <(find "${target_path}/${contents}" -maxdepth 1 -type d -print0) + fi + if [ "${app_folder}" != "-" ] && [ -d "${target_path}/${contents}/${app_folder}" ] + then + doEcho "Creating symlink as workaround for ${software} on MacOS" + local target_software_macos=${target_path%\/*}/macos + if [ ! -d "${target_software_macos}" ] + then + mkdir -p "${target_software_macos}" + fi + local target_software_software=${target_software_macos}/${dir} + doRunCommand "rm -rf '${target_software_software}'" + doRunCommand "mv '${target_path}' '${target_software_software}'" + doRunCommand "ln -sf 'macos/${dir}/${contents}/${app_folder}' '${target_path}'" + doRunCommand "cp '${target_software_software}/.devon.software.version' '${target_path}'" fi - local target_software_software=${target_software_macos}/${dir} - doRunCommand "rm -rf '${target_software_software}'" - doRunCommand "mv '${target_path}' '${target_software_software}'" - doRunCommand "ln -sf 'macos/${dir}/Contents/${app_folder}' '${target_path}'" - doRunCommand "cp '${target_software_software}/.devon.software.version' '${target_path}'" fi fi if [ "${target_path}" = "${DEVON_IDE_HOME}/software/${dir}" ]