diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-05-11 14:00:57 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-10-30 09:52:23 +0100 |
commit | 168f1d46569e796423f6a86cb1917b0d8cd06b8c (patch) | |
tree | 8d38108a93d0a9becd20f2a4dffd59432b2f35ff /.config/pacman/bin | |
parent | ad97641241bbcaaedabab7af1392a2706da0a776 (diff) |
[pacman] add hook for linux-lts-versioned-bin update
to create unversioned lts entries in /boot
Diffstat (limited to '.config/pacman/bin')
-rwxr-xr-x | .config/pacman/bin/linux-lts-versioned-bin-hook | 30 |
1 files changed, 30 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) |