feat(os): Replace manually building ZBM UEFI image with AUR package (#3)
This commit is contained in:
parent
b63164f2ad
commit
503ab0b58b
87
setup.sh
87
setup.sh
@ -41,6 +41,54 @@ function install_pkgs () {
|
|||||||
pacman -S --needed --noconfirm "${@}"
|
pacman -S --needed --noconfirm "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepare_zfsbootmenu_efi_bin_pkg () {
|
||||||
|
# Our Arch Linux will use prebuilt ZFSBootMenu UEFI image files for ease
|
||||||
|
# of use. We'd like to install them from within our chroot but the AUR
|
||||||
|
# package 'zfsbootmenu-efi-bin' that we're using currently (Friday,
|
||||||
|
# October 20, 2023) identifies its target EFI system partition (ESP) by
|
||||||
|
# doing 'lsblk' and checking the partition type name. Since within
|
||||||
|
# arch-chroot there's no '/run/udev' but only an empty '/run' tmpfs
|
||||||
|
# 'lsblk' cannot see partition type names and some other pieces of info.
|
||||||
|
#
|
||||||
|
# See also
|
||||||
|
# https://gitlab.archlinux.org/archlinux/arch-install-scripts/-/issues/24
|
||||||
|
#
|
||||||
|
# Thus within arch-chroot the installation of 'zfsbootmenu-efi-bin' and
|
||||||
|
# even 'makepkg -s' fails. We build the package in our Arch Linux live
|
||||||
|
# CD ISO image and copy the resulting file into our chroot.
|
||||||
|
#
|
||||||
|
# We circle back to the package file when we chroot into Arch and
|
||||||
|
# install_zbm_image().
|
||||||
|
pacman_cache_dir='/var/cache/pacman/pkg'
|
||||||
|
chroot_pacman_cache_dir='/mnt'"${pacman_cache_dir}"
|
||||||
|
git_zbm_efi_bin_dir='/tmp/zfsbootmenu-efi-bin'
|
||||||
|
sudo -u 'arch' git -C '/tmp' clone 'https://aur.archlinux.org/zfsbootmenu-efi-bin.git'
|
||||||
|
|
||||||
|
# We briefly bind-mount our ESP into '/efi' before we build the package.
|
||||||
|
# Its PKGBUILD will then find the ESP at the correct location and write
|
||||||
|
# a package file with that internal location ('/efi').
|
||||||
|
mkdir -p '/efi'
|
||||||
|
mount --bind '/mnt/efi' '/efi'
|
||||||
|
pushd "${git_zbm_efi_bin_dir}"
|
||||||
|
sudo -u 'arch' makepkg -s || {
|
||||||
|
printf -- '%s\n' 'Failed building zfsbootmenu-efi-bin package. Exiting ...'
|
||||||
|
exit 77
|
||||||
|
}
|
||||||
|
popd
|
||||||
|
umount '/efi'
|
||||||
|
rmdir '/efi'
|
||||||
|
|
||||||
|
package_file_abs="$(find "${git_zbm_efi_bin_dir}" -type f -iname '*pkg.tar.zst')"
|
||||||
|
package_file="$(basename "${package_file_abs}")"
|
||||||
|
mkdir -p "${chroot_pacman_cache_dir}"
|
||||||
|
rsync -av "${package_file_abs}" "${chroot_pacman_cache_dir}"'/'"${package_file}" || {
|
||||||
|
printf -- '%s\n' 'Failed rsyncing zfsbootmenu-efi-bin package file into chroot. Exiting ...'
|
||||||
|
exit 77
|
||||||
|
}
|
||||||
|
export ZFSBOOTMENU_EFI_BIN_PKG_PATH="${pacman_cache_dir}"'/'"${package_file}"
|
||||||
|
rm -rf "${git_zbm_efi_bin_dir}"
|
||||||
|
}
|
||||||
|
|
||||||
function install_zfs () {
|
function install_zfs () {
|
||||||
#1.4
|
#1.4
|
||||||
declare reset_colors='\033[0m'
|
declare reset_colors='\033[0m'
|
||||||
@ -502,6 +550,15 @@ function paru_install () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_zbm_image () {
|
||||||
|
# This takes image files written earlier in our Arch Linux live CD ISO
|
||||||
|
# image at prepare_zfsbootmenu_efi_bin_pkg() and installs them via their
|
||||||
|
# locally built package file. When done we delete the manually built
|
||||||
|
# package file from pacman's cache dir.
|
||||||
|
pacman -U "${ZFSBOOTMENU_EFI_BIN_PKG_PATH}" --noconfirm
|
||||||
|
rm "${ZFSBOOTMENU_EFI_BIN_PKG_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
function keep_initiramfs_root_only_rw () {
|
function keep_initiramfs_root_only_rw () {
|
||||||
declare systemd_local_admin_override_path unit_name
|
declare systemd_local_admin_override_path unit_name
|
||||||
systemd_local_admin_override_path='/etc/systemd/system'
|
systemd_local_admin_override_path='/etc/systemd/system'
|
||||||
@ -571,15 +628,8 @@ function install_os_in_chroot () {
|
|||||||
source /etc/locale.conf
|
source /etc/locale.conf
|
||||||
mkinitcpio -P
|
mkinitcpio -P
|
||||||
|
|
||||||
# Install ZFSBootMenu and deps
|
# Install ZFSBootMenu image
|
||||||
git clone --depth=1 https://github.com/zbm-dev/zfsbootmenu/ '/tmp/zfsbootmenu'
|
install_zbm_image
|
||||||
paru_install 'cpanminus' 'kexec-tools' 'fzf' 'util-linux'
|
|
||||||
pushd '/tmp/zfsbootmenu'
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
cpanm --notest --installdeps .
|
|
||||||
popd
|
|
||||||
rm -rf '/tmp/zfsbootmenu'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_root_pw () {
|
function set_root_pw () {
|
||||||
@ -636,24 +686,6 @@ function configure_zfs_mount_gen () {
|
|||||||
|
|
||||||
function configure_zfsbootmenu () {
|
function configure_zfsbootmenu () {
|
||||||
#2.7
|
#2.7
|
||||||
curl -s 'https://raw.githubusercontent.com/zbm-dev/zfsbootmenu/master/etc/zfsbootmenu/mkinitcpio.conf' | sed -r -e '/^#/d' -e '/^$/d' > '/mnt/etc/zfsbootmenu/mkinitcpio.conf'
|
|
||||||
cat > '/mnt/etc/zfsbootmenu/config.yaml' <<EOF
|
|
||||||
Global:
|
|
||||||
ManageImages: true
|
|
||||||
BootMountPoint: /efi
|
|
||||||
InitCPIO: true
|
|
||||||
|
|
||||||
Components:
|
|
||||||
Enabled: false
|
|
||||||
EFI:
|
|
||||||
ImageDir: /efi/EFI/ZBM
|
|
||||||
Versions: false
|
|
||||||
Enabled: true
|
|
||||||
Kernel:
|
|
||||||
CommandLine: ro loglevel=0 zbm.import_policy=hostid
|
|
||||||
Prefix: vmlinuz
|
|
||||||
EOF
|
|
||||||
# Up here maybe 'ro quiet' instead of 'ro'
|
|
||||||
zfs set org.zfsbootmenu:commandline='rw nowatchdog rd.vconsole.keymap=de-latin1' "${zpool_name}"'/root/'"${zfs_arch_dataset_name}"
|
zfs set org.zfsbootmenu:commandline='rw nowatchdog rd.vconsole.keymap=de-latin1' "${zpool_name}"'/root/'"${zfs_arch_dataset_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,6 +756,7 @@ function main () {
|
|||||||
set_ntp #1.1
|
set_ntp #1.1
|
||||||
update_pacman_db #1.2
|
update_pacman_db #1.2
|
||||||
install_pkgs 'base-devel' 'git' 'jq' #1.3
|
install_pkgs 'base-devel' 'git' 'jq' #1.3
|
||||||
|
prepare_zfsbootmenu_efi_bin_pkg
|
||||||
install_zfs #1.4
|
install_zfs #1.4
|
||||||
setup_zpool #1.4
|
setup_zpool #1.4
|
||||||
mount_system #1.5
|
mount_system #1.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user