rename parameters

This commit is contained in:
Tobias Powalowski 2023-01-08 08:48:05 +01:00
parent 75a59edd13
commit 277eec8e18
7 changed files with 60 additions and 59 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
DESTDIR="${1}"
_DESTDIR="${1}"
. /usr/lib/archboot/installer/common.sh
usage() {
@ -11,7 +11,7 @@ usage() {
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
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
@ -31,11 +31,11 @@ usage() {
# returns: 1 on error
prepare_pacman() {
# Set up the necessary directories for pacman use
if [[ ! -d "${DESTDIR}/var/cache/pacman/pkg" ]]; then
mkdir -p "${DESTDIR}/var/cache/pacman/pkg"
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"
if [[ ! -d "${_DESTDIR}/var/lib/pacman" ]]; then
mkdir -p "${_DESTDIR}/var/lib/pacman"
fi
# pacman-key process itself
while pgrep -x pacman-key > /dev/null 2>&1; do
@ -47,21 +47,21 @@ prepare_pacman() {
done
[[ -e /etc/systemd/system/pacman-init.service ]] && systemctl stop pacman-init.service
${PACMAN} -Sy
KEYRING="archlinux-keyring"
[[ "$(uname -m)" == "aarch64" ]] && KEYRING="${KEYRING} archlinuxarm-keyring"
_KEYRING="archlinux-keyring"
[[ "$(uname -m)" == "aarch64" ]] && _KEYRING="${_KEYRING} archlinuxarm-keyring"
#shellcheck disable=SC2086
pacman -Sy ${PACMAN_CONF} --noconfirm --noprogressbar ${KEYRING} || exit 1
pacman -Sy ${PACMAN_CONF} --noconfirm --noprogressbar ${_KEYRING} || exit 1
}
# package_installation
install_packages() {
# add packages from archboot defaults
PACKAGES=$(grep '^_PACKAGES' /etc/archboot/defaults | sed -e 's#_PACKAGES=##g' -e 's#"##g')
_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"
[[ -z "${_PACKAGES}" ]] && _PACKAGES="base linux linux-firmware"
auto_packages
#shellcheck disable=SC2086
${PACMAN} -S ${PACKAGES}
${PACMAN} -S ${_PACKAGES}
}
# start script
@ -71,7 +71,7 @@ fi
! [[ -d /tmp ]] && mkdir /tmp
if [[ -e "${LOCAL_DB}" ]]; then
if [[ -e "${_LOCAL_DB}" ]]; then
local_pacman_conf
else
PACMAN_CONF=""
@ -94,18 +94,18 @@ echo
echo -e "\033[1mPackage installation complete.\033[0m"
echo
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 "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"
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"
echo
echo "Next step, initramfs setup:"
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"
echo -e " \033[1m# mkinitcpio -p ${_KERNELPKG}\033[0m"
echo
echo -e "Then \033[1mexit\033[0m your chroot shell, edit \033[1m${DESTDIR}/etc/fstab\033[0m and \033[1mreboot\033[0m! "
echo -e "Then \033[1mexit\033[0m your chroot shell, edit \033[1m${_DESTDIR}/etc/fstab\033[0m and \033[1mreboot\033[0m! "
exit 0
# vim: set ts=4 sw=4 et:

View file

@ -139,13 +139,13 @@ auto_mkinitcpio() {
fi
# get kernel version
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
offset=$(hexdump -s 526 -n 2 -e '"%0d"' "${_DESTDIR}/boot/${VMLINUZ}")
read -r HWKVER _ < <(dd if="${_DESTDIR}/boot/${VMLINUZ}" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null)
offset=$(hexdump -s 526 -n 2 -e '"%0d"' "${_DESTDIR}/boot/${_VMLINUZ}")
read -r HWKVER _ < <(dd if="${_DESTDIR}/boot/${_VMLINUZ}" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null)
elif [[ "${_RUNNING_ARCH}" == "aarch64" || "${_RUNNING_ARCH}" == "riscv64" ]]; then
reader="cat"
# try if the image is gzip compressed
[[ $(file -b --mime-type "${_DESTDIR}/boot/${VMLINUZ}") == 'application/gzip' ]] && reader="zcat"
read -r _ _ HWKVER _ < <($reader "${_DESTDIR}/boot/${VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+')
[[ $(file -b --mime-type "${_DESTDIR}/boot/${_VMLINUZ}") == 'application/gzip' ]] && reader="zcat"
read -r _ _ HWKVER _ < <($reader "${_DESTDIR}/boot/${_VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+')
fi
# arrange MODULES for mkinitcpio.conf
HWDETECTMODULES="$(hwdetect --kernel_directory="${_DESTDIR}" --kernel_version="${HWKVER}" --hostcontroller --filesystem ${FBPARAMETER})"

View file

@ -20,6 +20,7 @@ _VC="VC${_VC_NUM}"
_S_SRC=0 # choose mirror
_S_MKFS=0 # formatting
_S_MKFSAUTO=0 # auto fs part/formatting
_S_BOOTLOADER=0 # bootloader installation
# menu item tracker- autoselect the next item
_NEXTITEM=""
# To allow choice in script set EDITOR=""

View file

@ -6,7 +6,7 @@ INTEL_UCODE="intel-ucode.img"
AMD_UCODE="amd-ucode.img"
ROOTFS=""
# name of the initramfs filesystem
INITRAMFS="initramfs-${KERNELPKG}.img"
INITRAMFS="initramfs-${_KERNELPKG}.img"
getrootfstype() {
ROOTFS="$(getfstype "${PART_ROOT}")"
@ -277,23 +277,23 @@ do_mok_sign () {
sleep 5
fi
SIGN_MOK=""
DIALOG --yesno "Do you want to sign with the MOK certificate?\n\n/boot/${VMLINUZ} and ${UEFI_BOOTLOADER_DIR}/grub${_SPEC_UEFI_ARCH}.efi" 7 55 && SIGN_MOK="1"
DIALOG --yesno "Do you want to sign with the MOK certificate?\n\n/boot/${_VMLINUZ} and ${UEFI_BOOTLOADER_DIR}/grub${_SPEC_UEFI_ARCH}.efi" 7 55 && SIGN_MOK="1"
if [[ "${SIGN_MOK}" == "1" ]]; then
if [[ "${_DESTDIR}" == "/install" ]]; then
systemd-nspawn -q -D "${_DESTDIR}" sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output /boot/"${VMLINUZ}" /boot/"${VMLINUZ}" > "${_LOG}" 2>&1
systemd-nspawn -q -D "${_DESTDIR}" sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output /boot/"${_VMLINUZ}" /boot/"${_VMLINUZ}" > "${_LOG}" 2>&1
systemd-nspawn -q -D "${_DESTDIR}" sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output "${UEFI_BOOTLOADER_DIR}"/grub"${_SPEC_UEFI_ARCH}".efi "${UEFI_BOOTLOADER_DIR}"/grub"${_SPEC_UEFI_ARCH}".efi > "${_LOG}" 2>&1
else
sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output /boot/"${VMLINUZ}" /boot/"${VMLINUZ}" > "${_LOG}" 2>&1
sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output /boot/"${_VMLINUZ}" /boot/"${_VMLINUZ}" > "${_LOG}" 2>&1
sbsign --key /"${KEYDIR}"/MOK/MOK.key --cert /"${KEYDIR}"/MOK/MOK.crt --output "${UEFI_BOOTLOADER_DIR}"/grub"${_SPEC_UEFI_ARCH}".efi "${UEFI_BOOTLOADER_DIR}"/grub"${_SPEC_UEFI_ARCH}".efi > "${_LOG}" 2>&1
fi
DIALOG --infobox "/boot/${VMLINUZ} and ${UEFI_BOOTLOADER_DIR}/grub${_SPEC_UEFI_ARCH}.efi\n\nbeen signed successfully.\n\nContinuing in 5 seconds ..." 7 60
DIALOG --infobox "/boot/${_VMLINUZ} and ${UEFI_BOOTLOADER_DIR}/grub${_SPEC_UEFI_ARCH}.efi\n\nbeen signed successfully.\n\nContinuing in 5 seconds ..." 7 60
sleep 5
fi
}
do_pacman_sign() {
SIGN_KERNEL=""
DIALOG --yesno "Do you want to install a pacman hook\nfor automatic signing /boot/${VMLINUZ} on updates?" 6 60 && SIGN_KERNEL="1"
DIALOG --yesno "Do you want to install a pacman hook\nfor automatic signing /boot/${_VMLINUZ} on updates?" 6 60 && SIGN_KERNEL="1"
if [[ "${SIGN_KERNEL}" == "1" ]]; then
[[ ! -d "${_DESTDIR}/etc/pacman.d/hooks" ]] && mkdir -p "${_DESTDIR}"/etc/pacman.d/hooks/
HOOKNAME="${_DESTDIR}/etc/pacman.d/hooks/999-sign_kernel_for_secureboot.hook"
@ -328,9 +328,9 @@ do_efistub_parameters() {
UEFISYS_PART_FS_UUID="$(getfsuuid "${_uefisysdev}")"
if [[ "${UEFISYS_MP}" == "/boot" ]]; then
if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
_KERNEL="${VMLINUZ_EFISTUB}"
_KERNEL="${_VMLINUZ_EFISTUB}"
else
_KERNEL="${VMLINUZ}"
_KERNEL="${_VMLINUZ}"
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
_INITRD_INTEL_UCODE="${INTEL_UCODE}"
fi
@ -342,9 +342,9 @@ do_efistub_parameters() {
else
# name .efi for uefisys partition
if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
_KERNEL="${UEFISYS_PATH}/${VMLINUZ_EFISTUB}"
_KERNEL="${UEFISYS_PATH}/${_VMLINUZ_EFISTUB}"
else
_KERNEL="${UEFISYS_PATH}/${VMLINUZ}"
_KERNEL="${UEFISYS_PATH}/${_VMLINUZ}"
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
_INITRD_INTEL_UCODE="${UEFISYS_PATH}/${INTEL_UCODE}"
fi
@ -362,7 +362,7 @@ do_efistub_copy_to_efisys() {
DIALOG --infobox "Copying kernel, ucode and initramfs to EFI system partition now ..." 4 50
! [[ -d "${_DESTDIR}/${UEFISYS_MP}/${UEFISYS_PATH}" ]] && mkdir -p "${_DESTDIR}/${UEFISYS_MP}/${UEFISYS_PATH}"
rm -f "${_DESTDIR}/${UEFISYS_MP}/${_KERNEL}"
cp -f "${_DESTDIR}/boot/${VMLINUZ}" "${_DESTDIR}/${UEFISYS_MP}/${_KERNEL}"
cp -f "${_DESTDIR}/boot/${_VMLINUZ}" "${_DESTDIR}/${UEFISYS_MP}/${_KERNEL}"
rm -f "${_DESTDIR}/${UEFISYS_MP}/${_INITRD}"
cp -f "${_DESTDIR}/boot/${INITRAMFS}" "${_DESTDIR}/${UEFISYS_MP}/${_INITRD}"
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
@ -379,7 +379,7 @@ do_efistub_copy_to_efisys() {
[Unit]
Description=Copy EFISTUB Kernel and Initramfs files to EFI SYSTEM PARTITION
[Path]
PathChanged=/boot/${VMLINUZ}
PathChanged=/boot/${_VMLINUZ}
PathChanged=/boot/${INITRAMFS}
CONFEOF
[[ "${_RUNNING_ARCH}" == "aarch64" || "${_RUNNING_ARCH}" == "x86_64" ]] && \
@ -396,7 +396,7 @@ CONFEOF
Description=Copy EFISTUB Kernel and Initramfs files to EFI SYSTEM PARTITION
[Service]
Type=oneshot
ExecStart=/usr/bin/cp -f /boot/${VMLINUZ} ${UEFISYS_MP}/${_KERNEL}
ExecStart=/usr/bin/cp -f /boot/${_VMLINUZ} ${UEFISYS_MP}/${_KERNEL}
ExecStart=/usr/bin/cp -f /boot/${INITRAMFS} ${UEFISYS_MP}/${_INITRD}
CONFEOF
[[ "${_RUNNING_ARCH}" == "aarch64" || "${_RUNNING_ARCH}" == "x86_64" ]] && \
@ -661,9 +661,9 @@ EOF
fi
fi
if [[ "${GRUB_UEFI}" == "1" ]]; then
LINUX_UNMOD_COMMAND="linux ${subdir}/${VMLINUZ} ${_KERNEL_PARAMS_MOD}"
LINUX_UNMOD_COMMAND="linux ${subdir}/${_VMLINUZ} ${_KERNEL_PARAMS_MOD}"
else
LINUX_UNMOD_COMMAND="linux ${subdir}/${VMLINUZ} ${_KERNEL_PARAMS_MOD}"
LINUX_UNMOD_COMMAND="linux ${subdir}/${_VMLINUZ} ${_KERNEL_PARAMS_MOD}"
fi
LINUX_MOD_COMMAND=$(echo "${LINUX_UNMOD_COMMAND}" | sed -e 's# # #g' | sed -e 's# # #g')
## create default kernel entry
@ -758,7 +758,7 @@ timeout 100
default linux
label linux
menu label Boot System (automatic boot in 10 seconds ...)
kernel ${subdir}/${VMLINUZ}
kernel ${subdir}/${_VMLINUZ}
initrd ${subdir}/${INITRAMFS}
append ${_KERNEL_PARAMS_COMMON_MOD}
EOF

View file

@ -4,13 +4,13 @@
LANG=C.UTF8
_LOCAL_DB="/var/cache/pacman/pkg/archboot.db"
_RUNNING_ARCH="$(uname -m)"
KERNELPKG="linux"
_KERNELPKG="linux"
# name of the kernel image
[[ "${_RUNNING_ARCH}" == "x86_64" || "${_RUNNING_ARCH}" == "riscv64" ]] && VMLINUZ="vmlinuz-${KERNELPKG}"
[[ "${_RUNNING_ARCH}" == "x86_64" || "${_RUNNING_ARCH}" == "riscv64" ]] && _VMLINUZ="vmlinuz-${_KERNELPKG}"
if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
VMLINUZ="Image.gz"
_VMLINUZ="Image.gz"
#shellcheck disable=SC2034
VMLINUZ_EFISTUB="Image"
_VMLINUZ_EFISTUB="Image"
fi
# abstract the common pacman args
PACMAN="pacman --root ${_DESTDIR} ${PACMAN_CONF} --cachedir=${_DESTDIR}/var/cache/pacman/pkg --noconfirm --noprogressbar"

View file

@ -89,9 +89,9 @@ run_mkinitcpio() {
chroot_mount
echo "Initramfs progress ..." > /tmp/mkinitcpio.log
if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
chroot "${_DESTDIR}" mkinitcpio -p "${KERNELPKG}"-"${_RUNNING_ARCH}" |& tee -a "${_LOG}" /tmp/mkinitcpio.log >/dev/null 2>&1
chroot "${_DESTDIR}" mkinitcpio -p "${_KERNELPKG}"-"${_RUNNING_ARCH}" |& tee -a "${_LOG}" /tmp/mkinitcpio.log >/dev/null 2>&1
else
chroot "${_DESTDIR}" mkinitcpio -p "${KERNELPKG}" |& tee -a "${_LOG}" /tmp/mkinitcpio.log >/dev/null 2>&1
chroot "${_DESTDIR}" mkinitcpio -p "${_KERNELPKG}" |& tee -a "${_LOG}" /tmp/mkinitcpio.log >/dev/null 2>&1
fi
echo $? > /tmp/.mkinitcpio-retcode
if [[ $(cat /tmp/.mkinitcpio-retcode) -ne 0 ]]; then

View file

@ -2,19 +2,19 @@
# created by Tobias Powalowski <tpowa@archlinux.org>
# downloader
DLPROG="wget"
MIRRORLIST="/etc/pacman.d/mirrorlist"
_MIRRORLIST="/etc/pacman.d/mirrorlist"
getsource() {
S_SRC=0
PACMAN_CONF=""
_S_SRC=0
_PACMAN_CONF=""
if [[ -e "${_LOCAL_DB}" ]]; then
_NEXTITEM="4"
local_pacman_conf
DIALOG --msgbox "Setup is running in <Local mode>.\nOnly Local package database is used for package installation.\n\nIf you want to switch to <Online mode>, you have to delete /var/cache/pacman/pkg/archboot.db and rerun this step." 10 70
S_SRC=1
_S_SRC=1
else
select_mirror || return 1
S_SRC=1
_S_SRC=1
fi
}
@ -30,12 +30,12 @@ select_mirror() {
dialog --infobox "Downloading latest mirrorlist ..." 3 40
${DLPROG} -q "https://www.archlinux.org/mirrorlist/?country=all&protocol=http&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" -O /tmp/pacman_mirrorlist.txt
if grep -q '#Server = http:' /tmp/pacman_mirrorlist.txt; then
mv "${MIRRORLIST}" "${MIRRORLIST}.bak"
cp /tmp/pacman_mirrorlist.txt "${MIRRORLIST}"
mv "${_MIRRORLIST}" "${_MIRRORLIST}.bak"
cp /tmp/pacman_mirrorlist.txt "${_MIRRORLIST}"
fi
fi
# FIXME: this regex doesn't honor commenting
MIRRORS=$(grep -E -o '((http)|(https))://[^/]*' "${MIRRORLIST}" | sed 's|$| _|g')
MIRRORS=$(grep -E -o '((http)|(https))://[^/]*' "${_MIRRORLIST}" | sed 's|$| _|g')
#shellcheck disable=SC2086
DIALOG --menu "Select a mirror:" 14 55 7 \
${MIRRORS} \
@ -51,7 +51,7 @@ select_mirror() {
# our mirrorlist and pulling the full URL out. Substitute 'core' in
# for the repository name, and ensure that if it was listed twice we
# only return one line for the mirror.
SYNC_URL=$(grep -E -o "${_server}.*" "${MIRRORLIST}" | head -n1)
SYNC_URL=$(grep -E -o "${_server}.*" "${_MIRRORLIST}" | head -n1)
fi
_NEXTITEM="4"
echo "Using mirror: ${SYNC_URL}" > "${_LOG}"
@ -87,13 +87,13 @@ update_environment() {
sleep 1
DIALOG --infobox "Checking on new online kernel version ..." 3 70
#shellcheck disable=SC2086
LOCAL_KERNEL="$(pacman -Qi ${KERNELPKG} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
LOCAL_KERNEL="$(pacman -Qi ${_KERNELPKG} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then
#shellcheck disable=SC2086
ONLINE_KERNEL="$(pacman -Si ${KERNELPKG}-${_RUNNING_ARCH} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
ONLINE_KERNEL="$(pacman -Si ${_KERNELPKG}-${_RUNNING_ARCH} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
else
#shellcheck disable=SC2086
ONLINE_KERNEL="$(pacman -Si ${KERNELPKG} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
ONLINE_KERNEL="$(pacman -Si ${_KERNELPKG} | grep Version | cut -d ':' -f2 | sed -e 's# ##')"
fi
echo "${LOCAL_KERNEL} local kernel version and ${ONLINE_KERNEL} online kernel version." > "${_LOG}"
sleep 2
@ -136,7 +136,7 @@ prepare_pacman() {
KEYRING="archlinux-keyring"
[[ "${_RUNNING_ARCH}" == "aarch64" ]] && KEYRING="${KEYRING} archlinuxarm-keyring"
#shellcheck disable=SC2086
pacman -Sy ${PACMAN_CONF} --noconfirm --noprogressbar ${KEYRING} > "${_LOG}" 2>&1 || (DIALOG --msgbox "Keyring update failed! Check ${_LOG} for errors." 6 60; return 1)
pacman -Sy ${_PACMAN_CONF} --noconfirm --noprogressbar ${KEYRING} > "${_LOG}" 2>&1 || (DIALOG --msgbox "Keyring update failed! Check ${_LOG} for errors." 6 60; return 1)
}
# Set _PACKAGES parameter before running to install wanted packages