#!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__