From b666c5108fd417d4fd938be5bf5abc46b58253be Mon Sep 17 00:00:00 2001 From: "Rick Farina (Zero_Chaos)" Date: Fri, 24 Apr 2020 12:44:07 -0400 Subject: [PATCH] pentoo-updater: move stuff around and add kernel only mode --- scripts/pentoo-updater.sh | 340 ++++++++++++++++++++------------------ 1 file changed, 179 insertions(+), 161 deletions(-) diff --git a/scripts/pentoo-updater.sh b/scripts/pentoo-updater.sh index dc8d0dd83..cd79765be 100755 --- a/scripts/pentoo-updater.sh +++ b/scripts/pentoo-updater.sh @@ -24,8 +24,34 @@ WE_FAILED=0 . /etc/profile env-update -#colorize the updates even if colors end up in the logs -export EMERGE_DEFAULT_OPTS="$(portageq envvar EMERGE_DEFAULT_OPTS) --color=y" +setup_env() { + #colorize the updates even if colors end up in the logs + export EMERGE_DEFAULT_OPTS="$(portageq envvar EMERGE_DEFAULT_OPTS) --color=y" + + if [ -n "${clst_subarch}" ]; then + if [ "${clst_subarch}" = "amd64" ]; then + ARCH="amd64" + ARCHY="x86_64" + elif [ "${clst_subarch}" = "pentium-m" ]; then + ARCH="x86" + ARCHY="x86" + fi + else + arch=$(uname -m) + if [ "${arch}" = "i686" ]; then + ARCH="x86" + ARCHY="x86" + elif [ "${arch}" = "x86_64" ]; then + ARCH="amd64" + ARCHY="x86_64" + fi + fi + if [ -n "${ARCH}" ]; then + export ARCH ARCHY + else + printf "Failed to detect arch, some things will be broken\n" + fi +} set_java() { java_system=$(eselect java-vm show system | tail -n 1 | tr -d " ") @@ -55,16 +81,7 @@ check_profile () { desired="pentoo:$(readlink /etc/portage/make.profile | cut -d'/' -f 8-)" if ! eselect profile set "${desired}"; then #profile failed to set, try hard to set the right one - #first set arch - arch=$(uname -m) - if [ "${arch}" = "i686" ]; then - ARCH="x86" - elif [ "${arch}" = "x86_64" ]; then - ARCH="amd64" - else - failure=1 - fi - #then check if we are hard + #check if we are hard if gcc -v 2>&1 | grep -q Hardened; then hardening="hardened" else @@ -93,18 +110,6 @@ check_profile () { } update_kernel() { - arch=$(uname -m) - if [ "${arch}" = "i686" ]; then - ARCH="x86" - ARCHY="x86" - elif [ "${arch}" = "x86_64" ]; then - ARCH="amd64" - ARCHY="x86_64" - else - printf "Arch ${arch} isn't supported for automatic kernel updating, skipping...\n." - return 1 - fi - bestkern="$(qlist $(portageq best_version / pentoo-sources 2> /dev/null) | grep 'distro/Kconfig' | awk -F'/' '{print $4}' | cut -d'-' -f 2-)" if [ -z "${bestkern}" ]; then printf "Failed to find pentoo-sources installed, is this a Pentoo system?\n" @@ -263,156 +268,159 @@ do_sync() { fi } -#check profile, manage repo, ensure valid python selected -check_profile -if [ -n "${clst_target}" ]; then #we are in catalyst - mkdir -p /var/log/portage/emerge-info/ - emerge --info > /var/log/portage/emerge-info/emerge-info-$(date "+%Y%m%d").txt -else #we are on a user system - if [[ -z "$(eselect python show)" || ! -f "/usr/bin/$(eselect python show)" ]]; then - eselect python update - fi - eselect python cleanup - [ "${NO_SYNC}" = "true" ] || do_sync +main_checks() { + setup_env + #check profile, manage repo, ensure valid python selected check_profile - if [ -d /var/db/repos/pentoo ] && [ -d /var/lib/layman/pentoo ]; then - printf "Pentoo now manages it's overlay through portage instead of layman.\n" - if [ -x /usr/bin/layman ]; then - if /usr/bin/layman -l | grep -q pentoo; then - printf "Removing Pentoo overlay from layman...\n" - layman --delete pentoo + if [ -n "${clst_target}" ]; then #we are in catalyst + mkdir -p /var/log/portage/emerge-info/ + emerge --info > /var/log/portage/emerge-info/emerge-info-$(date "+%Y%m%d").txt + else #we are on a user system + if [[ -z "$(eselect python show)" || ! -f "/usr/bin/$(eselect python show)" ]]; then + eselect python update + fi + eselect python cleanup + [ "${NO_SYNC}" = "true" ] || do_sync + check_profile + if [ -d /var/db/repos/pentoo ] && [ -d /var/lib/layman/pentoo ]; then + printf "Pentoo now manages it's overlay through portage instead of layman.\n" + if [ -x /usr/bin/layman ]; then + if /usr/bin/layman -l | grep -q pentoo; then + printf "Removing Pentoo overlay from layman...\n" + layman --delete pentoo + check_profile + fi + else + printf "Cleaning up the mess left behind by layman...\n" + rm -rf /var/lib/layman/pentoo + #if layman isn't on the system, it's repos.conf entry should be gone as well + [ -f /etc/portage/repos.conf/layman.conf ] && mv -f /etc/portage/repos.conf/layman.conf /etc/portage/repos.conf/layman.uninstalled + grep -q '/var/lib/layman/make.conf' /etc/portage/make.conf && sed -i '/\/var\/lib\/layman\/make.conf/d' /etc/portage/make.conf check_profile fi - else - printf "Cleaning up the mess left behind by layman...\n" - rm -rf /var/lib/layman/pentoo - #if layman isn't on the system, it's repos.conf entry should be gone as well - [ -f /etc/portage/repos.conf/layman.conf ] && mv -f /etc/portage/repos.conf/layman.conf /etc/portage/repos.conf/layman.uninstalled - grep -q '/var/lib/layman/make.conf' /etc/portage/make.conf && sed -i '/\/var\/lib\/layman\/make.conf/d' /etc/portage/make.conf - check_profile fi fi -fi -#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 - 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" - 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 -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}" - -#always update portage as early as we can (after making sure python works) -emerge --update --newuse --oneshot --changed-deps --newrepo portage || safe_exit - -#upgrade glibc first if we are using binpkgs -portage_features="$(portageq envvar FEATURES)" -if [ "${portage_features}" != "${portage_features/getbinpkg//}" ]; then - #learned something new, if a package updates before glibc and uses the newer glibc, the chance of breakage is - #*much* higher than if glibc is updated first. so let's just update glibc first. - emerge --update --newuse --oneshot --changed-deps --newrepo glibc || safe_exit -fi - -#modified from news item "Python ABIFLAGS rebuild needed" -if [ -n "$(find /usr/lib*/python3* -name '*cpython-3[3-5].so')" ]; then - emerge -1v --usepkg=n --buildpkg=y $(find /usr/lib*/python3* -name '*cpython-3[3-5].so') -fi -if [ -n "$(find /usr/include/python3.[3-5] -type f 2> /dev/null)" ]; then - emerge -1v --usepkg=n --buildpkg=y /usr/include/python3.[3-5] -fi - -#modified from news item gcc-5-new-c++11-abi -#gcc_target="x86_64-pc-linux-gnu-5.4.0" -#if [ "$(gcc-config -c)" != "${gcc_target}" ]; then -# if gcc-config -l | grep -q "${gcc_target}"; then -# gcc-config "${gcc_target}" -# . /etc/profile -# revdep-rebuild --library 'libstdc++.so.6' -- --buildpkg=y --usepkg=n --exclude gcc -# fi -#fi - -#migrate what we can from ruby 2.4 -if [ -n "$(portageq match / '=sys-devel/binutils-2.32-r1')" ]; then - printf "Removing old/broken binutils...\n" - emerge -C "=${removeme2}" -fi -removeme3=$(portageq match / 'dev-tex/xcolor') -if [ -n "${removeme3}" ]; then - printf "Removing hardblocked xcolor...\n" - emerge -C "=${removeme3}" -fi -removeme4=$(portageq match / 'dev-libs/capstone-bindings') -if [ -n "${removeme4}" ]; then - printf "Removing collision inducing capstone-bindings...\n" - emerge -C "=${removeme4}" -fi -removeme5=$(portageq match / ' /dev/null)" ]; then + emerge -1v --usepkg=n --buildpkg=y /usr/include/python3.[3-5] + fi + + #modified from news item gcc-5-new-c++11-abi + #gcc_target="x86_64-pc-linux-gnu-5.4.0" + #if [ "$(gcc-config -c)" != "${gcc_target}" ]; then + # if gcc-config -l | grep -q "${gcc_target}"; then + # gcc-config "${gcc_target}" + # . /etc/profile + # revdep-rebuild --library 'libstdc++.so.6' -- --buildpkg=y --usepkg=n --exclude gcc + # fi + #fi + + #migrate what we can from ruby 2.4 + if [ -n "$(portageq match / '=sys-devel/binutils-2.32-r1')" ]; then + printf "Removing old/broken binutils...\n" + emerge -C "=${removeme2}" + fi + removeme3=$(portageq match / 'dev-tex/xcolor') + if [ -n "${removeme3}" ]; then + printf "Removing hardblocked xcolor...\n" + emerge -C "=${removeme3}" + fi + removeme4=$(portageq match / 'dev-libs/capstone-bindings') + if [ -n "${removeme4}" ]; then + printf "Removing collision inducing capstone-bindings...\n" + emerge -C "=${removeme4}" + fi + removeme5=$(portageq match / '> /etc/portage/profile/package.use + echo "pentoo/pentoo-desktop kde mate" >> /etc/portage/profile/package.use #add in pentoo-extra to build more binpkgs echo 'USE="pentoo-extra"' >> /etc/portage/profile/make.defaults emerge --buildpkg @changed-deps || safe_exit @@ -426,6 +434,16 @@ fi FEATURES="-getbinpkg" smart-live-rebuild 2>&1 || safe_exit revdep-rebuild -i -v -- --usepkg=n --buildpkg=y || safe_exit emerge --deep --update --newuse -kb --changed-deps --newrepo @world || emerge --deep --update --newuse -kb --newrepo @world || safe_exit +} + +#execution begins here +main_checks + +if [ -z "${KERNEL_ONLY}" ]; then + main_upgrades +else + emerge --update sys-kernel/pentoo-sources sys-kernel/genkernel sys-kernel/linux-firmware sys-firmware/intel-microcode --oneshot || safe_exit +fi #we need to do the clean BEFORE we drop the extra flags otherwise all the packages we just built are removed currkern="$(uname -r)"