Skip to content

Commit

Permalink
Fix PXEGrub2 with vanilia GRUB2 (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
sathieu authored and lzap committed Feb 1, 2017
1 parent 200709d commit 0b9fe03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions manifests/tftp.pp
Expand Up @@ -32,8 +32,8 @@
}
'Debian': {
$grub_type = 'debian'
# taken from https://anonscm.debian.org/cgit/pkg-grub/grub.git/tree/debian/build-efi-images
$grub_modules = 'all_video boot btrfs cat chain configfile echo efifwsetup efinet ext2 fat font gettext gfxmenu gfxterm gfxterm_background gzio halt hfsplus iso9660 jpeg keystatus loadenv linux lsefi lsefimmap lsefisystab lssal memdisk minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test true video zfs zfscrypt zfsinfo linuxefi lvm mdraid09 mdraid1x raid5rec raid6rec tftp'
# taken from https://anonscm.debian.org/cgit/pkg-grub/grub.git/tree/debian/build-efi-images + regexp
$grub_modules = 'all_video boot btrfs cat chain configfile echo efifwsetup efinet ext2 fat font gettext gfxmenu gfxterm gfxterm_background gzio halt hfsplus iso9660 jpeg keystatus loadenv linux lsefi lsefimmap lsefisystab lssal memdisk minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test true video zfs zfscrypt zfsinfo linuxefi lvm mdraid09 mdraid1x raid5rec raid6rec tftp regexp'
}
default: {
warning("Unable to detect EFI loader for OS family '${::osfamily}'")
Expand Down Expand Up @@ -97,7 +97,7 @@

exec {'build-grub2-efi-image':
command => "/usr/bin/grub-mkimage -O x86_64-efi -d ${efi_dir} -o ${foreman_proxy::tftp_root}/grub2/grubx64.efi -p '' ${grub_modules}",
creates => "${foreman_proxy::tftp_root}/grub2/grubx64.efi",
unless => "/bin/grep -q regexp '${foreman_proxy::tftp_root}/grub2/grubx64.efi'",
require => [File[$foreman_proxy::tftp_dirs], Package['grub-common','grub-efi-amd64-bin']],
} ->
file {"${foreman_proxy::tftp_root}/grub2/grubx64.efi":
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/foreman_proxy__config__spec.rb
Expand Up @@ -301,7 +301,7 @@

it 'should generate efi image from grub2 modules for Debian' do
should contain_exec('build-grub2-efi-image').
with_creates("#{tftp_root}/grub2/grubx64.efi")
with_unless("/bin/grep -q regexp '#{tftp_root}/grub2/grubx64.efi'")
should contain_file("#{tftp_root}/grub2/grubx64.efi").
with_mode('0644').
with_owner('root').
Expand Down
8 changes: 8 additions & 0 deletions templates/grub.cfg.erb
@@ -0,0 +1,8 @@
insmod regexp

set net_pxe_mac=$net_default_mac
regexp --set=1:m1 --set=2:m2 --set=3:m3 --set=4:m4 --set=5:m5 --set=6:m6 '^([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})' "$net_default_mac"
mac_dashed=${m1}-${m2}-${m3}-${m4}-${m5}-${m6}

mac_configfile=$prefix/grub.cfg-01-$mac_dashed
source "$mac_configfile"

0 comments on commit 0b9fe03

Please sign in to comment.