archboot/usr/bin/archboot-quickinst.sh

102 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/bash
2021-09-27 10:02:51 +02:00
DESTDIR="${1}"
2022-04-05 21:44:16 +02:00
. /usr/lib/archboot/installer/common.sh
2008-10-20 22:39:25 +02:00
usage() {
2022-04-05 20:09:24 +02:00
echo -e "\033[1mWelcome to \033[34marchboot's\033[0m \033[1m QUICKINST INSTALLER:\033[0m"
2022-04-05 20:08:56 +02:00
echo -e "\033[1m-------------------------------------------\033[0m"
echo -e "Usage:"
echo -e "\033[1mquickinst <destdir>\033[0m"
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
if ! [[ -e "${LOCAL_DB}" ]]; then
echo -e "First configure \033[1m/etc/pacman.conf\033[0m which repositories to use"
echo -e "and set a mirror in \033[1m/etc/pacman.d/mirrorlist\033[0m"
fi
echo
echo -e "Make sure you have all your filesystems mounted under \033[1m<destdir>\033[0m."
echo -e "Then run this script to install all packages listed in \033[1m/etc/archboot/defaults\033[0m"
echo -e "to \033[1m<destdir>\033[0m."
2009-02-11 21:34:04 +01:00
echo
echo "Example:"
echo -e " \033[1mquickinst /mnt\033[0m"
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
prepare_pacman() {
# Set up the necessary directories for pacman use
2022-04-05 21:33:44 +02:00
if [[ ! -d "${DESTDIR}/var/cache/pacman/pkg" ]]; then
mkdir -p "${DESTDIR}/var/cache/pacman/pkg"
fi
if [[ ! -d "${DESTDIR}/var/lib/pacman" ]]; then
mkdir -p "${DESTDIR}/var/lib/pacman"
fi
2011-02-04 18:08:56 +01:00
${PACMAN} -Sy
KEYRING="archlinux-keyring"
[[ "$(uname -m)" == "aarch64" ]] && KEYRING="${KEYRING} archlinuxarm-keyring"
pacman -Sy ${PACMAN_CONF} --noconfirm --noprogressbar ${KEYRING} || exit 1
}
# package_installation
2010-02-22 07:40:53 +01:00
install_packages() {
# add packages from archboot defaults
PACKAGES=$(grep '^_PACKAGES' /etc/archboot/defaults | sed -e 's#_PACKAGES=##g' -e 's#"##g')
# fallback if _PACKAGES is empty
[[ -z "${PACKAGES}" ]] && PACKAGES="base linux linux-firmware"
auto_packages
2022-01-26 11:40:22 +01:00
#shellcheck disable=SC2086
2022-01-22 21:13:58 +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
2009-02-11 21:34:04 +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
if [[ -e "${LOCAL_DB}" ]]; then
local_pacman_conf
else
PACMAN_CONF=""
fi
2022-04-05 21:01:07 +02:00
if ! prepare_pacman; then
2022-04-05 21:33:44 +02:00
echo -e "Pacman preparation \033[91mFAILED\033[0m."
2022-04-05 21:26:44 +02:00
exit 1
2022-04-05 21:01:07 +02:00
fi
chroot_mount
2022-04-05 21:01:07 +02:00
if ! install_packages; then
2022-04-05 21:33:44 +02:00
echo -e "Package installation \033[91mFAILED\033[0m."
2022-04-05 21:01:07 +02:00
chroot_umount
exit 1
fi
locale_gen
chroot_umount
2008-12-06 19:12:19 +01:00
2009-02-11 21:34:04 +01:00
echo
2022-04-05 21:01:07 +02:00
echo -e "\033[1mPackage installation complete.\033[0m"
2009-02-11 21:34:04 +01:00
echo
2022-04-05 21:01:07 +02:00
echo -e "Please install a \033[1mbootloader\033[0m. Edit the appropriate config file for"
echo -e "your loader. Please use \033[1m${VMLINUZ}\033[0m as kernel image."
echo -e "Chroot into your system to install it:"
echo -e " \033[1m# mount -o bind /dev ${DESTDIR}/dev\033[0m"
echo -e " \033[1m# mount -t proc none ${DESTDIR}/proc\033[0m"
echo -e " \033[1m# mount -t sysfs none ${DESTDIR}/sys\033[0m"
echo -e " \033[1m# chroot ${DESTDIR} /bin/bash\033[0m"
2009-02-11 21:34:04 +01:00
echo
2008-10-20 22:39:25 +02:00
echo "Next step, initramfs setup:"
2022-04-05 21:01:07 +02:00
echo -e "Edit your \033[1m/etc/mkinitcpio.conf\033[0m to fit your needs. After that run:"
echo -e " \033[1m# mkinitcpio -p ${KERNELPKG}\033[0m"
2009-02-11 21:34:04 +01:00
echo
2022-04-05 21:47:40 +02:00
echo -e "Then \033[1mexit\033[0m your chroot shell, edit \033[1m${DESTDIR}/etc/fstab\033[0m and \033[1mreboot\033[0m! "
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: