mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
Update buildLabel.sh
Different set of headers.
This commit is contained in:
@@ -82,6 +82,36 @@ 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"
|
||||
appInvestigation
|
||||
elif [[ $pkgPath != "" ]]; then
|
||||
echo "PKG found: $pkgPath"
|
||||
archiveExt="pkgInDmg"
|
||||
pkgInvestigation
|
||||
else
|
||||
echo "Nothing found on DMG."
|
||||
exit 9
|
||||
fi
|
||||
|
||||
hdiutil detach "$dmgmount"
|
||||
}
|
||||
|
||||
appInvestigation() {
|
||||
appName=${appPath##*/}
|
||||
name=${appName%.*}
|
||||
@@ -122,19 +152,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 +204,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 +212,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 +221,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 +229,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"
|
||||
|
||||
Reference in New Issue
Block a user