don't kexec on local image

This commit is contained in:
Tobias Powalowski 2023-02-20 09:59:43 +01:00
parent 2c6393082d
commit f4e41b28f3
3 changed files with 42 additions and 7 deletions

View file

@ -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"

View file

@ -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}..."

View file

@ -172,7 +172,7 @@
</head>
<body>
<h1>Archboot Homepage</h1>
<p>Last update 18.02.2023 08:52 (c) Tobias Powalowski </span><a href="https://archlinux.org/people/developers/#tpowa"><strong>tpowa</strong></a><span dir=""></p>
<p>Last update 20.02.2023 08:36 (c) Tobias Powalowski </span><a href="https://archlinux.org/people/developers/#tpowa"><strong>tpowa</strong></a><span dir=""></p>
<p><span dir=""><img src="https://pkgbuild.com/~tpowa/archboot/web/logo.png" alt="Logo"></span></p>
<p><span dir=""><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=Z7GXKW4MKHK7C"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate" /></a> You like the project? I like coffee :-)</span></p>
<nav id="TOC" role="doc-toc">
@ -348,7 +348,7 @@
</tr>
<tr class="odd">
<td><strong><em>date</em>-local</strong></td>
<td>2700MB</td>
<td>3300MB</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>