summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.config/pacman/bin/linux-lts-versioned-bin-hook30
-rw-r--r--.config/pacman/hooks/linux-lts-versioned-bin.hook11
-rwxr-xr-x.config/yadm/bootstrap11
3 files changed, 52 insertions, 0 deletions
diff --git a/.config/pacman/bin/linux-lts-versioned-bin-hook b/.config/pacman/bin/linux-lts-versioned-bin-hook
new file mode 100755
index 0000000..ebb9b01
--- /dev/null
+++ b/.config/pacman/bin/linux-lts-versioned-bin-hook
@@ -0,0 +1,30 @@
+#! /usr/bin/python
+
+import sys, os, re
+
+boot_dir = '/boot'
+
+lts_vm_files = list(
+ filter(
+ re.compile(r'vmlinuz-([\d\.\-]+)-lts$').match,
+ os.listdir(boot_dir)
+ )
+)
+
+if not lts_vm_files:
+ print(f'No versioned kernel files found in {boot_dir}')
+ sys.exit(1)
+
+highest_lts_version_file = lts_vm_files[-1]
+version_name = re.search(r'vmlinuz-([\d\.\-]+)-lts$', highest_lts_version_file).group(1)
+
+symlink_map = {
+ f'{boot_dir}/initramfs-{version_name}-lts.img': f'{boot_dir}/initramfs-linux-lts.img',
+ f'{boot_dir}/initramfs-{version_name}-lts-fallback.img': f'{boot_dir}/initramfs-linux-lts-fallback.img',
+ f'{boot_dir}/vmlinuz-{version_name}-lts': f'{boot_dir}/vmlinuz-linux-lts',
+}
+for src, dst in symlink_map.items():
+ os.path.islink(dst) and os.unlink(dst)
+ os.symlink(src, dst)
+
+sys.exit(0)
diff --git a/.config/pacman/hooks/linux-lts-versioned-bin.hook b/.config/pacman/hooks/linux-lts-versioned-bin.hook
new file mode 100644
index 0000000..c9fa4fd
--- /dev/null
+++ b/.config/pacman/hooks/linux-lts-versioned-bin.hook
@@ -0,0 +1,11 @@
+[Trigger]
+Operation = Install
+Operation = Upgrade
+Operation = Remove
+Type = File
+Target = usr/lib/modules/*/vmlinuz
+
+[Action]
+Description = Symlinking newest versioned lts kernel...
+When = PostTransaction
+Exec = /usr/local/bin/linux-lts-versioned-bin-hook
diff --git a/.config/yadm/bootstrap b/.config/yadm/bootstrap
index 6ca05e9..06e079f 100755
--- a/.config/yadm/bootstrap
+++ b/.config/yadm/bootstrap
@@ -45,3 +45,14 @@ if command -v fcitx5 > /dev/null 2>&1; then
sudo ln -s "$HOME/.config/fcitx5/systemd/fcitx5-user.timer" /etc/systemd/user/
systemctl --user enable 'fcitx5-user.timer' --now
fi
+
+
+# #
+# pacman
+# #
+
+# linux-lts-versioned-bin
+if [ ! -f "/usr/share/libalpm/hooks/linux-lts-versioned-bin.hook" ]; then
+ sudo ln -s "$HOME/.config/pacman/hooks/linux-lts-versioned-bin.hook" /usr/share/libalpm/hooks/linux-lts-versioned-bin.hook
+ sudo ln -s "$HOME/.config/pacman/bin/linux-lts-versioned-bin-hook" /usr/local/bin/linux-lts-versioned-bin-hook
+fi