diff --git a/scripts/pentoo-updater.sh b/scripts/pentoo-updater.sh index c67d6bc61..36747abce 100755 --- a/scripts/pentoo-updater.sh +++ b/scripts/pentoo-updater.sh @@ -292,30 +292,45 @@ main_checks() { #deep checks for python, including fix RESET_PYTHON=0 #first we set the python interpreters to match PYTHON_TARGETS (and ensure the versions we set are actually built) - PYTHON2=$(emerge --info | grep -oE 'PYTHON_TARGETS\="(python[23]_[0-9]\s*)+"' | head -n1 | cut -d\" -f2 | cut -d" " -f 1 |sed 's#_#.#') - PYTHON3=$(emerge --info | grep -oE 'PYTHON_TARGETS\="(python[23]_[0-9]\s*)+"' | head -n1 | cut -d\" -f2 | cut -d" " -f 2 |sed 's#_#.#') - if [ -z "${PYTHON2}" ] || [ -z "${PYTHON3}" ]; then + PYTHON2=$(emerge --info | grep -oE '^PYTHON_TARGETS\="(python[23]_[0-9]\s*)+"' | grep 'python2' | cut -d\" -f2 | cut -d" " -f 1 |sed 's#_#.#') + #PYTHON_SINGLE_TARGET is the *main* python3 implementation + PYTHON3=$(emerge --info | grep -oE '^PYTHON_SINGLE_TARGET\="(python3*_[0-9]\s*)+"' | cut -d\" -f2 | sed 's#_#.#') + if [ -z "${PYTHON2}" ]; then + printf "Detected Python 2 is disabled\n" + printf "From PYTHON_TARGETS: $(emerge --info | grep '^PYTHON_TARGETS')\n" + printf "This is a good thing :-)\n" + fi + if [ -z "${PYTHON3}" ]; then printf "Failed to autodetect PYTHON_TARGETS\n" - printf "Detected Python 2: ${PYTHON2:-none}\n" printf "Detected Python 3: ${PYTHON3:-none}\n" - printf "From PYTHON_TARGETS: $(emerge --info | grep '^PYTHON TARGETS')\n" + printf "From PYTHON_TARGETS: $(emerge --info | grep '^PYTHON_TARGETS')\n" + printf "From PYTHON_SINGLE_TARGET: $(emerge --info | grep '^PYTHON_SINGLE_TARGET')\n" + printf "This is fatal, python3 support is required, it is $(date +'%Y')\n" exit 1 fi - if eselect python list --python2 | grep -q "${PYTHON2}"; then - eselect python set --python2 "${PYTHON2}" || safe_exit - else - printf "System wants ${PYTHON2} as default python2 version but it isn't installed yet.\n" - RESET_PYTHON=1 - fi + #set default implementation + eselect python set "${PYTHON3}" + #set python 3 implementation if eselect python list --python3 | grep -q "${PYTHON3}"; then eselect python set --python3 "${PYTHON3}" || safe_exit else printf "System wants ${PYTHON3} as default python3 version but it isn't installed yet.\n" RESET_PYTHON=1 fi - "${PYTHON2}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON2#python}" "${PYTHON3}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON3#python}" + #fix python2, if it's even requested + if [ -n "${PYTHON2}" ]; then + # set python 2 implementation if requested + if eselect python list --python2 | grep -q "${PYTHON2}"; then + eselect python set --python2 "${PYTHON2}" || safe_exit + "${PYTHON2}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON2#python}" + else + printf "System wants ${PYTHON2} as default python2 version but it isn't installed yet.\n" + RESET_PYTHON=1 + fi + fi + #always update portage as early as we can (after making sure python works) emerge --update --newuse --oneshot --changed-deps --newrepo portage || safe_exit @@ -403,10 +418,12 @@ main_upgrades() { set_java #might fail, run it a few times if [ ${RESET_PYTHON} = 1 ]; then - eselect python set --python2 "${PYTHON2}" || safe_exit eselect python set --python3 "${PYTHON3}" || safe_exit - "${PYTHON2}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON2#python}" "${PYTHON3}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON3#python}" + if [ -n "${PYTHON2}" ]; then + eselect python set --python2 "${PYTHON2}" || safe_exit + "${PYTHON2}" -c "from _multiprocessing import SemLock" || emerge -1 python:"${PYTHON2#python}" + fi fi #if we are in catalyst, update the extra binpkgs