mirror of
https://codeberg.org/privacy1st/arch
synced 2024-12-23 01:16:04 +01:00
grub: remember selected menu entry
This commit is contained in:
parent
66b26a20d2
commit
c6ea86a21e
15
pkg/de-p1st-grub/.install
Normal file
15
pkg/de-p1st-grub/.install
Normal file
@ -0,0 +1,15 @@
|
||||
## arg 1: the new package version
|
||||
post_install() {
|
||||
holo apply
|
||||
}
|
||||
|
||||
## arg 1: the new package version
|
||||
## arg 2: the old package version
|
||||
post_upgrade() {
|
||||
holo apply
|
||||
}
|
||||
|
||||
## arg 1: the old package version
|
||||
post_remove() {
|
||||
holo apply
|
||||
}
|
@ -2,14 +2,14 @@
|
||||
_pkgname=grub
|
||||
_reponame=arch
|
||||
pkgname="de-p1st-$_pkgname"
|
||||
pkgver=0.0.2
|
||||
pkgrel=2
|
||||
pkgver=0.0.3
|
||||
pkgrel=1
|
||||
pkgdesc="grub with configuration"
|
||||
arch=('any')
|
||||
url="https://codeberg.org/privacy1st/${_reponame}"
|
||||
license=('MIT')
|
||||
groups=()
|
||||
depends=('grub')
|
||||
depends=('grub' 'holo')
|
||||
makedepends=('git')
|
||||
optdepends=()
|
||||
provides=()
|
||||
@ -17,7 +17,7 @@ conflicts=()
|
||||
replaces=()
|
||||
backup=()
|
||||
options=()
|
||||
install=
|
||||
install='.install'
|
||||
changelog=
|
||||
source=("git+${url}.git")
|
||||
noextract=()
|
||||
@ -27,4 +27,6 @@ package() {
|
||||
cd "${_reponame}/pkg/${pkgname}"
|
||||
|
||||
install -Dm0755 -o0 40_efi_setup "$pkgdir"/etc/grub.d/40_efi_setup
|
||||
|
||||
install -Dm0544 grub.holoscript "$pkgdir"/usr/share/holo/files/"$pkgname"/etc/default/grub.holoscript
|
||||
}
|
||||
|
12
pkg/de-p1st-grub/README.md
Normal file
12
pkg/de-p1st-grub/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# grub
|
||||
|
||||
## efi setup
|
||||
|
||||
See [/etc/grub.d/40_efi_setup](40_efi_setup)
|
||||
|
||||
## multiple entries
|
||||
|
||||
* disable submenu
|
||||
* remember last selection
|
||||
|
||||
Archwiki: [GRUB/Tips_and_tricks#Multiple_entries](https://wiki.archlinux.org/title/GRUB/Tips_and_tricks#Multiple_entries)
|
10
pkg/de-p1st-grub/grub.holoscript
Normal file
10
pkg/de-p1st-grub/grub.holoscript
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# stdin: default config
|
||||
# stdout: modified config
|
||||
|
||||
# 1) and 2) remember last selected entry; 3) disable submenu
|
||||
sed '
|
||||
s|^GRUB_DEFAULT=0$|GRUB_DEFAULT=saved|;
|
||||
s|^#GRUB_SAVEDEFAULT="true"$|#GRUB_SAVEDEFAULT="true"|;
|
||||
s|^#GRUB_DISABLE_SUBMENU=y$|GRUB_DISABLE_SUBMENU=y|;
|
||||
'
|
@ -294,9 +294,29 @@ function user_and_pwd() {
|
||||
printf "%s:%s" "root" "${ROOT_PWD}" | chpasswd --root /mnt || return $?
|
||||
}
|
||||
|
||||
function gen_initramfs(){
|
||||
function bootloader() {
|
||||
# @pre
|
||||
# TARGET_BLOCK_DEVICE
|
||||
# LUKS_PART_UUID
|
||||
|
||||
case "${BIOS_TYPE}" in
|
||||
uefi)
|
||||
# portable fallback efi name for grub:
|
||||
# * https://www.rodsbooks.com/efi-bootloaders/installation.html#alternative-naming
|
||||
# * arch-chroot /mnt cp /boot/EFI/GRUB/grubx64.efi /boot/EFI/BOOT/bootx64.efi
|
||||
arch-chroot /mnt grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot --removable || return $?
|
||||
;;
|
||||
bios)
|
||||
arch-chroot /mnt grub-install --target=i386-pc "${TARGET_BLOCK_DEVICE}" || return $?
|
||||
;;
|
||||
*)
|
||||
echo "Not yet implemented!"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# TODO
|
||||
true
|
||||
|
||||
}
|
||||
|
||||
function main() {
|
||||
@ -322,7 +342,7 @@ function main() {
|
||||
# out: BOOT_PART, LUKS_PART
|
||||
partition || return $?
|
||||
# in: BIOS_TYPE, BOOT_PART, LUKS_PART, LUKS_PWD, FS
|
||||
# out: DATA_PART
|
||||
# out: LUKS_PART_UUID, DATA_PART
|
||||
format || return $?
|
||||
|
||||
# Combine default and chosen mount options
|
||||
@ -338,16 +358,22 @@ function main() {
|
||||
mount "$BOOT_PART" /mnt/boot || return $?
|
||||
|
||||
# in: BIOS_TYPE, KERNEL, CPU_VENDOR
|
||||
run_pacstrap || return $?
|
||||
run_pacstrap || return $?
|
||||
# in: FS
|
||||
run_genfstab || return $?
|
||||
run_genfstab || return $?
|
||||
|
||||
# in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional)
|
||||
config_hostname_and_hosts || return $?
|
||||
# in: USERNAME, USER_PWD, ROOT_PWD (optional)
|
||||
user_and_pwd || return $?
|
||||
user_and_pwd || return $?
|
||||
|
||||
gen_initramfs || return $?
|
||||
mkinitcpio -P || return $?
|
||||
# in: TARGET_BLOCK_DEVICE, LUKS_PART_UUID
|
||||
bootloader || return $?
|
||||
|
||||
umount -R /mnt || return $?
|
||||
cryptsetup luksClose "$(basename "${DATA_PART}")" || return $?
|
||||
echo "Finished installation without errors!"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -7,6 +7,14 @@
|
||||
# -n, --noheadings
|
||||
# -x, --sort column
|
||||
|
||||
function get_uuid() {
|
||||
# arg $1: partition
|
||||
# arg $2: variable name to store UUID
|
||||
|
||||
local -n ptr=$2 || return $?
|
||||
ptr="$(blkid -o value -s UUID "${1}")" || return $?
|
||||
}
|
||||
|
||||
function get_partitions(){
|
||||
# arg $1: block-device
|
||||
# @post
|
||||
@ -14,7 +22,7 @@ function get_partitions(){
|
||||
|
||||
# Remove first line of output (which is just the block device $1 itself)
|
||||
# with sed: sed 1d
|
||||
PARTITIONS="$(lsblk -pln -o name "$1" | sed 1d)" || return $?
|
||||
PARTITIONS="$(lsblk -pln -o name "${1}" | sed 1d)" || return $?
|
||||
|
||||
newline_separated_to_array PARTITIONS PARTITIONS || return $?
|
||||
}
|
||||
@ -110,6 +118,7 @@ function format() {
|
||||
# LUKS_PWD
|
||||
# FS
|
||||
# @post
|
||||
# LUKS_PART_UUID
|
||||
# DATA_PART (variable set with value /dev/mapper/$(basename "${LUKS_PART}")
|
||||
# boot partition formatted
|
||||
# luks partition formatted and opened at DATA_PART
|
||||
@ -129,6 +138,8 @@ function format() {
|
||||
--cipher aes-xts-plain64 --key-size 512 --hash sha512 \
|
||||
--iter-time 10000 --use-random "${LUKS_PART}" || return $?
|
||||
|
||||
get_uuid "${LUKS_PART}" LUKS_PART_UUID || return $?
|
||||
|
||||
local luks_name
|
||||
luks_name=$(basename "${LUKS_PART}")
|
||||
DATA_PART="/dev/mapper/${luks_name}"
|
||||
|
@ -2,14 +2,17 @@
|
||||
pre_install() {
|
||||
# Check if system is SSE4.2 capable
|
||||
# lscpu is part of util-linux which is a dependency of mkinitcpio
|
||||
lscpu | grep sse4_2 >/dev/null 2>&1
|
||||
if ! lscpu | grep sse4_2 >/dev/null 2>&1; then
|
||||
echo "Warning: mkinitcpio.conf has module 'crc32c_intel' enabled but this system is not SSE4.2 capable!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## arg 1: the new package version
|
||||
post_install() {
|
||||
holo apply
|
||||
if ! mkinitcpio -P; then
|
||||
echo "The previous error can be ignored on initial system installation. One should however execute 'mkinitcpio -P' after the kernel was installed.";
|
||||
echo "Failed to generate initramfs. Please run 'mkinitcpio -P' manually. (This is normal during initial system installation).";
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
@ -18,11 +21,17 @@ post_install() {
|
||||
## arg 2: the old package version
|
||||
post_upgrade() {
|
||||
holo apply
|
||||
mkinitcpio -P
|
||||
if ! mkinitcpio -P; then
|
||||
echo "Failed to generate initramfs."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## arg 1: the old package version
|
||||
post_remove() {
|
||||
holo apply
|
||||
mkinitcpio -P
|
||||
if ! mkinitcpio -P; then
|
||||
echo "Failed to generate initramfs."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
_pkgname=mkinitcpio
|
||||
_reponame=arch
|
||||
pkgname="de-p1st-$_pkgname"
|
||||
pkgver=0.0.3
|
||||
pkgver=0.0.4
|
||||
pkgrel=1
|
||||
pkgdesc="mkinitcpio configuration"
|
||||
arch=('any')
|
||||
|
@ -9,7 +9,7 @@ Special thanks to nachoparker for his article:
|
||||
Install `de-p1st-repo` on your local machine as well as on
|
||||
a remote server.
|
||||
|
||||
Adjust `/etc/de-p1st-repo/arch-repo.conf` according to your needs.
|
||||
Adjust [/etc/de-p1st-repo/arch-repo.conf](arch-repo.cfg) according to your needs.
|
||||
|
||||
Run a webserver on the server to serve static content:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user