summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-05 16:25:36 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 18:55:01 +0100
commit7bc240c0750fcffa36f5c8df234542578b20ae1f (patch)
treeca98ffab0bac1e632a138c755c4fe9318046c8fb /manifests
downloadsyslinux-7bc240c0750fcffa36f5c8df234542578b20ae1f.tar.gz
syslinux-7bc240c0750fcffa36f5c8df234542578b20ae1f.tar.xz
Setup syslinux.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp114
1 files changed, 114 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644
index 0000000..570b31c
--- /dev/null
+++ b/manifests/init.pp
@@ -0,0 +1,114 @@
+class syslinux (
+ String $kernel = 'linux',
+ String $efi_root = '/boot/efi',
+ String $bootentry = 'syslinux',
+) {
+
+ $efi_dev = $facts['mountpoints'][$efi_root]
+ if ! $efi_dev {
+ fail("A device needs to be mounted on efi_root [${efi_root}]")
+ }
+ # $efi_dev['device']
+
+ ensure_packages ([
+ $kernel,
+ mkinitcpio,
+ syslinux,
+ efibootmgr,
+ ], {
+ ensure => installed,
+ })
+
+ file { "/etc/mkinitcpio.d/${kernel}.preset":
+ ensure => file,
+ source => "puppet:///modules/${module_name}/mkinitcpio.${kernel}",
+ }
+
+ # cp -r /usr/lib/syslinux/efi64 ${efi_root}/EFI/syslinux
+
+ $device = $facts['mountpoints']['/']['device']
+ $partuuid = $facts['blkid'][$device]['PARTUUID']
+
+ file { "${efi_root}/EFI/syslinux/syslinux.cfg":
+ content => epp("${module_name}/syslinux.cfg.epp", {
+ 'default' => 'arch',
+ 'linux' => {
+ 'arch' => {
+ 'label' => 'Arch Linux',
+ 'initrd' => 'initramfs-linux.img',
+ 'args' => "root=PARTUUID=${partuuid} rw",
+ },
+ 'arch-runlevel-1' => {
+ 'label' => 'Arch Linux (Runlevel 1)',
+ 'initrd' => 'initramfs-linux.img',
+ 'args' => "root=PARTUUID=${partuuid} rw 1",
+ },
+ 'archfallback' => {
+ 'label' => 'Arch Linux fallback',
+ 'initrd' => 'initramfs-linux-fallback.img',
+ 'args' => "root=PARTUUID=${partuuid} rw",
+ }
+ },
+ 'com32' => {
+ 'hdt' => {
+ 'label' => 'HDT (Hardware Detection Tool)',
+ 'com' => 'hdt',
+ },
+ 'reboot' => {
+ 'label' => 'Reboot',
+ 'com' => 'reboot',
+ },
+ 'poweroff' => {
+ 'label' => 'Poweroff',
+ 'com' => 'poweroff',
+ }
+
+ }
+ })
+ }
+
+ file { "${efi_root}/EFI/arch":
+ ensure => directory,
+ }
+
+ $has_syslinux = $facts['efi']['boots'].any |$_, $value| {
+ $value == $bootentry
+ }
+
+ $partition = $facts['partinfo'][basename($efi_dev['device'])]
+
+ if ! $has_syslinux {
+ $efi_device = $partition['device']
+ $partid = $partition['partid']
+ exec { "efibootmgr --disk '/dev/${efi_device}' --part ${partid} --create --label '${bootentry}' --loader /EFI/syslinux/syslinux.efi":
+ path => [ '/usr/bin', '/bin', ],
+ }
+ }
+
+ file { '/usr/libexec':
+ ensure => directory,
+ }
+
+ file { '/usr/libexec/move-kernel':
+ ensure => file,
+ mode => '0555',
+ content => @("EOF"/$)
+ #!/bin/sh
+ IFS='\n' read data
+ cp "/\$data" "${efi_root}/EFI/arch/vmlinuz-${kernel}"
+ | EOF
+ }
+
+ pacman::hook { 'install-kernel':
+ priority => 60, # something less than /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
+ trigger => {
+ type => 'Path',
+ operation => [ 'Install', 'Upgrade' ],
+ target => [ 'usr/lib/modules/*/vmlinuz', ],
+ },
+ description => 'Moving kernel to EFI',
+ when => 'PostTransaction',
+ exec => '/usr/libexec/move-kernel',
+ needsTargets => true ,
+ }
+}