Compare commits

...

2 Commits

Author SHA1 Message Date
7282ad8025
feat: add pacman hooks and update install script 2021-02-12 01:34:13 +01:00
1f33307608
finish rewrite 2021-02-12 01:18:56 +01:00
5 changed files with 87 additions and 13 deletions

View File

@ -1,6 +1,6 @@
#!/bin/fish
cp ./pacman/snap-pac-uki-create.fish /usr/local/bin
cp ./src/snap-pac-uki.fish /usr/local/bin/snap-pac-uki
echo "installed creation script."
cp ./pacman/hooks/* /usr/share/libalpm/hooks/
cp ./pacman/* /usr/share/libalpm/hooks/
echo "installed pacman hooks."

View File

@ -0,0 +1,12 @@
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Performing pre UKI creation...
When = PreTransaction
Exec = /usr/local/bin/snap-pac-uki snapshots
AbortOnFail

View File

@ -0,0 +1,11 @@
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Performing post UKI creation...
When = PostTransaction
Exec = /usr/local/bin/snap-pac-uki snapshots

View File

@ -0,0 +1,11 @@
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Performing post UKI creation...
When = PostTransaction
Exec = /usr/local/bin/snap-pac-uki current

View File

@ -70,13 +70,7 @@ function create_uki -d "creates a new uki" -a variant id
--add-section .splash="$prefix/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
--add-section .linux="$prefix/boot/vmlinuz-linux" --change-section-vma .linux=0x2000000 \
--add-section .initrd="$prefix/boot/initramfs-linux$fallback.img" --change-section-vma .initrd=0x3000000 \
"$prefix/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bp/arch-linux$fallback$snid.efi"
end
function add_efi_entry -d "adds an efi boot entry for a snapshot uki" -a id
efibootmgr -q -C -d $CFG_EFI_DEV -p $CFG_EFI_PART \
-l "$EFI_PATH\arch-linux-$id.efi" \
-L "Arch Linux (Snapshot $id)"
"$prefix/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "$bd/arch-linux$fallback$snid.efi"
end
function create_snapshot_uki -d "creates an uki for a snapshot" -a id
@ -87,16 +81,43 @@ function create_snapshot_uki -d "creates an uki for a snapshot" -a id
else if test -d $bd
rm -rf "$bd/*"
else
mkdir $bd
mkdir -p $bd
end
# prepare files
sed "s/BUILD_ID=.*/BUILD_ID=\"snapshot $id\"/;s/PRETTY_NAME=\"\(.*\)\"/PRETTY_NAME=\"\1 (Snapshot $id)\"" <"$CFG_SNAPSHOT_PATH/$id/snapshot/usr/lib/os-release" >"$bd/os-release"
sed "s/SNAPSHOT/$CFG_SNAPSHOT_SUBVOL/" <"$CFG_SNAPSHOT_PATH/$id/snapshot/etc/snap-pac-uki/kernel-cmd" >"$bd/kernel-cmd"
sed "s/BUILD_ID=.*/BUILD_ID=\"snapshot $id\"/;s/PRETTY_NAME=\"\(.*\)\"/PRETTY_NAME=\"\1 (Snapshot $id)\"/" <"$CFG_SNAPSHOT_PATH/$id/snapshot/usr/lib/os-release" >"$bd/os-release"
sed "s/SNAPSHOT/$CFG_SNAPSHOT_SUBVOL\/$id\/snapshot/" <"$CFG_SNAPSHOT_PATH/$id/snapshot/etc/snap-pac-uki/kernel-cmd" >"$bd/kernel-cmd"
# create uki
create_uki snapshot $id
add_efi_entry $id
end
function create_current_uki -d "creates an uki for the current system"
# create build directory
set bd "$CFG_BUILD_DIR/current"
if test -f $bd
error "build dir for snapshot $id is a file"
else if test -d $bd
rm -rf "$bd/*"
else
mkdir -p $bd
end
# create default
cp "/usr/lib/os-release" "$bd/os-release"
sed "s/SNAPSHOT/$CFG_DEFAULT_SUBVOL/" <"/etc/snap-pac-uki/kernel-cmd" >"$bd/kernel-cmd"
create_uki rolling
# create fallbac
sed "s/BUILD_ID=.*/BUILD_ID=fallback/;s/PRETTY_NAME=\"\(.*\)\"/PRETTY_NAME=\"\1 (Fallback)\"/" <"/usr/lib/os-release" >"$bd/os-release-fallback"
sed "s/SNAPSHOT/$CFG_DEFAULT_SUBVOL/" <"/etc/snap-pac-uki/kernel-cmd-fallback" >"$bd/kernel-cmd-fallback"
create_uki fallback
end
function add_efi_entry -d "adds an efi boot entry for a snapshot uki" -a id
efibootmgr -q -C -d $CFG_EFI_DEV -p $CFG_EFI_PART \
-l "$CFG_EFI_PATH\arch-linux-$id.efi" \
-L "Arch Linux (Snapshot $id)"
end
function main
@ -108,9 +129,28 @@ function main
case "snapshots"
find_tasks
for id in $TASK_UKI
echo "==> found snapshot without uki: $id"
create_snapshot_uki $id
echo " -> created uki for snapshot $id"
cp "$CFG_BUILD_DIR/$id/arch-linux-$id.efi" "$CFG_UKI_DIR"
echo " -> copied uki for snapshot $id into uki directory"
add_efi_entry $id
echo " -> created efi boot entry for uki of snapshot $id"
end
case "current"
echo "==> creating current ukis"
create_current_uki
echo " -> created ukis"
cp "$CFG_BUILD_DIR/current/arch-linux.efi" "$CFG_UKI_DIR"
cp "$CFG_BUILD_DIR/current/arch-linux-fallback.efi" "$CFG_UKI_DIR"
echo " -> copied ukis into uki directory"
case "*"
error "unknown command"
end