From 96d07b4340fa3f9e6b48f42a64eacf3444917f37 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Sat, 4 Jun 2022 08:13:03 +0200 Subject: [PATCH] add memory switch for --latest and --latest-install on latest and local image --- usr/lib/archboot/container.sh | 34 ++++++++++++++++++++++++------- usr/lib/archboot/login.sh | 38 +++++++++++++++++------------------ 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/usr/lib/archboot/container.sh b/usr/lib/archboot/container.sh index 72f824473..e32098d25 100644 --- a/usr/lib/archboot/container.sh +++ b/usr/lib/archboot/container.sh @@ -141,9 +141,19 @@ _install_archboot() { echo "Adding "${_GPG_KEY_ID}" to trusted keys" pacman-key --add "${_GPG_KEY}" >/dev/null 2>&1 pacman-key --lsign-key "${_GPG_KEY_ID}" >/dev/null 2>&1 - echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." #shellcheck disable=SC2086 - pacman --root "${1}" -Syw --dbpath "${1}"/blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config "${_PACMAN_CONF}" --ignore systemd-resolvconf --cachedir "${_CACHEDIR}" --noconfirm >/dev/null 2>&1 + if grep -qw archboot /etc/hostname; then + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 3860000 ]]; then + echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." + pacman --root "${1}" -Syw --dbpath "${1}"/blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config "${_PACMAN_CONF}" --ignore systemd-resolvconf --cachedir "${_CACHEDIR}" --noconfirm >/dev/null 2>&1 + else + echo "Downloading ${_ARCHBOOT} to ${1} ..." + pacman --root "${1}" -Syw --dbpath "${1}"/blankdb ${_ARCHBOOT} --config "${_PACMAN_CONF}" --ignore systemd-resolvconf --cachedir "${_CACHEDIR}" --noconfirm >/dev/null 2>&1 + fi + else + echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." + pacman --root "${1}" -Syw --dbpath "${1}"/blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config "${_PACMAN_CONF}" --ignore systemd-resolvconf --cachedir "${_CACHEDIR}" --noconfirm >/dev/null 2>&1 + fi echo "Installing ${_ARCHBOOT} to ${1} ..." #shellcheck disable=SC2086 pacman --root "${1}" -Sy ${_ARCHBOOT} --config "${_PACMAN_CONF}" --ignore systemd-resolvconf --noconfirm --cachedir "${_CACHEDIR}" >/dev/null 2>&1 @@ -163,6 +173,7 @@ _aarch64_install_base_packages() { } _aarch64_install_archboot() { + [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb if [[ -e "${1}/$(basename "${_PACMAN_CONF}")" ]]; then _PACMAN_CONF=$(basename "${_PACMAN_CONF}") fi @@ -172,11 +183,20 @@ _aarch64_install_archboot() { systemd-nspawn -q -D "${1}" pacman-key --add "${_GPG_KEY}" >/dev/null 2>&1 systemd-nspawn -q -D "${1}" pacman-key --lsign-key "${_GPG_KEY_ID}" >/dev/null 2>&1 rm "${1}"/"${_GPG_KEY}" - echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." - [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb - systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Syw --dbpath /blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 - echo "Installing ${_ARCHBOOT} to ${1} ..." - systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Sy ${_ARCHBOOT} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + if grep -qw archboot /etc/hostname; then + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 3860000 ]]; then + echo "Downloading ${_ARCHBOOT} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Syw --dbpath /blankdb ${_ARCHBOOT} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + else + echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Syw --dbpath /blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + fi + else + echo "Downloading ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Syw --dbpath /blankdb ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + fi + echo "Installing ${_ARCHBOOT} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Sy ${_ARCHBOOT} --config ${_PACMAN_CONF} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 } _copy_mirrorlist_and_pacman_conf() { diff --git a/usr/lib/archboot/login.sh b/usr/lib/archboot/login.sh index 53454fec5..9b0af1142 100644 --- a/usr/lib/archboot/login.sh +++ b/usr/lib/archboot/login.sh @@ -36,10 +36,19 @@ _run_update_installer() { sleep 10 echo -e "\033[1mStarting\033[0m assembling of archboot environment with package cache ..." echo "" - echo -e "\033[1mRunning now: \033[92mupdate-installer.sh -latest-install\033[0m" - update-installer.sh -latest-install | tee -a /dev/ttyS0 /dev/ttyAMA0 /dev/ttyUSB0 /dev/pts/0 2>/dev/null + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 3860000 ]]; then + echo -e "\033[1mRunning now: \033[92mupdate-installer.sh -latest-install\033[0m" + update-installer.sh -latest-install | tee -a /dev/ttyS0 /dev/ttyAMA0 /dev/ttyUSB0 /dev/pts/0 2>/dev/null + else + echo -e "\033[1mRunning now: \033[92mupdate-installer.sh -latest\033[0m" + update-installer.sh -latest | tee -a /dev/ttyS0 /dev/ttyAMA0 /dev/ttyUSB0 /dev/pts/0 2>/dev/null + fi elif [[ "${TTY}" == "ttyS0" || "${TTY}" == "ttyAMA0" || "${TTY}" == "ttyUSB0" || "${TTY}" == "pts/0" ]]; then - echo -e "Running \033[1m\033[92mupdate-installer.sh -latest-install\033[0m on \033[1mtty1\033[0m, please wait ...\033[0m" + if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 3860000 ]]; then + echo -e "Running \033[1m\033[92mupdate-installer.sh -latest-install\033[0m on \033[1mtty1\033[0m, please wait ...\033[0m" + else + echo -e "\033[1mRunning now: \033[92mupdate-installer.sh -latest\033[0m" + fi echo -e "\033[1mProgress is shown here ...\033[0m" fi } @@ -50,24 +59,13 @@ if [[ -e /usr/bin/setup ]]; then if ! [[ -e /tmp/.setup ]]; then setup fi -elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 3860000 ]]; then +elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 1970000 ]]; then _welcome - if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -lt 1970000 ]]; then - echo -e "\033[1m\033[91mMemory check failed:\033[0m" - echo -e "\033[91m- Not engough memory detected! \033[0m" - echo -e "\033[93m- Please add \033[1mmore\033[0m\033[93m than \033[1m2.0GB\033[0m\033[93m RAM.\033[0m" - echo -e "\033[91mAborting ...\033[0m" - _enter_shell - elif [[ -e /var/cache/pacman/pkg/archboot.db ]]; then - echo -e "\033[1m\033[91mMemory check failed:\033[0m" - echo -e "\033[91m- Not engough memory detected! \033[0m" - echo -e "\033[93m- Please add \033[1mmore\033[0m\033[93m than \033[1m3.9GB\033[0m\033[93m RAM\033[0m" - echo -e "\033[93m or switch to \033[1mOnline\033[0m\033[93m mode.\033[0m" - echo -e "\033[91mAborting ...\033[0m" - _enter_shell - else - _run_update_installer - fi + echo -e "\033[1m\033[91mMemory check failed:\033[0m" + echo -e "\033[91m- Not engough memory detected! \033[0m" + echo -e "\033[93m- Please add \033[1mmore\033[0m\033[93m than \033[1m2.0GB\033[0m\033[93m RAM.\033[0m" + echo -e "\033[91mAborting ...\033[0m" + _enter_shell else _welcome _run_update_installer