fix: 🐛 create ukis with appropriate configuration
This commit is contained in:
parent
79a7067f58
commit
3c018e29ed
@ -23,12 +23,13 @@ function load_config -d "loads the config from a config file" -a cfg
|
|||||||
set -g EFI_DIR "/efi/EFI/Linux/"
|
set -g EFI_DIR "/efi/EFI/Linux/"
|
||||||
set -g SNAPPER_CONFIG "root"
|
set -g SNAPPER_CONFIG "root"
|
||||||
set -g SNAPSHOT_SUBVOL "@snapshots"
|
set -g SNAPSHOT_SUBVOL "@snapshots"
|
||||||
|
set -g ROOT_SUBVOL "@"
|
||||||
|
|
||||||
# load file
|
# load file
|
||||||
set -l cfg (jq -c <$cfg)
|
set -l cfg (jq -c <$cfg)
|
||||||
|
|
||||||
# parse config
|
# parse config
|
||||||
set -l cfgs "build_path" "efi_dir" "kernel_cmd" "fallback_cmd" "snapper_config" "snapshot_subvol"
|
set -l cfgs "build_path" "efi_dir" "kernel_cmd" "fallback_cmd" "snapper_config" "snapshot_subvol" "root_subvol"
|
||||||
for c in $cfgs
|
for c in $cfgs
|
||||||
echo $cfg | jq -e ".$c" >/dev/null
|
echo $cfg | jq -e ".$c" >/dev/null
|
||||||
|
|
||||||
@ -55,17 +56,21 @@ function get_last_snapshot -d "reads the last snapper snapshot id"
|
|||||||
set -g SNAPSHOT_ID (snapper -c $SNAPPER_CONFIG --jsonout ls | jq ".$SNAPPER_CONFIG | last | .number")
|
set -g SNAPSHOT_ID (snapper -c $SNAPPER_CONFIG --jsonout ls | jq ".$SNAPPER_CONFIG | last | .number")
|
||||||
end
|
end
|
||||||
|
|
||||||
function create_uki -d "creates a new uki" -a fallback
|
function create_uki -d "creates a new uki"
|
||||||
# prepare directory
|
# prepare directory
|
||||||
set -l bp "$BUILD_PATH/$SNAPSHOT_ID"
|
set -l bp "$BUILD_PATH/$SNAPSHOT_ID"
|
||||||
mkdir -p $bp
|
mkdir -p $bp
|
||||||
rm -rf "$bp/*"
|
rm -rf "$bp/*"
|
||||||
|
|
||||||
# os-release
|
# os-release
|
||||||
sed "s/BUILD_ID=.*/BUILD_ID=\"Snapshot $SNAPSHOT_ID\"/" </usr/lib/os-release >"$bp/os-release"
|
cp /usr/lib/os-release "$bp/os-release"
|
||||||
|
sed "s/BUILD_ID=.*/BUILD_ID=\"fallback\"/" </usr/lib/os-release >"$bp/os-release-fallback"
|
||||||
|
sed "s/BUILD_ID=.*/BUILD_ID=\"snapshot $SNAPSHOT_ID\"/" </usr/lib/os-release >"$bp/os-release-snapshot"
|
||||||
|
|
||||||
# kernel cmd
|
# kernel cmd
|
||||||
echo $KERNEL_CMD | sed "s/SNAPSHOT/$SNAPSHOT_SUBVOL\\/$SNAPSHOT_ID\\/snapshot/" >"$bp/kernel-cmd"
|
echo $KERNEL_CMD | sed "s/SNAPSHOT/$ROOT_SUBVOL/" >"$bp/kernel-cmd"
|
||||||
|
echo $FALLBACK_CMD | sed "s/SNAPSHOT/$ROOT_SUBVOL/" >"$bp/kernel-cmd-fallback"
|
||||||
|
echo $KERNEL_CMD | sed "s/SNAPSHOT/$SNAPSHOT_SUBVOL\\/$SNAPSHOT_ID\\/snapshot/" >"$bp/kernel-cmd-snapshot"
|
||||||
|
|
||||||
# create uki
|
# create uki
|
||||||
objcopy \
|
objcopy \
|
||||||
@ -73,17 +78,22 @@ function create_uki -d "creates a new uki" -a fallback
|
|||||||
--add-section .cmdline="$bp/kernel-cmd" --change-section-vma .cmdline=0x30000 \
|
--add-section .cmdline="$bp/kernel-cmd" --change-section-vma .cmdline=0x30000 \
|
||||||
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
|
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
|
||||||
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
|
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
|
||||||
--add-section .initrd="/boot/initramfs-linux$fallback.img" --change-section-vma .initrd=0x3000000 \
|
--add-section .initrd="/boot/initramfs-linux.img" --change-section-vma .initrd=0x3000000 \
|
||||||
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bp/arch-linux-$SNAPSHOT_ID$fallback.efi"
|
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bp/arch-linux.efi"
|
||||||
end
|
objcopy \
|
||||||
|
--add-section .osrel="$bp/os-release-fallback" --change-section-vma .osrel=0x20000 \
|
||||||
function copy_current -d "copies new ukis to efi"
|
--add-section .cmdline="$bp/kernel-cmd-fallback" --change-section-vma .cmdline=0x30000 \
|
||||||
# copy to "current"
|
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
|
||||||
cp "$BUILD_PATH/$SNAPSHOT_ID/arch-linux-$SNAPSHOT_ID.efi" "$EFI_DIR/arch-linux-current.efi"
|
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
|
||||||
cp "$BUILD_PATH/$SNAPSHOT_ID/arch-linux-$SNAPSHOT_ID-fallback.efi" "$EFI_DIR/arch-linux-fallback.efi"
|
--add-section .initrd="/boot/initramfs-linux-fallback.img" --change-section-vma .initrd=0x3000000 \
|
||||||
|
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bp/arch-linux-fallback.efi"
|
||||||
# copy to "snapshots"
|
objcopy \
|
||||||
cp "$BUILD_PATH/$SNAPSHOT_ID/arch-linux-$SNAPSHOT_ID.efi" $EFI_DIR
|
--add-section .osrel="$bp/os-release-snapshot" --change-section-vma .osrel=0x20000 \
|
||||||
|
--add-section .cmdline="$bp/kernel-cmd-snapshot" --change-section-vma .cmdline=0x30000 \
|
||||||
|
--add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
|
||||||
|
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
|
||||||
|
--add-section .initrd="/boot/initramfs-linux.img" --change-section-vma .initrd=0x3000000 \
|
||||||
|
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bp/arch-linux-$SNAPSHOT_ID.efi"
|
||||||
end
|
end
|
||||||
|
|
||||||
function main -d "the main function"
|
function main -d "the main function"
|
||||||
@ -92,9 +102,8 @@ function main -d "the main function"
|
|||||||
|
|
||||||
get_last_snapshot
|
get_last_snapshot
|
||||||
create_uki
|
create_uki
|
||||||
create_uki "-fallback"
|
|
||||||
|
|
||||||
copy_current
|
cp "$BUILD_PATH/$SNAPSHOT_ID/*.efi" "$EFI_DIR"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user