Skip to content

Commit

Permalink
#1010: support for msi and pkg, change aws to local installation (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
CREITZ25 authored Jan 26, 2023
1 parent e410584 commit 7bd06ec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
22 changes: 1 addition & 21 deletions scripts/src/main/resources/scripts/command/aws
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,8 @@ function doSetup() {
TOOL_VERSION_COMMAND="-"
doInstall "aws" "${AWS_VERSION}" "${1}" "" "${AWS_HOME}"
ERR="${?}"
local version_to_install
version_to_install=$(cat "${AWS_HOME}"/.devon.software.version)
if doIsWindows
if ! doIsWindows && ! doIsMacOs
then
if [ "${ERR}" = 0 ]
then
mv "${AWS_HOME}"/Amazon/AWSCLIV2/* "${AWS_HOME}"
[ -d "${AWS_HOME}"//Amazon/ ] && rm -rf "${AWS_HOME}"/Amazon/
[ -f "${AWS_HOME}"/aws-"${version_to_install}"-windows.msi ] && rm -rf "${AWS_HOME}"/aws-"${version_to_install}"-windows.msi
fi
elif doIsMacOs
then
if [ "${ERR}" = 0 ]
then
xar -C "${AWS_HOME}" -xf "${AWS_HOME}"/aws-"${version_to_install}"-mac.pkg
tar -C "${AWS_HOME}" -xzvf "${AWS_HOME}"/aws-cli.pkg/Payload
rm -rf "${AWS_HOME}"/Distribution "${AWS_HOME}"/Resources "${AWS_HOME}"/aws-cli.pkg
[ ! -h "${AWS_HOME}/aws" ] && ln -s "${AWS_HOME}"/aws-cli/aws "${AWS_HOME}"/aws
[ ! -h "${AWS_HOME}/aws_completer" ] && ln -s "${AWS_HOME}"/aws-cli/aws_completer "${AWS_HOME}"/aws_completer
[ -f "${AWS_HOME}"/aws-"${version_to_install}"-mac.pkg ] && rm "${AWS_HOME}"/aws-"${version_to_install}"-mac.pkg
fi
else
if [ "${ERR}" = 0 ]
then
doRunCommand "${AWS_HOME}/install -i ${AWS_HOME} -b ${AWS_HOME}"
Expand Down
35 changes: 32 additions & 3 deletions scripts/src/main/resources/scripts/functions
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,24 @@ function doExtract() {
then
doRunCommand "mv \"${1}\" \"${target_dir}\""
extracted="no"
elif [ "${ext}" = ".pkg" ]
then
local macos_download_file
macos_download_file="${1}"
mkdir "${target_dir}/~tmp/"
xar -C "${target_dir}/~tmp/" -xf "${macos_download_file}"
tar -C "${target_dir}" -xzvf "${target_dir}"/~tmp/*/Payload
[ -d "${target_dir}/~tmp/" ] && rm -rf "${target_dir}/~tmp/"
elif [ "${ext}" = ".msi" ]
then
local windows_download_file
windows_download_file=$(cygpath -w "${1}")
local windows_target_dir
windows_target_dir=$(cygpath -w "${target_dir}")
local downloadfile
downloadfile="${target_dir}/$(basename "${1}")"
msiexec //a "${windows_download_file}" //qn "TARGETDIR=${windows_target_dir}"
[ -f "${downloadfile}" ] && rm -rf "${downloadfile}"
else
doFail "Unknown archive format: ${ext}. Can not extract ${1}"
fi
Expand Down Expand Up @@ -751,7 +762,7 @@ function doInstallWithPackageManager() {
# $1: filename (e.g. ${filename})
function doIsInstallerExtension() {
local myext="${1/*\./.}"
if [ "${myext}" = ".exe" ] || [ "${myext}" = ".pkg" ] || [ "${myext}" = ".bat" ] || [ "${myext}" = ".py" ]
if [ "${myext}" = ".exe" ] || [ "${myext}" = ".bat" ] || [ "${myext}" = ".py" ]
then
return
fi
Expand Down Expand Up @@ -817,13 +828,31 @@ function doReplaceExtractedSkipSingleFolder() {
local source_dir="${1}"
local target_dir="${2}"
local backup_dir="${3}"
local root_dir="${1}"
shift 3
local files
local anz_files
local dir="${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}"
files="$(find "${dir}" -maxdepth 1 -mindepth 1 -exec basename {} \;)"
anz_files="$(echo "${files}" | wc -w)"
while [ "${anz_files}" == "1" ]
do
if [ -d "${dir}/${files}" ] && [ "${files}" != "bin" ] && [ "${files%.app}" = "${files}" ]
then
dir="${dir}/${files}"
else
break
fi
files="$(find "${dir}" -maxdepth 1 -mindepth 1 -exec basename {} \;)"
anz_files="$(echo "${files}" | wc -w)"
done
source_dir="${dir}"
doDebug "Changing source directory from ${root_dir} to ${source_dir} due to single folder."
fi
doReplaceExtractedFile "${source_dir}" "${target_dir}" "${backup_dir}"
[ -d "${root_dir}" ] && rm -rf "${root_dir}"
}

# $1: path of the extracted name to install (move to target)
Expand Down

0 comments on commit 7bd06ec

Please sign in to comment.