mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
merge common.sh
This commit is contained in:
parent
ffd15e8654
commit
62d2236333
9 changed files with 18 additions and 58 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
. /usr/lib/archboot/common.sh
|
||||
. /usr/lib/archboot/installer/common.sh
|
||||
_DESTDIR="${1}"
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
# source base and common first, contains basic parameters
|
||||
LANG=C
|
||||
. /usr/lib/archboot/common.sh
|
||||
. /usr/lib/archboot/installer/common.sh
|
||||
. /usr/lib/archboot/installer/base.sh
|
||||
# source all other functions
|
||||
|
|
|
@ -26,6 +26,7 @@ fi
|
|||
_PACMAN_MIRROR="/etc/pacman.d/mirrorlist"
|
||||
_PACMAN_CONF="/etc/pacman.conf"
|
||||
_CACHEDIR="/var/cache/pacman/pkg"
|
||||
_LOCAL_DB="${_CACHEDIR}/archboot.db"
|
||||
_FIX_PACKAGES="libelf libevent talloc gcc-libs glibc glib2 pcre2 nss terminus-font"
|
||||
_XORG_PACKAGE="xorg"
|
||||
_VNC_PACKAGE="tigervnc"
|
||||
|
|
|
@ -35,7 +35,7 @@ _clean_cache() {
|
|||
if grep -qw 'archboot' /etc/hostname; then
|
||||
echo "Cleaning archboot ${_CACHEDIR}..."
|
||||
for i in "${1}${_CACHEDIR}"/*; do
|
||||
[[ "${i}" == "${1}${_CACHEDIR}/archboot.db" ]] || rm -f "${_CACHEDIR}"/"$(basename "${i}")"
|
||||
[[ "${i}" == "${1}${_LOCAL_DB}" ]] || rm -f "${_CACHEDIR}"/"$(basename "${i}")"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
_ANSWER="/tmp/.setup"
|
||||
_LOG="/dev/tty11"
|
||||
_VC_NUM="$(basename ${_LOG} | sed -e 's#tty##g')"
|
||||
_VC="VC${_VC_NUM}"
|
||||
# install stages
|
||||
|
@ -15,7 +13,6 @@ _EDITOR=""
|
|||
_LSBLK="lsblk -rpno"
|
||||
_BLKID="blkid -c ${_NO_LOG}"
|
||||
_FINDMNT="findmnt -vno SOURCE"
|
||||
_DLPROG="curl -s"
|
||||
|
||||
_set_title() {
|
||||
if [[ "${_DESTDIR}" == "/" ]]; then
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
_LOCAL_DB="/var/cache/pacman/pkg/archboot.db"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_KERNELPKG="linux"
|
||||
_NO_LOG="/dev/null"
|
||||
# use the first VT not dedicated to a running console
|
||||
# don't use _DESTDIR=/mnt because it's intended to mount other things there!
|
||||
# check first if bootet in archboot
|
||||
# don't ask for source and network on booted system
|
||||
if grep -qw '^archboot' /etc/hostname; then
|
||||
_DESTDIR="/install"
|
||||
_NSPAWN="systemd-nspawn -q -D ${_DESTDIR}"
|
||||
|
@ -25,40 +19,6 @@ if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
|
|||
fi
|
||||
# abstract the common pacman args
|
||||
_PACMAN="pacman --root ${_DESTDIR} --cachedir=${_DESTDIR}/var/cache/pacman/pkg --noconfirm --noprogressbar"
|
||||
_MIRRORLIST="/etc/pacman.d/mirrorlist"
|
||||
|
||||
# $1: percentage
|
||||
# $2: message
|
||||
_progress() {
|
||||
cat <<EOF
|
||||
XXX
|
||||
${1}
|
||||
${2}
|
||||
XXX
|
||||
EOF
|
||||
}
|
||||
|
||||
# $1: start percentage
|
||||
# $2: end percentage
|
||||
# $3: message
|
||||
# $4: sleep time
|
||||
_progress_wait() {
|
||||
_COUNT=${1}
|
||||
while [[ -e "${_W_DIR}/.archboot" || -e /.archboot ]]; do
|
||||
if [[ "${_COUNT}" -lt "${2}" ]]; then
|
||||
_progress "${_COUNT}" "${3}"
|
||||
fi
|
||||
if [[ "${_COUNT}" -gt "${2}" ]]; then
|
||||
_progress "${2}" "${3}"
|
||||
fi
|
||||
# abort after 15 minutes
|
||||
if [[ "${_COUNT}" -gt 150 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
_COUNT="$((_COUNT+1))"
|
||||
sleep "${4}"
|
||||
done
|
||||
}
|
||||
|
||||
_linux_firmware() {
|
||||
_PACKAGES="${_PACKAGES//\ linux-firmware\ / }"
|
||||
|
|
|
@ -14,7 +14,7 @@ _welcome () {
|
|||
}
|
||||
|
||||
_local_mode () {
|
||||
if [[ -e "${_CACHEDIR}/archboot.db" ]]; then
|
||||
if [[ -e "${_LOCAL_DB}" ]]; then
|
||||
echo -e "You are running in \e[92m\e[1mOffline Mode\e[m, with \e[1mlocal package repository\e[m enabled.\e[m"
|
||||
fi
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ _run_update_installer() {
|
|||
_run_latest
|
||||
else
|
||||
# local image
|
||||
if [[ -e "${_CACHEDIR}/archboot.db" ]]; then
|
||||
if [[ -e "${_LOCAL_DB}" ]]; then
|
||||
_run_latest_install
|
||||
else
|
||||
# latest image
|
||||
|
@ -130,7 +130,7 @@ if [[ "${TTY}" = "tty1" ]] ; then
|
|||
systemctl start initrd-cleanup.service
|
||||
systemctl start initrd-switch-root.target
|
||||
else
|
||||
if ! [[ -e "${_CACHEDIR}/archboot.db" ]]; then
|
||||
if ! [[ -e "${_LOCAL_DB}" ]]; then
|
||||
systemctl start systemd-networkd
|
||||
systemctl start systemd-resolved
|
||||
fi
|
||||
|
@ -174,7 +174,7 @@ elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e
|
|||
_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 2571000 &&\
|
||||
-e "${_CACHEDIR}/archboot.db" ]]; then
|
||||
-e "${_LOCAL_DB}" ]]; then
|
||||
_welcome
|
||||
echo -e "\e[1m\e[91mMemory check failed:\e[m"
|
||||
echo -e "\e[91m- Not engough memory detected! \e[m"
|
||||
|
|
|
@ -21,15 +21,15 @@ _create_container() {
|
|||
"archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc -cp >"${_LOG}" 2>&1 || exit 1
|
||||
fi
|
||||
# create container with package cache
|
||||
if [[ -e /var/cache/pacman/pkg/archboot.db ]]; then
|
||||
if [[ -e "${_LOCAL_DB}" ]]; then
|
||||
# offline mode, for local image
|
||||
# add the db too on reboot
|
||||
install -D -m644 /var/cache/pacman/pkg/archboot.db "${_W_DIR}"/var/cache/pacman/pkg/archboot.db
|
||||
install -D -m644 "${_LOCAL_DB}" "${_W_DIR}""${_LOCAL_DB}"
|
||||
if [[ -n "${_L_INSTALL_COMPLETE}" ]]; then
|
||||
"archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc --install-source=file:///var/cache/pacman/pkg >"${_LOG}" 2>&1 || exit 1
|
||||
fi
|
||||
# needed for checks
|
||||
cp "${_W_DIR}"/var/cache/pacman/pkg/archboot.db /var/cache/pacman/pkg/archboot.db
|
||||
cp "${_W_DIR}""${_LOCAL_DB}" "${_LOCAL_DB}"
|
||||
else
|
||||
# online mode
|
||||
if [[ -n "${_L_INSTALL_COMPLETE}" ]]; then
|
||||
|
@ -69,7 +69,7 @@ _update_installer_check() {
|
|||
echo "If you are absolutly sure it's not running, you need to remove /.update"
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ -e /var/cache/pacman/pkg/archboot.db ]]; then
|
||||
if ! [[ -e "${_LOCAL_DB}" ]]; then
|
||||
_network_check
|
||||
fi
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ _new_environment() {
|
|||
_clean_kernel_cache
|
||||
_ram_check
|
||||
# local switch, don't kexec on local image
|
||||
if [[ -e /var/cache/pacman/pkg/archboot.db ]]; then
|
||||
if [[ -e "${_LOCAL_DB}" ]]; then
|
||||
_progress "86" "Moving rootfs to ${_RAM}..."
|
||||
mv "${_ROOTFS_DIR}"/* "${_RAM}/"
|
||||
# cleanup mkinitcpio directories and files
|
||||
|
|
|
@ -35,20 +35,20 @@ usage () {
|
|||
echo -e "\e[1mManage \e[36mArchboot\e[m\e[1m - Arch Linux Environment:\e[m"
|
||||
echo -e "\e[1m-----------------------------------------\e[m"
|
||||
echo -e " \e[1m-help\e[m This message."
|
||||
if [[ ! -e "/var/cache/pacman/pkg/archboot.db" || -e "/usr/bin/setup" ]]; then
|
||||
if [[ ! -e ""${_LOCAL_DB}"" || -e "/usr/bin/setup" ]]; then
|
||||
echo -e " \e[1m-update\e[m Update scripts: setup, quickinst, network, clock and helpers."
|
||||
fi
|
||||
# latest image
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2000000 && ! -e "/.full_system" && ! -e "/var/cache/pacman/pkg/archboot.db" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2000000 && ! -e "/.full_system" && ! -e ""${_LOCAL_DB}"" ]]; then
|
||||
echo -e " \e[1m-full-system\e[m Switch to full Arch Linux system."
|
||||
# local image
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2571000 && ! -e "/.full_system" && -e "/var/cache/pacman/pkg/archboot.db" && -e "/usr/bin/setup" ]]; then
|
||||
elif [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2571000 && ! -e "/.full_system" && -e ""${_LOCAL_DB}"" && -e "/usr/bin/setup" ]]; then
|
||||
echo -e " \e[1m-full-system\e[m Switch to full Arch Linux system."
|
||||
fi
|
||||
echo -e ""
|
||||
if [[ -e "/usr/bin/setup" ]]; then
|
||||
# works only on latest image
|
||||
if ! [[ -e "/var/cache/pacman/pkg/archboot.db" ]]; then
|
||||
if ! [[ -e ""${_LOCAL_DB}"" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 2400000 ]] ; then
|
||||
_graphic_options
|
||||
fi
|
||||
|
@ -61,7 +61,7 @@ usage () {
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
if ! [[ -e "/var/cache/pacman/pkg/archboot.db" ]] || [[ -e "/var/cache/pacman/pkg/archboot.db" && ! -e "/usr/bin/setup" ]]; then
|
||||
if ! [[ -e ""${_LOCAL_DB}"" ]] || [[ -e ""${_LOCAL_DB}"" && ! -e "/usr/bin/setup" ]]; then
|
||||
if [[ "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" -gt 1970000 ]]; then
|
||||
if ! [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then
|
||||
echo -e " \e[1m-latest\e[m Launch latest archboot environment (using kexec)."
|
||||
|
|
Loading…
Reference in a new issue