Update BuildmacOSInstallApp.command

This commit is contained in:
CorpNewt 2024-02-07 14:51:13 -06:00 committed by GitHub
parent e5158a13d2
commit eadcf01e39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 43 additions and 12 deletions

View File

@ -13,6 +13,10 @@ target="${script%.*}.py"
# FORCE = Use py3 # FORCE = Use py3
use_py3="TRUE" use_py3="TRUE"
# We'll parse if the first argument passed is
# --install-python and if so, we'll just install
just_installing="FALSE"
tempdir="" tempdir=""
compare_to_version () { compare_to_version () {
@ -104,6 +108,7 @@ download_py () {
fi fi
echo echo
echo "Running python install package..." echo "Running python install package..."
echo
sudo installer -pkg "$tempdir/python.pkg" -target / sudo installer -pkg "$tempdir/python.pkg" -target /
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo echo
@ -111,23 +116,36 @@ download_py () {
echo echo
exit $? exit $?
fi fi
echo # Now we expand the package and look for a shell update script
pkgutil --expand "$tempdir/python.pkg" "$tempdir/python"
if [ -e "$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall" ]; then
# Run the script
echo
echo "Updating PATH..."
echo
"$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall"
fi
vers_folder="Python $(echo "$vers" | cut -d'.' -f1 -f2)" vers_folder="Python $(echo "$vers" | cut -d'.' -f1 -f2)"
if [ -f "/Applications/$vers_folder/Install Certificates.command" ]; then if [ -f "/Applications/$vers_folder/Install Certificates.command" ]; then
# Certs script exists - let's execute that to make sure our certificates are updated # Certs script exists - let's execute that to make sure our certificates are updated
echo
echo "Updating Certificates..." echo "Updating Certificates..."
echo echo
"/Applications/$vers_folder/Install Certificates.command" "/Applications/$vers_folder/Install Certificates.command"
echo
fi fi
echo
echo "Cleaning up..." echo "Cleaning up..."
cleanup cleanup
echo echo
# Now we check for py again if [ "$just_installing" == "TRUE" ]; then
echo "Rechecking py..." echo "Done."
downloaded="TRUE" else
clear # Now we check for py again
main echo "Rechecking py..."
downloaded="TRUE"
clear
main
fi
} }
cleanup () { cleanup () {
@ -145,8 +163,13 @@ print_error() {
echo echo
echo "Python is not installed or not found in your PATH var." echo "Python is not installed or not found in your PATH var."
echo echo
echo "Please go to https://www.python.org/downloads/macos/" if [ "$kernel" == "Darwin" ]; then
echo "to download and install the latest version." echo "Please go to https://www.python.org/downloads/macos/ to"
echo "download and install the latest version, then try again."
else
echo "Please install python through your package manager and"
echo "try again."
fi
echo echo
exit 1 exit 1
} }
@ -228,8 +251,8 @@ get_python_version() {
} }
prompt_and_download() { prompt_and_download() {
if [ "$downloaded" != "FALSE" ]; then if [ "$downloaded" != "FALSE" ] || [ "$kernel" != "Darwin" ]; then
# We already tried to download - just bail # We already tried to download, or we're not on macOS - just bail
print_error print_error
fi fi
clear clear
@ -289,6 +312,9 @@ main() {
"$python" "$dir/$target" "${args[@]}" "$python" "$dir/$target" "${args[@]}"
} }
# Keep track of whether or not we're on macOS to determine if
# we can download and install python for the user as needed.
kernel="$(uname -s)"
# Check to see if we need to force based on # Check to see if we need to force based on
# macOS version. 10.15 has a dummy python3 version # macOS version. 10.15 has a dummy python3 version
# that can trip up some py3 detection in other scripts. # that can trip up some py3 detection in other scripts.
@ -298,4 +324,9 @@ downloaded="FALSE"
# our OS version is 10.15 or greater. # our OS version is 10.15 or greater.
check_py3_stub="$(compare_to_version "3" "10.15")" check_py3_stub="$(compare_to_version "3" "10.15")"
trap cleanup EXIT trap cleanup EXIT
main if [ "$1" == "--install-python" ] && [ "$kernel" == "Darwin" ]; then
just_installing="TRUE"
download_py
else
main
fi