Skip to content

Commit

Permalink
devonfw#940: generalize macos workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Oct 17, 2022
1 parent 4ecbbb9 commit 9b4109c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
9 changes: 0 additions & 9 deletions scripts/src/main/resources/scripts/command/eclipse
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@ function doSetup() {
doInstall "eclipse" "${ECLIPSE_VERSION}" "${silent}" "${ECLIPSE_EDITION_TYPE:-java}"
if [ "${?}" = 0 ]
then
if doIsMacOs
then
if [ ! -x "${ECLIPSE_HOME}/eclipse" ]
then
echo "Doing workarounds for MacOS quirks..."
echo -e "#!/usr/bin/env bash\nECLIPSE_HOME=\"\$(dirname \"\${0}\")\"\n\"\${ECLIPSE_HOME}/Eclipse.app/Contents/MacOS/eclipse\" \$@" > "${ECLIPSE_HOME}/eclipse"
chmod a+x "${ECLIPSE_HOME}/eclipse"
fi
fi
doAddPlugins
fi
}
Expand Down
21 changes: 2 additions & 19 deletions scripts/src/main/resources/scripts/command/intellij
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ fi

if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi
IDEA_HOME="${DEVON_IDE_HOME}/software/intellij"
if [ "${OSTYPE:0:6}" = "darwin" ]
then
TOOL_VERSION_COMMAND="head -n 6 '${IDEA_HOME}/IntelliJ.app/Contents/Resources/product-info.json'"
else
TOOL_VERSION_COMMAND="head -n 6 '${IDEA_HOME}/product-info.json'"
fi
TOOL_VERSION_COMMAND="head -n 6 '${IDEA_HOME}/product-info.json'"
# shellcheck source=scripts/functions
source "$(dirname "${0}")"/../functions
cd "${DEVON_IDE_HOME}" || exit 255
Expand All @@ -32,19 +27,7 @@ function doSetup() {
doInstall "intellij" "${INTELLIJ_VERSION}" "${1}" "${edition}"
if [ "${?}" = 0 ]
then
if doIsMacOs
then
echo "Doing workarounds for MacOS quirks..."
if [ "${edition}" = "U" ]
then
mv "${DEVON_IDE_HOME}/software/intellij/IntelliJ IDEA.app" "${DEVON_IDE_HOME}/software/intellij/IntelliJ.app"
else
mv "${DEVON_IDE_HOME}/software/intellij/IntelliJ IDEA CE.app" "${DEVON_IDE_HOME}/software/intellij/IntelliJ.app"
fi
mkdir -p "${IDEA_HOME}/bin"
echo -e "#!/usr/bin/env bash\n'${DEVON_IDE_HOME}/software/intellij/IntelliJ.app/Contents/MacOS/idea' \$@" > "${IDEA_HOME}/bin/idea"
chmod a+x "${IDEA_HOME}/bin/idea"
elif [ -f "${IDEA_HOME}/bin/idea.sh" ]
if [ -f "${IDEA_HOME}/bin/idea.sh" ]
then
ln -s "${IDEA_HOME}/bin/idea.sh" "${IDEA_HOME}/bin/idea"
fi
Expand Down
25 changes: 18 additions & 7 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ function doReplaceExtractedSkipSingleFolder() {
local target_dir="${2}"
local backup_dir="${3}"
shift 3
if [ "${#*}" = 1 ] && [ -d "${1}" ] && [[ ! "${1}" =~ .*\.app ]]
if [ "${#*}" = 1 ] && [ -d "${1}" ]
then
doDebug "Changing source directory from ${source_dir} to ${1} due to single folder."
source_dir="${1}"
Expand Down Expand Up @@ -1315,26 +1315,37 @@ function doInstall() {
# macos workaround
if [ ! -d "${target_path}/bin" ] && doIsMacOs && [ -d "${target_path}/Contents/" ]
then
doDebug "Found MacOS app in ${target_path}"
local app_folder=""
local folder
while IFS= read -r -d '' folder
do
if [[ "${folder}" =~ ${target_path}/Contents/(|_*|Resources) ]]
folder="${folder/*\//}"
doDebug "Checking app sub-folder ${folder}"
if [ "${folder}" != "Contents" ] && [ "${folder}" != "Resources" ] && [ "${folder:0:1}" != "_" ]
then
if [ -d "${folder}/bin" ]
doDebug "Found candidate sub-folder ${folder}"
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
app_folder="${folder/*\//}"
break
done < <(find "${folder}/" -maxdepth 1 -type f -executable -print0)
if [ -x "${file}" ]
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)
done < <(find "${target_path}/Contents" -maxdepth 1 -type d -print0)
doDebug "App folder detected as ${app_folder}"

if [ -n "${app_folder}" ] && [ -d "${target_path}/Contents/${app_folder}" ]
then
Expand Down

0 comments on commit 9b4109c

Please sign in to comment.