archboot/usr/bin/archboot-quickinst.sh

99 lines
2.9 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
2023-08-11 17:19:18 +02:00
# SPDX-License-Identifier: GPL-3.0-or-later
# created by Tobias Powalowski <tpowa@archlinux.org>
2023-09-06 09:03:43 +02:00
. /usr/lib/archboot/common.sh
2022-04-05 21:44:16 +02:00
. /usr/lib/archboot/installer/common.sh
2023-02-07 22:22:19 +01:00
_DESTDIR="${1}"
2022-04-05 21:44:16 +02:00
2023-01-09 08:20:54 +01:00
_usage() {
2024-08-01 10:30:36 +02:00
echo -e "\e[1m\e[36mArchboot\e[m \e[1m- Quickinst Installer\e[m"
echo -e "\e[1m------------------------------\e[m"
2024-08-01 07:54:05 +02:00
echo "This script is for users, who would rather partition/mkfs/mount"
echo "their target media manually, than go through the routines in"
echo "the setup script."
2009-02-11 21:34:04 +01:00
echo
2023-01-08 08:48:05 +01:00
if ! [[ -e "${_LOCAL_DB}" ]]; then
2024-08-01 07:54:05 +02:00
echo -e "Configure repositories: \e[1m/etc/pacman.conf\e[m"
echo -e "Configure mirror: \e[1m/etc/pacman.d/mirrorlist\e[m"
fi
2024-08-01 07:54:05 +02:00
echo -e "Configure packages to install: \e[1m/etc/archboot/defaults\e[m"
2024-08-14 10:39:30 +02:00
echo -e "Mount all your filesystems: \e[1m<destdir>\e[m"
echo ""
echo -e "Usage: \e[1mquickinst <destdir>\e[m"
2009-02-11 21:34:04 +01:00
exit 0
2008-10-20 22:39:25 +02:00
}
2010-02-22 07:40:53 +01:00
# configures pacman and syncs db on destination system
# params: none
# returns: 1 on error
2023-01-09 08:20:54 +01:00
_prepare_pacman() {
# Set up the necessary directories for pacman use
2023-09-06 11:44:56 +02:00
if [[ ! -d "${_DESTDIR}${_CACHEDIR}" ]]; then
mkdir -p "${_DESTDIR}${_CACHEDIR}"
2022-04-05 21:33:44 +02:00
fi
2023-09-06 11:44:56 +02:00
if [[ ! -d "${_DESTDIR}${_PACMAN_LIB}" ]]; then
mkdir -p "${_DESTDIR}${_PACMAN_LIB}"
2022-04-05 21:33:44 +02:00
fi
2024-06-11 12:31:10 +02:00
_pacman_keyring
2023-01-09 08:31:45 +01:00
${_PACMAN} -Sy
2023-01-08 08:48:05 +01:00
_KEYRING="archlinux-keyring"
2023-10-10 08:23:44 +02:00
[[ "${_RUNNING_ARCH}" == "aarch64" ]] && _KEYRING="${_KEYRING} archlinuxarm-keyring"
2022-09-23 08:50:09 +02:00
#shellcheck disable=SC2086
2023-01-09 21:34:59 +01:00
pacman -Sy ${_PACMAN_CONF} --noconfirm --noprogressbar ${_KEYRING} || exit 1
}
# package_installation
2023-01-09 08:20:54 +01:00
_install_packages() {
2024-08-14 23:40:55 +02:00
# add packages from Archboot defaults
2024-06-26 21:52:49 +02:00
_PACKAGES="$(rg -o '^_PACKAGES="(.*)"' -r '$1' /etc/archboot/defaults)"
# fallback if _PACKAGES is empty
2023-01-08 08:48:05 +01:00
[[ -z "${_PACKAGES}" ]] && _PACKAGES="base linux linux-firmware"
2023-01-09 08:20:54 +01:00
_auto_packages
2022-01-26 11:40:22 +01:00
#shellcheck disable=SC2086
2023-01-09 08:31:45 +01:00
${_PACMAN} -S ${_PACKAGES}
}
2010-01-15 20:36:43 +01:00
2024-08-14 10:59:39 +02:00
_post_installation() {
echo -e "
\e[1mPackage installation complete.\e[m
Please install a \e[1mbootloader\e[m. Edit the appropriate config file for
your loader. Please use \e[1m${_VMLINUZ}\e[m as kernel image.
Chroot into your system to install it:
\e[1m# mount -o bind /dev ${_DESTDIR}/dev\e[m
\e[1m# mount -t proc none ${_DESTDIR}/proc\e[m
\e[1m# mount -t sysfs none ${_DESTDIR}/sys\e[m
\e[1m# chroot ${_DESTDIR} /bin/bash\e[m
Next step, initramfs setup:
Edit your \e[1m/etc/mkinitcpio.conf\e[m to fit your needs. After that run:
\e[1m# mkinitcpio -p ${_KERNELPKG}\e[m
Then \e[1mexit\e[m your chroot shell, edit \e[1m${_DESTDIR}/etc/fstab\e[m and \e[1mreboot\e[m!"
}
2021-09-27 10:04:52 +02:00
if [[ -z "${1}" ]]; then
2023-01-09 08:20:54 +01:00
_usage
2008-10-20 22:39:25 +02:00
fi
2023-01-08 08:48:05 +01:00
if [[ -e "${_LOCAL_DB}" ]]; then
2023-01-09 08:20:54 +01:00
_local_pacman_conf
else
2023-01-09 08:20:54 +01:00
_PACMAN_CONF=""
fi
2023-01-09 08:20:54 +01:00
if ! _prepare_pacman; then
2023-02-07 20:19:31 +01:00
echo -e "Pacman preparation \e[91mFAILED\e[m."
2022-04-05 21:26:44 +02:00
exit 1
2022-04-05 21:01:07 +02:00
fi
2023-01-09 08:20:54 +01:00
_chroot_mount
if ! _install_packages; then
2023-02-07 20:19:31 +01:00
echo -e "Package installation \e[91mFAILED\e[m."
2023-01-09 08:20:54 +01:00
_chroot_umount
2022-04-05 21:01:07 +02:00
exit 1
fi
2023-01-09 08:20:54 +01:00
_locale_gen
_chroot_umount
2024-08-14 10:59:39 +02:00
_post_installation
2008-10-20 22:39:25 +02:00
exit 0
2009-02-11 21:34:04 +01:00