From f4e41b28f31e77495e829ea2746cb39c494b1331 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Mon, 20 Feb 2023 09:59:43 +0100 Subject: [PATCH] don't kexec on local image --- usr/lib/archboot/login.sh | 6 +-- .../update-installer/update-installer.sh | 39 ++++++++++++++++++- usr/share/archboot/doc/archboot.html | 4 +- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/usr/lib/archboot/login.sh b/usr/lib/archboot/login.sh index baa60db93..4f6d0c6ed 100644 --- a/usr/lib/archboot/login.sh +++ b/usr/lib/archboot/login.sh @@ -91,13 +91,13 @@ _run_update_installer() { echo -e "\e[1m\e[91m10 seconds\e[0;25m time to hit \e[1m\e[92mCTRL-C\e[m to \e[1m\e[91mstop\e[m the process \e[1m\e[1mnow...\e[m" sleep 10 echo "" - if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 3271000 ]]; then + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2571000 ]]; then _run_latest else _run_latest_install fi elif [[ "${TTY}" == "ttyS0" || "${TTY}" == "ttyAMA0" || "${TTY}" == "ttyUSB0" || "${TTY}" == "pts/0" ]]; then - if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 3271000 ]]; then + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2571000 ]]; then echo -e "Running \e[1m\e[92mupdate-installer -latest-install\e[m on \e[1mtty1\e[m, please wait...\e[m" else echo -e "\e[1mRunning now: \e[92mupdate-installer -latest\e[m" @@ -155,7 +155,7 @@ elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e echo -e "\e[91mAborting...\e[m" _enter_shell # local image, fail if less than 3.3GB RAM available -elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 3271000 &&\ +elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 2571000 &&\ -e "/var/cache/pacman/pkg/archboot.db" ]]; then _welcome echo -e "\e[1m\e[91mMemory check failed:\e[m" diff --git a/usr/lib/archboot/update-installer/update-installer.sh b/usr/lib/archboot/update-installer/update-installer.sh index 9412d4bef..28dd93f3e 100644 --- a/usr/lib/archboot/update-installer/update-installer.sh +++ b/usr/lib/archboot/update-installer/update-installer.sh @@ -11,7 +11,7 @@ _SOURCE="https://gitlab.archlinux.org/tpowa/archboot/-/raw/master" _BIN="/usr/bin" _ETC="/etc/archboot" _LIB="/usr/lib/archboot" -_RAM="/ramfs" +_RAM="/sysroot" _INITRD="initrd.img" _INST="/${_LIB}/installer" _HELP="/${_LIB}/installer/help" @@ -330,6 +330,41 @@ _new_environment() { _update_installer_check touch /.update-installer _kill_w_dir + # local switch, don't kexec on local image + if [[ -e /var/cache/pacman/pkg/archboot.db ]]; then + echo -e "\e[1mStep 01/07:\e[m Waiting for gpg pacman keyring import to finish..." + _gpg_check + echo -e "\e[1mStep 02/07:\e[m Removing not necessary files from /..." + _clean_archboot + _clean_kernel_cache + echo -e "\e[1mStep 03/07:\e[m Generating archboot container in ${_W_DIR}..." + echo " This will need some time..." + _create_container || exit 1 + _clean_kernel_cache + _ram_check + mkdir ${_RAM} + mount -t ramfs none ${_RAM} + [[ ${_RUNNING_ARCH} == "x86_64" ]] && _kver_x86 + [[ ${_RUNNING_ARCH} == "aarch64" || ${_RUNNING_ARCH} == "riscv64" ]] && _kver_generic + # fallback if no detectable kernel is installed + [[ -z "${_HWKVER}" ]] && _HWKVER="$(uname -r)" + echo -e "\e[1mStep 05/07:\e[m Collecting rootfs files in ${_W_DIR}..." + echo " This will need some time..." + # write initramfs to "${_W_DIR}"/tmp + ${_NSPAWN} "${_W_DIR}" /bin/bash -c "umount tmp;mkinitcpio -k ${_HWKVER} -c ${_CONFIG} -d /tmp" >/dev/tty7 2>&1 || exit 1 + echo -e "\e[1mStep 06/07:\e[m Cleanup ${_W_DIR}..." + find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' -exec rm -rf {} \; + _clean_kernel_cache + _ram_check + echo -e "\e[1mStep 07/07:\e[m Switch root to ${_RAM}..." + mv ${_W_DIR}/tmp/* /ramfs/ + # cleanup mkinitcpio directories and files + rm -rf /sysroot/{hooks,install,kernel,new_root,sysroot} &>/dev/null + rm -f /sysroot/{VERSION,config,buildconfig,init} &>/dev/null + # systemd needs this for root_switch + touch /etc/initrd-release + systemctl start initrd-switch-root + fi echo -e "\e[1mStep 01/10:\e[m Waiting for gpg pacman keyring import to finish..." _gpg_check echo -e "\e[1mStep 02/10:\e[m Removing not necessary files from /..." @@ -354,7 +389,7 @@ _new_environment() { # write initramfs to "${_W_DIR}"/tmp ${_NSPAWN} "${_W_DIR}" /bin/bash -c "umount tmp;mkinitcpio -k ${_HWKVER} -c ${_CONFIG} -d /tmp" >/dev/tty7 2>&1 || exit 1 echo -e "\e[1mStep 06/10:\e[m Cleanup ${_W_DIR}..." - find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' ! -name "${_VMLINUZ}" -exec rm -rf {} \; + find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' -exec rm -rf {} \; _clean_kernel_cache _ram_check echo -e "\e[1mStep 07/10:\e[m Creating initramfs ${_RAM}/${_INITRD}..." diff --git a/usr/share/archboot/doc/archboot.html b/usr/share/archboot/doc/archboot.html index 079b2b307..ca404bda2 100644 --- a/usr/share/archboot/doc/archboot.html +++ b/usr/share/archboot/doc/archboot.html @@ -172,7 +172,7 @@

Archboot Homepage

-

Last update 18.02.2023 08:52 (c) Tobias Powalowski tpowa

+

Last update 20.02.2023 08:36 (c) Tobias Powalowski tpowa

Logo

Donate You like the project? I like coffee :-)