archboot/usr/bin/archboot-quickinst.sh

106 lines
3.3 KiB
Bash
Raw 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() {
2023-02-07 20:19:31 +01:00
echo -e "\e[1mWelcome to \e[36mARCHBOOT\e[m \e[1m- QUICKINST INSTALLER:\e[m"
echo -e "\e[1m-------------------------------------------\e[m"
2023-04-23 22:22:15 +02:00
echo -e "usage: \e[1mquickinst <destdir>\e[m"
echo ""
2009-02-11 21:34:04 +01:00
echo "This script is for users who would rather partition/mkfs/mount their target"
echo "media manually than go through the routines in the setup script."
echo
2023-01-08 08:48:05 +01:00
if ! [[ -e "${_LOCAL_DB}" ]]; then
2023-02-07 20:19:31 +01:00
echo -e "First configure \e[1m/etc/pacman.conf\e[m which repositories to use"
echo -e "and set a mirror in \e[1m/etc/pacman.d/mirrorlist\e[m"
fi
echo
2023-02-07 20:19:31 +01:00
echo -e "Make sure you have all your filesystems mounted under \e[1m<destdir>\e[m."
echo -e "Then run this script to install all packages listed in \e[1m/etc/archboot/defaults\e[m"
echo -e "to \e[1m<destdir>\e[m."
2009-02-11 21:34:04 +01:00
echo
echo "Example:"
2023-02-07 20:19:31 +01:00
echo -e " \e[1mquickinst /mnt\e[m"
2009-02-11 21:34:04 +01:00
echo ""
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() {
# 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
# start script
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
2011-02-04 18:11:11 +01:00
! [[ -d /tmp ]] && mkdir /tmp
2008-10-20 22:39:25 +02:00
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
2008-12-06 19:12:19 +01:00
2009-02-11 21:34:04 +01:00
echo
2023-02-07 20:19:31 +01:00
echo -e "\e[1mPackage installation complete.\e[m"
2009-02-11 21:34:04 +01:00
echo
2023-02-07 20:19:31 +01:00
echo -e "Please install a \e[1mbootloader\e[m. Edit the appropriate config file for"
echo -e "your loader. Please use \e[1m${_VMLINUZ}\e[m as kernel image."
2022-04-05 21:01:07 +02:00
echo -e "Chroot into your system to install it:"
2023-02-07 20:19:31 +01:00
echo -e " \e[1m# mount -o bind /dev ${_DESTDIR}/dev\e[m"
echo -e " \e[1m# mount -t proc none ${_DESTDIR}/proc\e[m"
echo -e " \e[1m# mount -t sysfs none ${_DESTDIR}/sys\e[m"
echo -e " \e[1m# chroot ${_DESTDIR} /bin/bash\e[m"
2009-02-11 21:34:04 +01:00
echo
2008-10-20 22:39:25 +02:00
echo "Next step, initramfs setup:"
2023-02-07 20:19:31 +01:00
echo -e "Edit your \e[1m/etc/mkinitcpio.conf\e[m to fit your needs. After that run:"
echo -e " \e[1m# mkinitcpio -p ${_KERNELPKG}\e[m"
2009-02-11 21:34:04 +01:00
echo
2023-02-07 20:19:31 +01:00
echo -e "Then \e[1mexit\e[m your chroot shell, edit \e[1m${_DESTDIR}/etc/fstab\e[m and \e[1mreboot\e[m! "
2008-10-20 22:39:25 +02:00
exit 0
2009-02-11 21:34:04 +01:00
# vim: set ts=4 sw=4 et: