Merge pull request #359 from Installomator/Theile-labels-9.0

Theile labels 9.0
This commit is contained in:
Søren Theilgaard
2022-01-09 21:33:08 +01:00
committed by GitHub
20 changed files with 171 additions and 67 deletions

View File

@@ -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` in a label can now be searched for. An example is logitechoptions, where only the name of the pkg is given, and not the exact file path to it.
- `LSMinimumSystemVersion` will now be honered, if the `Info.plist` in the app is specifying this. That means that an app that has this parameter in that file and it shows that the app requires a newer version of the OS than is currently installed, then we will not install it.
- New variable `RETURN_LABEL_NAME`. If given the value `1`, like `RETURN_LABEL_NAME=1` then Installomator only returns the name of the label. It makes for a better user friendly message for displaying in DEPNotify if that is integrated.
- Changed logic if `IGNORE_APP_STORE_APPS=yes`. Before this version a label like `microsoftonedrive` that was installed from App Store, and that we want to replace with the “ordinary” version, Installomator would still use `updateTool`, even though `IGNORE_APP_STORE_APPS=yes`. So we would have to have `INSTALL=force` in order to have the app replaced, as `updateTool` would be used. But now if `IGNORE_APP_STORE_APPS=yes` then `updateTool` will be not set, and the App Store app will be replaced. BUT if the installed software was not from App Store, then `updateTool` will not be used, and it would be a kind of a forced install (in the example of `microsoftonedrive`), except if the version is the same (where installation is skipped).

View File

@@ -1,5 +1,5 @@
mightymike)
name="Nanosaur"
name="Mighty Mike"
type="dmg"
downloadURL=$(downloadURLFromGit jorio MightyMike)
appNewVersion=$(versionFromGit jorio MightyMike)

View File

@@ -0,0 +1,7 @@
mochakeyboard)
name="Mocha Keyboard"
type="appInDmgInZip"
downloadURL="https://mochasoft.dk/mochakeyboard.dmg.zip"
appNewVersion=""
expectedTeamID="RR9F5EPNVW"
;;

View File

@@ -0,0 +1,7 @@
mochatelnet)
name="Telnet"
type="appInDmgInZip"
downloadURL="https://mochasoft.dk/telnet.dmg.zip"
appNewVersion=""
expectedTeamID="RR9F5EPNVW"
;;

View File

@@ -0,0 +1,7 @@
mochatn3270)
name="TN3270"
type="appInDmgInZip"
downloadURL="https://mochasoft.dk/tn3270.dmg.zip"
appNewVersion=""
expectedTeamID="RR9F5EPNVW"
;;

View File

@@ -0,0 +1,7 @@
mochatn3812)
name="TN3812"
type="appInDmgInZip"
downloadURL="https://mochasoft.dk/tn3812.dmg.zip"
appNewVersion=""
expectedTeamID="Frydendal"
;;

View File

@@ -0,0 +1,7 @@
mochatn5250)
name="TN5250"
type="appInDmgInZip"
downloadURL="https://mochasoft.dk/tn5250.dmg.zip"
appNewVersion=""
expectedTeamID="RR9F5EPNVW"
;;

View File

@@ -563,8 +563,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
@@ -584,12 +595,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

View File

@@ -205,7 +205,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:

View File

@@ -0,0 +1,7 @@
applesfarabic)
name="San Francisco Arabic"
type="pkgInDmg"
downloadURL="https://devimages-cdn.apple.com/design/resources/download/SF-Arabic.dmg"
packageID="com.apple.pkg.SFArabicFonts"
expectedTeamID="Software Update"
;;

View File

@@ -2,7 +2,7 @@ applesfsymbols|\
sfsymbols)
name="SF Symbols"
type="pkgInDmg"
downloadURL=$( curl -fs "https://developer.apple.com/sf-symbols/" | grep -oe "https.*\.dmg" | head -1 )
appNewVersion=$( echo "$downloadURL" | head -1 | sed -E 's/.*SF-Symbols-([0-9.]*)\..*/\1/g')
downloadURL=$( curl -fs "https://developer.apple.com/sf-symbols/" | grep -oe "https.*Symbols.*\.dmg" | head -1 )
appNewVersion=$( echo "$downloadURL" | sed -E 's/.*SF-Symbols-([0-9.]*)\..*/\1/g')
expectedTeamID="Software Update"
;;

View File

@@ -1,15 +1,18 @@
brave)
# credit: @securitygeneration
name="Brave Browser"
type="dmg"
if [[ $(arch) != "i386" ]]; then
printlog "Architecture: arm64 (not i386)"
downloadURL=$(curl -fsIL https://laptop-updates.brave.com/latest/osxarm64/release | grep -i "^location" | awk '{print $2}' | tr -d '\r\n')
downloadURL=$(curl -fsIL https://laptop-updates.brave.com/latest/osxarm64/release | grep -i "^location" | awk '{print $2}')
appNewVersion="$(curl -fsL "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable-arm64/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@sparkle:version' 2>/dev/null | cut -d '"' -f 2)"
#appNewVersion="96.$(curl -fsL "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable-arm64/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@sparkle:shortVersionString' 2>/dev/null | cut -d '"' -f 2 | cut -d "." -f1-3)"
else
printlog "Architecture: i386"
downloadURL=$(curl -fsIL https://laptop-updates.brave.com/latest/osx/release | grep -i "^location" | awk '{print $2}' | tr -d '\r\n')
downloadURL=$(curl -fsIL https://laptop-updates.brave.com/latest/osx/release | grep -i "^location" | awk '{print $2}')
appNewVersion="$(curl -fsL "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@sparkle:version' 2>/dev/null | cut -d '"' -f 2)"
#appNewVersion="96.$(curl -fsL "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@sparkle:shortVersionString' 2>/dev/null | cut -d '"' -f 2 | cut -d "." -f1-3)"
fi
# downloadURL=$(curl --location --fail --silent "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@url' 2>/dev/null | cut -d '"' -f 2)
appNewVersion=$(curl --location --fail --silent "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@sparkle:shortVersionString' 2>/dev/null | cut -d '"' -f 2)
versionKey="CFBundleVersion"
# downloadURL=$(curl -fsL "https://updates.bravesoftware.com/sparkle/Brave-Browser/stable/appcast.xml" | xpath '//rss/channel/item[last()]/enclosure/@url' 2>/dev/null | cut -d '"' -f 2)
expectedTeamID="KL8N8XSYF4"
;;

View File

@@ -1,7 +1,8 @@
depnotify)
name="DEPNotify"
type="zip"
downloadURL="https://files.nomad.menu/DEPNotify.zip"
type="pkg"
#packageID="menu.nomad.depnotify"
downloadURL="https://files.nomad.menu/DEPNotify.pkg"
#appNewVersion=$()
expectedTeamID="VRPY9KHGX6"
targetDir="/Applications/Utilities"
;;

View File

@@ -0,0 +1,7 @@
ibarcoder)
name="iBarcoder"
type="dmg"
downloadURL="https://cristallight.com/Downloads/mac/ibarcoder.dmg"
appNewVersion="$(curl -fs "https://cristallight.com/iBarcoder/" | grep -i version: | head -1 | awk '{print $2}')"
expectedTeamID="JAXVB9AH9M"
;;

View File

@@ -1,9 +1,9 @@
logitechoptions)
# credit: AP Orlebeke (@apizz)
name="Logitech Options"
type="pkgInZip"
downloadURL=$(curl -fs -L https://www.logitech.com/en-us/product/options | grep -m 1 -o "https.*zip" | sed 's/\"//' | awk '{print $1}')
#appNewVersion=$(curl -fs -L https://www.logitech.com/en-us/product/options | grep -m 1 -o "https.*zip" | sed 's/\"//' | awk '{print $1}' | sed -E 's/.*_([0-9\.]*)[-\.].*/\1/' )
pkgName="LogiMgr Installer ${appNewVersion}.app/Contents/Resources/LogiMgr.pkg"
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 "*".app/Contents/Resources/LogiMgr.pkg"
pkgName=LogiMgr.pkg
expectedTeamID="QED4VVPZWA"
;;

View File

@@ -5,4 +5,3 @@ ottomatic)
appNewVersion=$(versionFromGit jorio OttoMatic)
expectedTeamID="RVNL7XC27G"
;;

View File

@@ -0,0 +1,7 @@
sdnotary)
name="SD Notary"
type="zip"
downloadURL=$(curl -fs https://latenightsw.com/sd-notary-notarizing-made-easy/ | grep -io "https://.*/.*\.zip")
appNewVersion=$(echo "$downloadURL" | sed -E 's/.*\/[a-zA-Z]*([0-9.]*)-.*\.zip/\1/g')
expectedTeamID="Z7S6X96M3X"
;;

View File

@@ -1,8 +1,7 @@
signal)
# credit: Søren Theilgaard (@theilgaard)
name="Signal"
type="dmg"
downloadURL=https://updates.signal.org/desktop/$(curl -fs https://updates.signal.org/desktop/latest-mac.yml | awk '/url/ && /dmg/ {print $3}')
downloadURL=https://updates.signal.org/desktop/$(curl -fs https://updates.signal.org/desktop/latest-mac.yml | awk '/url/ && /dmg/ {print $3}' | grep -i universal)
appNewVersion=$(curl -fs https://updates.signal.org/desktop/latest-mac.yml | grep version | awk '{print $2}')
expectedTeamID="U68MSDN6DR"
;;

View File

@@ -82,6 +82,43 @@ pkgInvestigation() {
echo "$packageID"
echo "Above is the possible packageIDs that can be used, and the correct one is probably one of those with a version number. More investigation might be needed to figure out correct packageID if several are displayed."
}
dmgInvestigation() {
echo "DMG investigation."
# mount the dmg
echo "Mounting $archiveName"
if ! dmgmount=$(echo "Y"$'\n' | hdiutil attach "$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then
echo "Error mounting $archiveName"
exit 3
fi
echo "Mounted: $dmgmount"
# check if app og pkg exists on disk image
appPath=$(find "$dmgmount" -name "*.app" -maxdepth 1 -print )
pkgPath=$(find "$dmgmount" -name "*.pkg" -maxdepth 1 -print )
if [[ $appPath != "" ]]; then
echo "App found: $appPath"
if [[ $archiveExt = "dmgInZip" ]]; then
archiveExt="appInDmgInZip"
fi
appInvestigation
elif [[ $pkgPath != "" ]]; then
echo "PKG found: $pkgPath"
if [[ $archiveExt = "dmgInZip" ]]; then
archiveExt="pkgInDmgInZip not supported, yet!"
else
archiveExt="pkgInDmg"
fi
pkgInvestigation
else
echo "Nothing found on DMG."
exit 9
fi
hdiutil detach "$dmgmount"
}
appInvestigation() {
appName=${appPath##*/}
name=${appName%.*}
@@ -122,19 +159,22 @@ if ! downloadOut="$(curl -fL "$downloadURL" --remote-header-name --remote-name -
echo "result: $downloadOut"
echo "Trying all headers…" # that I know of
if ! downloadOut="$(curl -fL -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15" -H "accept-encoding: gzip, deflate, br" -H "Referrer Policy: strict-origin-when-cross-origin" -H "upgrade-insecure-requests: 1" -H "sec-fetch-dest: document" -H "sec-gpc: 1" -H "sec-fetch-user: ?1" -H "accept-language: en-US,en;q=0.9" -H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" -H "sec-fetch-mode: navigate" "$downloadURL" --remote-header-name --remote-name -w "%{filename_effective}\n%{url_effective}\n")"; then
# we are only here if the download failed
echo "error downloading $downloadURL using all headers."
echo "result: $downloadOut"
# Sometimes a server will give some results to the downloaded output
if [[ -n $downloadOut ]]; then
echo "Trying output of this…"
downloadURL="$(echo $downloadOut | tail -1)"
# Last chance for succes on this download
if ! downloadOut="$(curl -fL "$downloadURL" --remote-header-name --remote-name -w "%{filename_effective}\n%{url_effective}\n")"; then
echo "error downloading $downloadURL using previous output."
echo "result: $downloadOut"
echo "No more tries. Cannot continue."
exit 1
echo "Trying almost all headers…" # that I know of
if ! downloadOut="$(curl -fL -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15" -H "accept-encoding: gzip, deflate, br" -H "upgrade-insecure-requests: 1" -H "sec-fetch-dest: document" -H "sec-gpc: 1" -H "sec-fetch-user: ?1" -H "accept-language: en-US,en;q=0.9" -H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" -H "sec-fetch-mode: navigate" "$downloadURL" --remote-header-name --remote-name -w "%{filename_effective}\n%{url_effective}\n")"; then
# we are only here if the download failed
echo "error downloading $downloadURL using two different sets of headers."
echo "result: $downloadOut"
# Sometimes a server will give some results to the downloaded output
if [[ -n $downloadOut ]]; then
echo "Trying output of this…"
downloadURL="$(echo $downloadOut | tail -1)"
# Last chance for succes on this download
if ! downloadOut="$(curl -fL "$downloadURL" --remote-header-name --remote-name -w "%{filename_effective}\n%{url_effective}\n")"; then
echo "error downloading $downloadURL using previous output."
echo "result: $downloadOut"
echo "No more tries. Cannot continue."
exit 1
fi
fi
fi
fi
@@ -171,10 +211,6 @@ echo "name: $name"
archiveExt=${archiveName##*.}
type=$archiveExt
echo "archiveExt: $archiveExt"
identifier=${name:l} # making lower case
identifier=${identifier//\%[0-9a-fA-F][0-9a-fA-F]} # removing certain characters
identifier=${identifier//[,._*@$\(\)\-]} # removing more characters from label name
echo "identifier: $identifier"
# Now figuring out the filename extension and handling those situations
if [ "$archiveExt" = "pkg" ]; then
@@ -183,31 +219,7 @@ if [ "$archiveExt" = "pkg" ]; then
pkgInvestigation
elif [ "$archiveExt" = "dmg" ]; then
echo "Diskimage found"
# mount the dmg
echo "Mounting $archiveName"
if ! dmgmount=$(echo "Y"$'\n' | hdiutil attach "$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then
echo "Error mounting $archiveName"
exit 3
fi
echo "Mounted: $dmgmount"
# check if app og pkg exists on disk image
appPath=$(find "$dmgmount" -name "*.app" -maxdepth 1 -print )
pkgPath=$(find "$dmgmount" -name "*.pkg" -maxdepth 1 -print )
if [[ $appPath != "" ]]; then
echo "App found: $appPath"
appInvestigation
elif [[ $pkgPath != "" ]]; then
echo "PKG found: $pkgPath"
archiveExt="pkgInDmg"
pkgInvestigation
else
echo "Nothing found on DMG."
exit 9
fi
hdiutil detach "$dmgmount"
dmgInvestigation
elif [ "$archiveExt" = "zip" ] || [ "$archiveExt" = "tbz" ]; then
echo "Compressed file found"
# unzip the archive
@@ -216,6 +228,7 @@ elif [ "$archiveExt" = "zip" ] || [ "$archiveExt" = "tbz" ]; then
# check if app og pkg exists after expanding
appPath=$(find "$tmpDir" -name "*.app" -maxdepth 2 -print )
pkgPath=$(find "$tmpDir" -name "*.pkg" -maxdepth 2 -print )
archiveName=$(find "$tmpDir" -name "*.dmg" -maxdepth 2 -print )
if [[ $appPath != "" ]]; then
echo "App found: $appPath"
@@ -223,14 +236,24 @@ elif [ "$archiveExt" = "zip" ] || [ "$archiveExt" = "tbz" ]; then
elif [[ $pkgPath != "" ]]; then
echo "PKG found: $pkgPath"
archiveExt="pkgInZip"
echo "archiveExt: $archiveExt"
pkgInvestigation
elif [[ $archiveName != "" ]]; then
echo "Disk image found: $archiveName"
archiveExt="dmgInZip"
echo "archiveExt: $archiveExt"
dmgInvestigation
else
echo "Nothing found in compressed archive."
exit 9
fi
fi
identifier=${name:l} # making lower case
identifier=${identifier//\%[0-9a-fA-F][0-9a-fA-F]} # removing certain characters
identifier=${identifier//[,._*@$\(\)\-]} # removing more characters from label name
echo "identifier: $identifier"
# github-part to figure out if we can find author and repo, to use our github functions for the label
if echo "$downloadURL" | grep -i "github.com.*releases/download"; then
echo "\n**********\n\nFound GitHub path"