EmuDeck/install-darwin.sh

113 lines
3.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
clear
appleChip=$(uname -m)
function getLatestReleaseURLGH(){
local repository=$1
local fileType=$2
local fileNameContains=$3
local url
#local token=$(tokenGenerator)
if [ "$url" == "" ]; then
url="https://api.github.com/repos/${repository}/releases/latest"
fi
curl -fSs "$url" | \
jq -r '[ .assets[] | select(.name | contains("'"$fileNameContains"'") and endswith("'"$fileType"'")).browser_download_url ][0] // empty'
}
function alert() {
osascript <<EOT
tell app "System Events"
display dialog "$1" buttons {"OK"} default button 1 with icon caution with title "Flying Pigs - Mac Setup"
return -- Suppress result
end tell
EOT
}
safeDownload() {
local name="$1"
local url="$2"
local outFile="$3"
local showProgress="$4"
local headers="$5"
if [ "$showProgress" == "true" ]; then
echo "safeDownload()"
echo "- $name"
echo "- $url"
echo "- $outFile"
echo "- $showProgress"
echo "- $headers"
fi
request=$(curl -w $'\1'"%{response_code}" --fail -L "$url" -H "$headers" -o "$outFile.temp" 2>&1 && echo $'\2'0 || echo $'\2'$?)
returnCodes="${request#*$'\1'}"
httpCode="${returnCodes%$'\2'*}"
exitCode="${returnCodes#*$'\2'}"
if [ "$httpCode" = "200" ] && [ "$exitCode" == "0" ]; then
#echo "$name downloaded successfully";
mv -v "$outFile.temp" "$outFile" &>/dev/null
volumeName=$(yes | hdiutil attach "$outFile" | grep -o '/Volumes/.*$')
return 0
else
#echo "$name download failed"
rm -f "$outFile.temp"
return 1
fi
}
if ! command -v brew &> /dev/null; then
hasBrew=false
else
hasBrew=true
fi
function prompt() {
osascript <<EOT
tell app "System Events"
text returned of (display dialog "$1" default answer "$2" buttons {"OK"} default button 1 with title "EmuDeck - Mac Dependencies")
end tell
EOT
}
if [ $hasBrew == "false" ]; then
Handle special chars when echoing password for sudo req funcs? (#901) * adds updating the roms path in usersettings to the migration * Fix migration with saves * Hotfix dolphin config Remove WirelessMac * SRM: update saturn parser to include saturnjp * freeze PCSX2 # Conflicts: # functions/EmuScripts/emuDeckPCSX2QT.sh * Update emuDeckPCSX2QT.sh * Add GitHub Issue Templates * Create pull_request_template.md * Update README.md * Update README.md * helpers: Fix FlatPak installed check (#875) The previous way of checking whether a package was installed or not was incorrect in its assumption, that a package ID will only occur once in the flatpak installed list. I noticed this while trying to install PPSSPP, as FlatPak installs a `org.ppsspp.PPSSPP` and `org.ppsspp.PPSSPP.Locale` package. The package was installed correctly, but EmuDeck would register it as non-installed. Signed-off-by: Sophie 'Tyalie' Friedrich <dev@flowerpot.me> * SDL Driver * hotfix Vita3k releaseURL hotfix Vita3k releaseURL * Update Vita3K's default config path (#890) * better linux support * Chimera * chimera * chimera * chimeraaa * chimeraPath * chimeraos FIX * chimera fixes * fixed readme # Conflicts: # README.md # Conflicts: # README.md * Handle special chars when echoing password for sudo req funcs * store zenity/cli prompt passwd as str --------- Signed-off-by: Sophie 'Tyalie' Friedrich <dev@flowerpot.me> Co-authored-by: Livedeht <godsbane@gmail.com> Co-authored-by: Rodrigo <rodrigosedano@me.com> Co-authored-by: 108900299+rawdatafeel@users.noreply.github.com <108900299+rawdatafeel@users.noreply.github.com> Co-authored-by: Sophie Tyalie <dev@flowerpot.me> Co-authored-by: Pedro Montes Alcalde <pedro.montes.alcalde@gmail.com>
2023-12-29 10:58:03 -05:00
read -r pass <<< "$(prompt 'EmuDeck needs to install Brew, and for that you need to input your password:' '')"
echo $pass | sudo -v -S && {
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSLk https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
if [ $appleChip == "arm64" ];then
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
else
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
echo "export PATH=/usr/local/bin:$PATH" >> ~/.zshrc && source ~/.zshrc
fi
fi
#Brew dependencies
alert "Let's install EmuDeck dependencies... This could take some time. Please press OK"
brew install zenity gnu-sed rsync xmlstarlet jq steam
if ! command -v xcode-select &>/dev/null; then
xcode-select --install
wait
fi
alert "All prerequisite packages have been installed. EmuDeck's DMG will be installed now!. Please press OK"
if [ $appleChip == "arm64" ];then
EmuDeckURL="$(getLatestReleaseURLGH "EmuDeck/emudeck-electron-early" "arm64.dmg")"
else
EmuDeckURL="$(getLatestReleaseURLGH "EmuDeck/emudeck-electron-early" ".dmg")"
fi
safeDownload "EmuDeck" "$EmuDeckURL" "$HOME/Downloads/EmuDeck.dmg" && open "$HOME/Downloads/EmuDeck.dmg"
exit