diff --git a/.config/yadm/bootstrap.d/python3.sh b/.config/yadm/bootstrap.d/python3.sh index 30026e9..a2b87a6 100755 --- a/.config/yadm/bootstrap.d/python3.sh +++ b/.config/yadm/bootstrap.d/python3.sh @@ -1,15 +1,85 @@ if ! command -v python3 &> /dev/null; then echo 'Installing python3' - sudo apt update - sudo apt install python3 -y + + source $HOME/.zshenv + + if [[ "$OSNAME" == "Linux" ]]; then + # Linux + if [[ "$DISTRO_TYPE" == "debian" ]]; then + # Debian-based + sudo apt update + sudo apt install python3 -y + elif [[ "$DISTRO_TYPE" == "rpm" ]]; then + # RPM-based + echo 'ERROR: Currently unsupported' + echo 'Exiting...' + exit 1 + elif [[ "$DISTRO_TYPE" == "arch" ]]; then + # Arch-based + echo 'ERROR: Currently unsupported' + echo 'Exiting...' + exit 1 + else + # Unknown distro + echo 'ERROR: Unknown distro' + echo 'Exiting...' + exit 1 + fi + elif [[ "$OSNAME" == "macOS" ]]; then + # macOS + brew install python3 + else + # Unknown + echo 'ERROR: Unknown OS' + echo 'Exiting...' + exit 1 + fi fi echo 'python3 is installed' + if ! command -v pip3 &> /dev/null; then echo 'Installing pip3' - sudo apt update - sudo apt install python3-pip -y + + source $HOME/.zshenv + + if [[ "$OSNAME" == "Linux" ]]; then + # Linux + if [[ "$DISTRO_TYPE" == "debian" ]]; then + # Debian-based + sudo apt update + sudo apt install python3-pip -y + elif [[ "$DISTRO_TYPE" == "rpm" ]]; then + # RPM-based + echo 'ERROR: Currently unsupported' + echo 'Exiting...' + exit 1 + elif [[ "$DISTRO_TYPE" == "arch" ]]; then + # Arch-based + echo 'ERROR: Currently unsupported' + echo 'Exiting...' + exit 1 + else + # Unknown distro + echo 'ERROR: Unknown distro' + echo 'Exiting...' + exit 1 + fi + elif [[ "$OSNAME" == "macOS" ]]; then + # macOS + echo 'ERROR: pip3 is not installed' + echo 'pip3 should have been installed by Homebrew together with python3.' + echo + echo 'Please re-run this script or manually re-install python3 with Homebrew.' + echo 'Exiting...' + exit 1 + else + # Unknown + echo 'ERROR: Unknown OS' + echo 'Exiting...' + exit 1 + fi fi echo 'pip3 is installed'