refactor(os): Allow AUR helper to replace itself (#3)

This commit is contained in:
2023-10-20 16:30:29 +02:00
parent 66eb02ff7d
commit 148f930636
2 changed files with 42 additions and 2 deletions

View File

@@ -460,7 +460,46 @@ function get_aur_helper () {
}
function paru_install () {
sudo --user build paru -S --noconfirm "${@}"
declare -a paru_install_packages
[[ "${1}" ]] && while :; do
case "${1}" in
-[[:alnum:]]*)
printf -- '%s\n' \
'Short-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
exit 77
;;
--replace-conflicting)
pacman_force_yes='true'
shift
continue
;;
--*)
printf -- '%s\n' \
'Long-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
exit 77
;;
'')
# All arguments processed
break
;;
*)
paru_install_packages+=("${1}")
shift
;;
esac
done || {
printf -- '%s\n' \
'No argument '"'${1}'"' given for function '"'${FUNCNAME[0]}'"'. Exiting ...'
exit 77
}
if [[ "${pacman_force_yes}" ]]; then
yes 'y' | sudo --user build paru -S "${paru_install_packages[@]}"
unset -v pacman_force_yes
else
sudo --user build paru -S --noconfirm "${paru_install_packages[@]}"
fi
}
function keep_initiramfs_root_only_rw () {
@@ -525,6 +564,7 @@ function install_os_in_chroot () {
unleash_makepkg
add_motd_getting_started_msg
get_aur_helper
paru_install --replace-conflicting 'paru-bin'
paru_install 'zfs-dkms' 'zfs-utils'
hwclock --systohc
locale-gen