diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f87508..065e838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v9? - We have moved the root check to the beginning of the script, and improved DEBUG handling with two different modes. `DEBUG=0` is still for production, and `1` is still for the DEBUG we previously knew downloading to the directory it is running from, but `2` will download to temporary folder, will detect updates, but will not install anything, but it will notify the user (almost as running the script without root before). +- `pkgName` can now be searched for. An example is logitechoptions. ## v8.0 diff --git a/fragments/functions.sh b/fragments/functions.sh index f5d5137..7a4664d 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -543,8 +543,19 @@ installPkgInDmg() { archiveName="${filearray[1]}" printlog "found pkg: $archiveName" else - # it is now safe to overwrite archiveName for installFromPKG - archiveName="$dmgmount/$pkgName" + if ls "$tmpDir/$pkgName" ; then + archiveName="$tmpDir/$pkgName" + else + # try searching for pkg + findfiles=$(find "$tmpDir" -iname "$pkgName") + filearray=( ${(f)findfiles} ) + if [[ ${#filearray} -eq 0 ]]; then + cleanupAndExit 20 "couldn't find pkg “$pkgName” in zip $archiveName" + fi + # it is now safe to overwrite archiveName for installFromPKG + archiveName="${filearray[1]}" + printlog "found pkg: $archiveName" + fi fi # installFromPkgs @@ -564,12 +575,23 @@ installPkgInZip() { if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg in zip $archiveName" fi - archiveName="${filearray[1]}" # it is now safe to overwrite archiveName for installFromPKG + archiveName="${filearray[1]}" printlog "found pkg: $archiveName" else - # it is now safe to overwrite archiveName for installFromPKG - archiveName="$tmpDir/$pkgName" + if ls "$tmpDir/$pkgName" ; then + archiveName="$tmpDir/$pkgName" + else + # try searching for pkg + findfiles=$(find "$tmpDir" -iname "$pkgName") + filearray=( ${(f)findfiles} ) + if [[ ${#filearray} -eq 0 ]]; then + cleanupAndExit 20 "couldn't find pkg “$pkgName” in zip $archiveName" + fi + # it is now safe to overwrite archiveName for installFromPKG + archiveName="${filearray[1]}" + printlog "found pkg: $archiveName" + fi fi # installFromPkgs diff --git a/fragments/header.sh b/fragments/header.sh index c41879d..02a6e89 100644 --- a/fragments/header.sh +++ b/fragments/header.sh @@ -190,7 +190,7 @@ REOPEN="yes" # blockingProcesses=( NONE ) # # - pkgName: (optional, only used for pkgInDmg, dmgInZip, and appInDmgInZip) -# File name of the pkg/dmg file _inside_ the dmg or zip +# File name or path to the pkg/dmg file _inside_ the dmg or zip. # When not given the pkgName is derived from the $name # # - updateTool: diff --git a/fragments/labels/logitechoptions.sh b/fragments/labels/logitechoptions.sh index bf7c088..98bdf6b 100644 --- a/fragments/labels/logitechoptions.sh +++ b/fragments/labels/logitechoptions.sh @@ -3,6 +3,7 @@ logitechoptions) type="pkgInZip" downloadURL=$(curl -fs https://support.logi.com/api/v2/help_center/en-us/articles.json | tr "," "\n" | grep -A 10 "macOS" | grep -oie "https.*/.*/options.*\.zip") appNewVersion=$(curl -fs https://support.logi.com/api/v2/help_center/en-us/articles.json | tr "," "\n" | grep -A 10 "macOS" | grep -B 5 -ie "https.*/.*/options.*\.zip" | grep "Software Version" | sed 's/\\u[0-9a-z][0-9a-z][0-9a-z][0-9a-z]//g' | grep -ioe "Software Version.*[0-9.]*" | tr "/" "\n" | grep -oe "[0-9.]*" | head -1) - pkgName="LogiMgr Installer [0-9.]*.app/Contents/Resources/LogiMgr.pkg" + #pkgName="LogiMgr Installer "*".app/Contents/Resources/LogiMgr.pkg" + pkgName=LogiMgr.pkg expectedTeamID="QED4VVPZWA" ;;