Compare commits
4 Commits
b5c9ba4127
...
da88ec53a6
Author | SHA1 | Date | |
---|---|---|---|
da88ec53a6 | |||
e92a22c005 | |||
de4f3f2066 | |||
c7e59ba0cb |
82
setup.sh
82
setup.sh
@@ -1,5 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Whatever comes in on file descriptor (FD) 3 gets redirected to where file
|
||||||
|
# descriptor 1 is pointing. File descriptor 1 points to stdout so when we
|
||||||
|
# output-redirect something into FD 3 it shows up on stdout. We can use this
|
||||||
|
# to produce arbitrary logging output inside a subshell like so:
|
||||||
|
#
|
||||||
|
# function my_func () {
|
||||||
|
# some_command "${1:?}"
|
||||||
|
# >&3 echo 'A log message'
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# var="$(my_func arg_1)"
|
||||||
|
#
|
||||||
|
# Here "${var}" will only capture the output of some_command "${1:?}". It
|
||||||
|
# will not capture 'echo' which will instead show up on our stdout/FD 1.
|
||||||
exec 3>&1
|
exec 3>&1
|
||||||
|
|
||||||
declare this_script_url
|
declare this_script_url
|
||||||
@@ -250,7 +264,7 @@ function setup_zpool () {
|
|||||||
export_pool
|
export_pool
|
||||||
import_pool
|
import_pool
|
||||||
else
|
else
|
||||||
printf -- '%s\n' 'A zpool already exists, that is unexpected. Cowardly exiting 1 ...'
|
>&3 printf -- '%s\n' 'A zpool already exists, that is unexpected. Cowardly exiting 1 ...'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -299,7 +313,7 @@ function prepare_zfsbootmenu_efi_bin_pkg () {
|
|||||||
mount --bind '/mnt/efi' '/efi'
|
mount --bind '/mnt/efi' '/efi'
|
||||||
pushd "${git_zbm_efi_bin_dir}"
|
pushd "${git_zbm_efi_bin_dir}"
|
||||||
sudo -u 'arch' makepkg -s || {
|
sudo -u 'arch' makepkg -s || {
|
||||||
printf -- '%s\n' 'Failed building zfsbootmenu-efi-bin package. Exiting ...'
|
>&3 printf -- '%s\n' 'Failed building zfsbootmenu-efi-bin package. Exiting ...'
|
||||||
exit 77
|
exit 77
|
||||||
}
|
}
|
||||||
popd
|
popd
|
||||||
@@ -310,7 +324,7 @@ function prepare_zfsbootmenu_efi_bin_pkg () {
|
|||||||
package_file="$(basename "${package_file_abs}")"
|
package_file="$(basename "${package_file_abs}")"
|
||||||
mkdir -p "${chroot_pacman_cache_dir}"
|
mkdir -p "${chroot_pacman_cache_dir}"
|
||||||
rsync -av "${package_file_abs}" "${chroot_pacman_cache_dir}"'/'"${package_file}" || {
|
rsync -av "${package_file_abs}" "${chroot_pacman_cache_dir}"'/'"${package_file}" || {
|
||||||
printf -- '%s\n' 'Failed rsyncing zfsbootmenu-efi-bin package file into chroot. Exiting ...'
|
>&3 printf -- '%s\n' 'Failed rsyncing zfsbootmenu-efi-bin package file into chroot. Exiting ...'
|
||||||
exit 77
|
exit 77
|
||||||
}
|
}
|
||||||
export ZFSBOOTMENU_EFI_BIN_PKG_PATH="${pacman_cache_dir}"'/'"${package_file}"
|
export ZFSBOOTMENU_EFI_BIN_PKG_PATH="${pacman_cache_dir}"'/'"${package_file}"
|
||||||
@@ -447,54 +461,6 @@ curl --silent '${this_script_url}' | bash
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_pkg_info () {
|
|
||||||
declare from_where local_pkg_info local_pkg_version version_search
|
|
||||||
from_where="${1}"
|
|
||||||
version_search='/Version/{print $3}'
|
|
||||||
pkg_info="$(paru -$([[ "${from_where}" == 'local' ]] && printf -- '%s' 'Q' || printf -- '%s' 'S')i "${2}" 2>&1)"
|
|
||||||
if [[ "${from_where}" == 'local' ]] && grep -Piq -- '^error: package .*? was not found' <<<"${pkg_info}"; then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
local_pkg_version="$(awk "${version_search}" <<<"${pkg_info}")"
|
|
||||||
fi
|
|
||||||
printf -- '%s' "${local_pkg_version}"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function paru_with_zfs_first () {
|
|
||||||
if [[ "${#}" -eq '0' ]]; then
|
|
||||||
declare -A local_pkg_info
|
|
||||||
/usr/bin/paru -Sy
|
|
||||||
if local_pkg_info['zfs-dkms']="$(get_pkg_info 'local' 'zfs-dkms')" && local_pkg_info['zfs-utils']="$(get_pkg_info 'local' 'zfs-utils')"; then
|
|
||||||
local_pkg_info['zfs-dkms']="$(get_pkg_info 'local' 'zfs-dkms')"
|
|
||||||
local_pkg_info['zfs-utils']="$(get_pkg_info 'local' 'zfs-utils')"
|
|
||||||
|
|
||||||
declare -A remote_pkg_info
|
|
||||||
remote_pkg_info['zfs-dkms']="$(get_pkg_info 'remote' 'zfs-dkms')"
|
|
||||||
remote_pkg_info['zfs-utils']="$(get_pkg_info 'remote' 'zfs-utils')"
|
|
||||||
|
|
||||||
/usr/bin/paru -S --needed archlinux-keyring
|
|
||||||
|
|
||||||
if [[ "${local_pkg_info['zfs-dkms']}" == "${remote_pkg_info['zfs-dkms']}" ]] && \
|
|
||||||
[[ "${local_pkg_info['zfs-utils']}" == "${remote_pkg_info['zfs-utils']}" ]]; then
|
|
||||||
/usr/bin/paru -Su
|
|
||||||
else
|
|
||||||
/usr/bin/paru -Sy 'zfs-dkms' 'zfs-utils' \
|
|
||||||
--assume-installed zfs-dkms="${local_pkg_info['zfs-dkms']}" \
|
|
||||||
--assume-installed zfs-dkms="${remote_pkg_info['zfs-dkms']}" \
|
|
||||||
--assume-installed zfs-utils="${local_pkg_info['zfs-utils']}" \
|
|
||||||
--assume-installed zfs-utils="${remote_pkg_info['zfs-utils']}"
|
|
||||||
/usr/bin/paru -Su
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
/usr/bin/paru -S --needed archlinux-keyring
|
|
||||||
/usr/bin/paru -Su
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
/usr/bin/paru "${@}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_unpriv_user () {
|
function create_unpriv_user () {
|
||||||
account_name="${1:?}"
|
account_name="${1:?}"
|
||||||
full_name="${2:-${account_name}}"
|
full_name="${2:-${account_name}}"
|
||||||
@@ -531,7 +497,6 @@ function get_aur_helper () {
|
|||||||
popd
|
popd
|
||||||
rm -rf 'paru'
|
rm -rf 'paru'
|
||||||
popd
|
popd
|
||||||
alias paru='paru_with_zfs_first'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function paru_install () {
|
function paru_install () {
|
||||||
@@ -539,7 +504,7 @@ function paru_install () {
|
|||||||
[[ "${1}" ]] && while :; do
|
[[ "${1}" ]] && while :; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-[[:alnum:]]*)
|
-[[:alnum:]]*)
|
||||||
printf -- '%s\n' \
|
>&3 printf -- '%s\n' \
|
||||||
'Short-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
|
'Short-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
|
||||||
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
|
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
|
||||||
exit 77
|
exit 77
|
||||||
@@ -550,7 +515,7 @@ function paru_install () {
|
|||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
printf -- '%s\n' \
|
>&3 printf -- '%s\n' \
|
||||||
'Long-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
|
'Long-form argument '"'${1}'"' not supported for function '"'${FUNCNAME[0]}()'"'. Only known accepted argument' \
|
||||||
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
|
'is '"'"'--replace-conflicting'"'"' without a value given. Exiting ...'
|
||||||
exit 77
|
exit 77
|
||||||
@@ -565,15 +530,15 @@ function paru_install () {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done || {
|
done || {
|
||||||
printf -- '%s\n' \
|
>&3 printf -- '%s\n' \
|
||||||
'No argument '"'${1}'"' given for function '"'${FUNCNAME[0]}'"'. Exiting ...'
|
'No argument '"'${1}'"' given for function '"'${FUNCNAME[0]}'"'. Exiting ...'
|
||||||
exit 77
|
exit 77
|
||||||
}
|
}
|
||||||
if [[ "${pacman_force_yes}" ]]; then
|
if [[ "${pacman_force_yes}" ]]; then
|
||||||
yes 'y' | sudo --user build paru -S "${paru_install_packages[@]}"
|
yes 'y' | sudo --user 'build' paru -S "${paru_install_packages[@]}"
|
||||||
unset -v pacman_force_yes
|
unset -v pacman_force_yes
|
||||||
else
|
else
|
||||||
sudo --user build paru -S --noconfirm "${paru_install_packages[@]}"
|
sudo --user 'build' paru -S --noconfirm "${paru_install_packages[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,8 +623,7 @@ function install_os_in_chroot () {
|
|||||||
add_motd_getting_started_msg #2.6
|
add_motd_getting_started_msg #2.6
|
||||||
get_aur_helper #2.7
|
get_aur_helper #2.7
|
||||||
paru_install --replace-conflicting 'paru-bin'
|
paru_install --replace-conflicting 'paru-bin'
|
||||||
paru_install 'zfs-dkms'
|
paru_install 'zfs-dkms' 'zfs-utils' 'rsync'
|
||||||
paru_install 'zfs-utils' 'rsync'
|
|
||||||
hwclock --systohc
|
hwclock --systohc
|
||||||
mkinitcpio -P
|
mkinitcpio -P
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user