Skip to content

Commit d8c0752

Browse files
committed
1.0.8 top fix three issues
1 parent e63af54 commit d8c0752

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

patchomator.sh

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/zsh
22

3-
# Version: 2023.10.05 - 1.0.7
4-
# "there's an app for that"
3+
# Version: 2023.10.05 - 1.0.8
4+
# "reading is FUNdamental!"
55

66
# Big Thanks to:
77
# Adam Codega
@@ -14,13 +14,18 @@
1414
# Trevor Sysock
1515

1616

17+
# To Fix:
18+
19+
1720
# To Do:
1821
# [speed] Defer verification step until discovery is complete. Parallelize as much as possible.
1922
# [1.1] Add MDM deployed Non-interactive Mode --mdm "MDMName"
2023
# [1.1] Swift Dialog support
2124

2225

2326
# Changed:
27+
# On --write, add any found label to the config, even if the latest version is installed
28+
# Messaging for missing config file on --write
2429
# Respects --installomatoroptions setting for ignoring App Store apps (or not)
2530

2631
# Done:
@@ -211,8 +216,8 @@ checkInstallomator() {
211216
# check for existence of Installomator to enable installation of updates
212217
notice "Checking for Installomator.sh at ${YELLOW}$InstallomatorPATH ${RESET}"
213218

214-
InstalledVersion=$($InstallomatorPATH version)
215-
LatestVersion=$(versionFromGit Installomator Installomator )
219+
InstalledVersion="$($InstallomatorPATH version)"
220+
LatestVersion="$(versionFromGit Installomator Installomator)"
216221

217222
notice "Latest Version: $LatestVersion - Installed Version: $InstalledVersion"
218223

@@ -223,7 +228,6 @@ checkInstallomator() {
223228
OfferToInstall
224229
fi
225230

226-
$(versionFromGit Installomator Installomator )
227231
if ! [[ -f $InstallomatorPATH ]]
228232
then
229233
error "Installomator was not found at ${YELLOW}$InstallomatorPATH ${RESET}"
@@ -389,22 +393,22 @@ doInstallations() {
389393

390394
}
391395

392-
396+
# renamed to avoid conflicts with Installomator version of the same function name.
393397
PgetAppVersion() {
394-
# renamed to avoid conflicts with Installomator version of the same function name.
395-
# pkgs contains a version number, then we don't have to search for an app
396-
if [[ $packageID != "" ]]; then
398+
399+
# shortcut: pkgs contains a version number, if it's installed then we don't have to parse the plist.
400+
# still need to confirm it's installed, tho. Receipts can be unreliable.
401+
if [[ "$packageID" != "" ]]
402+
then
397403

398404
appversion="$(pkgutil --pkg-info-plist ${packageID} 2>/dev/null | grep -A 1 pkg-version | tail -1 | sed -E 's/.*>([0-9.]*)<.*/\1/g')"
399405

400-
if [[ $appversion != "" ]]; then
401-
notice "Label: $label_name"
402-
notice "--- found packageID $packageID installed"
403-
404-
InstalledLabelsArray+=( "$label_name" )
405-
406-
return
407-
fi
406+
# if [[ $appversion != "" ]]; then
407+
# notice "Label: $label_name"
408+
# notice "--- found packageID $packageID installed"
409+
# InstalledLabelsArray+=( "$label_name" )
410+
# fi
411+
408412
fi
409413

410414
if [ -z "$appName" ]; then
@@ -427,14 +431,16 @@ PgetAppVersion() {
427431

428432
appPathArray=( ${(0)applist} )
429433

430-
if [[ ${#appPathArray} -gt 0 ]]; then
434+
if [[ ${#appPathArray} -gt 0 ]]
435+
then
431436

432437
filteredAppPaths=( ${(M)appPathArray:#${targetDir}*} )
433438

434-
if [[ ${#filteredAppPaths} -eq 1 ]]; then
439+
if [[ ${#filteredAppPaths} -eq 1 ]]
440+
then
435441
installedAppPath=$filteredAppPaths[1]
436442

437-
appversion=$(defaults read $installedAppPath/Contents/Info.plist $versionKey) #Not dependant on Spotlight indexing
443+
[[ -n "$appversion" ]] || appversion=$(defaults read "$installedAppPath/Contents/Info.plist" "$versionKey")
438444

439445
infoOut "Found $appName version $appversion"
440446

@@ -470,7 +476,7 @@ verifyApp() {
470476

471477
if [[ $appVerifyStatus -ne 0 ]]
472478
then
473-
error "Error verifying $appPath"
479+
error "Error verifying $appPath: Returned $appVerifyStatus"
474480
return
475481
fi
476482

@@ -802,7 +808,6 @@ notice "Checking for configuration at ${YELLOW}$configfile ${RESET}"
802808

803809
if [[ ! -f $configfile ]] || [[ ${#writeconfig} -eq 1 ]]
804810
then
805-
notice "No config file at $configfile. Running discovery."
806811

807812
# Write Config mode
808813
# --write
@@ -823,7 +828,7 @@ then
823828
if [[ -w "$(dirname $configfile)" ]]
824829
#directory is writable
825830
then
826-
infoOut "No config file at $configfile. Creating one now."
831+
infoOut "No existing config file at $configfile. Creating one now."
827832
# creates a blank plist
828833
# touch "$configfile"
829834
plutil -create xml1 "$configfile"
@@ -834,7 +839,7 @@ then
834839
fi
835840
else
836841
# directory doesn't exist
837-
infoOut "No config file at $configfile. Creating one now."
842+
infoOut "No existing config file at $configfile. Creating one now."
838843
makepath "$configfile"
839844
# creates a blank plist
840845
plutil -create xml1 "$configfile" || fatal "Unable to create $configfile. Re-run patchomator with sudo to create the config file there, or use a writable path with\n\t ${YELLOW}--config \"path to config file\"${RESET}"
@@ -844,7 +849,7 @@ then
844849

845850
if [[ -w $configfile ]]
846851
then
847-
echo "\t${BOLD}Refreshing $configfile ${RESET}"
852+
infoOut "Refreshing $configfile"
848853
else
849854
fatal "$configfile is not writable. Re-run patchomator with sudo, or use a writable path with\n\t ${YELLOW}--config \"path to config file\"${RESET}"
850855
fi

0 commit comments

Comments
 (0)