From 6a55709f400a4d9bd489a0a187d14964f3246dc5 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Mon, 18 May 2020 10:44:42 +0200 Subject: [PATCH] installPkgInDmg now searches for the first pkg in the dmg --- Installomator.sh | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index 68a7653..d0b64bd 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -118,16 +118,25 @@ BLOCKING_PROCESS_ACTION=prompt_user downloadURLFromGit() { # $1 git user name, $2 git repo name gitusername=${1?:"no git user name"} gitreponame=${2?:"no git repo name"} - + + if [[ $type == "pkgInDmg" ]]; then + filetype="dmg" + elif [[ $type == "pkgInZip" ]]; then + filetype="zip" + else + filetype=$type + fi + if [ -n "$archiveName" ]; then downloadURL=$(curl --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" \ | awk -F '"' "/browser_download_url/ && /$archiveName/ { print \$4 }") else downloadURL=$(curl --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" \ - | awk -F '"' "/browser_download_url/ && /$type/ { print \$4 }") + | awk -F '"' "/browser_download_url/ && /$filetype/ { print \$4 }") fi if [ -z "$downloadURL" ]; then - cleanupAndExit 9 "could not retrieve download URL for $gitusername/$gitreponame" + echo "could not retrieve download URL for $gitusername/$gitreponame" + exit 9 else echo "$downloadURL" return 0 @@ -967,12 +976,21 @@ installPkgInDmg() { mountDMG # locate pkg in dmg if [[ -z $pkgName ]]; then - pkgName="$name.pkg" + # find a file starting with $name and ending with 'pkg' + findfiles=$(find -X "$dmgmount" -iname "${name}*.pkg" -maxdepth 1 ) + echo $findfiles + filearray=( ${(0)findfiles} ) + echo $filearray ${#filearray} + if [[ ${#filearray} -eq 0 ]]; then + cleanupAndExit 20 "couldn't find pkg in dmg $archiveName" + fi + archiveName="${filearray[1]}" + echo "found pkg: $archiveName" + else + # it is now safe to overwrite archiveName for installFromPKG + archiveName="$dmgmount/$pkgName" fi - # it is now safe to overwrite archiveName for installFromPKG - archiveName="$dmgmount/$pkgName" - # installFromPkgs installFromPKG }