#!perl
# sysl2grub.pl -- Convert syslinux config file to grub-l config file.
# This tool attempts to convert syslinux (isolinux etc) config file to
# grub-l config file. The conversion is not fully automated, you need
# to edit the resulting file afterwards. In particular, you may want
# to add a "default" and "timeout" declaration.
# I use this on Debian live disks.
use warnings; use 5.010; use strict;
no warnings "uninitialized";
our %r;
sub out {
if (my $l = delete $r{label}) {
print $l;
} elsif ($r{id}) {
warn "warning: missing menu title, inventing one";
print "title $r{id}\n";
}
if (my $i = delete $r{id}) {
print "# syslinux label $i\n";
}
print delete $r{early};
if (my $k = delete $r{kernel}) {
print $k . delete($r{append}) . "\n";
}
print delete $r{initrd};
print delete $r{other};
if (%r) {
warn "internal warning: unused fields (" . join(" ", keys %r) . ")";
}
}
while (<>) {
if (/^\s*label\s+(.*)/i) {
out();
%r = ();
$r{id} = $1;
} elsif (/^\s*menu\s+label\s+(.*)/i) {
$r{label} and warn "warning: second menu label line, ignoring first ($r{id}) ($r{label})";
$r{label} = "title $1\n";
} elsif (/^\s*(kernel\s+.*)/i) {
$r{kernel} and warn "warning: second kernel line, ignoring first ($r{id}) ($r{kernel})";
$r{kernel} = $1;
} elsif (/^\s*append(\s+.*)/i) {
my $a = $1;
while ($a =~ s/\sinitrd=(\S+)//) {
$r{initrd} and warn "warning: second initrd param, ignoring first ($r{id}) ($r{initrd})";
$r{initrd} = "initrd $1\n";
}
$r{append} .= $a;
} else {
($r{kernel} ? $r{other} : $r{early}) .= $_;
}
}
eof or warn "warning: error reading input file: $!";
out();
__END__
####
label live
menu label Live
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live config quiet
label livefailsafe
menu label Live (failsafe)
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live config noapic noapm nodma nomce nolapic nomodeset nosmp vga=normal
label live-686
menu label Live 686
kernel /live/vmlinuz2
append initrd=/live/initrd2.img boot=live config quiet
label live-686failsafe
menu label Live 686 (failsafe)
kernel /live/vmlinuz2
append initrd=/live/initrd2.img boot=live config noapic noapm nodma nomce nolapic nomodeset nosmp vga=normal
label install
menu label Text Install
kernel /install/vmlinuz
append initrd=/install/initrd.gz vga=normal quiet
label expert
menu label Text Expert
kernel /install/vmlinuz
append initrd=/install/initrd.gz priority=low vga=normal
label rescue
menu label Text Rescue
kernel /install/vmlinuz
append initrd=/install/initrd.gz rescue/enable=true vga=normal quiet
label auto
menu label Text Auto
kernel /install/vmlinuz
append initrd=/install/initrd.gz auto=true priority=critical vga=normal quiet
label installgui
menu label GUI Install
kernel /install/gtk/vmlinuz
append initrd=/install/gtk/initrd.gz video=vesa:ywrap,mtrr vga=788 quiet
label expertgui
menu label GUI Expert
kernel /install/gtk/vmlinuz
append initrd=/install/gtk/initrd.gz priority=low video=vesa:ywrap,mtrr vga=788
label rescuegui
menu label GUI Rescue
kernel /install/gtk/vmlinuz
append initrd=/install/gtk/initrd.gz rescue/enable=true video=vesa:ywrap,mtrr vga=788 quiet
label autogui
menu label GUI Auto
kernel /install/gtk/vmlinuz
append initrd=/install/gtk/initrd.gz auto=true priority=critical video=vesa:ywrap,mtrr vga=788 quiet
label memtest
menu label Memory test
kernel /live/memtest
####
title Live
# syslinux label live
kernel /live/vmlinuz boot=live config quiet
initrd /live/initrd.img
title Live (failsafe)
# syslinux label livefailsafe
kernel /live/vmlinuz boot=live config noapic noapm nodma nomce nolapic nomodeset nosmp vga=normal
initrd /live/initrd.img
title Live 686
# syslinux label live-686
kernel /live/vmlinuz2 boot=live config quiet
initrd /live/initrd2.img
title Live 686 (failsafe)
# syslinux label live-686failsafe
kernel /live/vmlinuz2 boot=live config noapic noapm nodma nomce nolapic nomodeset nosmp vga=normal
initrd /live/initrd2.img
title Text Install
# syslinux label install
kernel /install/vmlinuz vga=normal quiet
initrd /install/initrd.gz
title Text Expert
# syslinux label expert
kernel /install/vmlinuz priority=low vga=normal
initrd /install/initrd.gz
title Text Rescue
# syslinux label rescue
kernel /install/vmlinuz rescue/enable=true vga=normal quiet
initrd /install/initrd.gz
title Text Auto
# syslinux label auto
kernel /install/vmlinuz auto=true priority=critical vga=normal quiet
initrd /install/initrd.gz
title GUI Install
# syslinux label installgui
kernel /install/gtk/vmlinuz video=vesa:ywrap,mtrr vga=788 quiet
initrd /install/gtk/initrd.gz
title GUI Expert
# syslinux label expertgui
kernel /install/gtk/vmlinuz priority=low video=vesa:ywrap,mtrr vga=788
initrd /install/gtk/initrd.gz
title GUI Rescue
# syslinux label rescuegui
kernel /install/gtk/vmlinuz rescue/enable=true video=vesa:ywrap,mtrr vga=788 quiet
initrd /install/gtk/initrd.gz
title GUI Auto
# syslinux label autogui
kernel /install/gtk/vmlinuz auto=true priority=critical video=vesa:ywrap,mtrr vga=788 quiet
initrd /install/gtk/initrd.gz
title Memory test
# syslinux label memtest
kernel /live/memtest
#label floppy
# localboot 0x00
#label disk1
# localboot 0x80
#label disk2
# localboot 0x81
#label nextboot
# localboot -1