Does anyone know of a python parser for grub2's grub.cfg file?
I'm trying to get the "menuentry" by device partition (root), e.g.
hd0,msdos1: ['Ubuntu, with Linux 3.0.0-15-generic',
'Ubuntu, with Linux 3.0.0-15-generic (recovery mode)',
'Ubuntu, with Linux 3.0.0-14-generic']
hd2,msdos1: ["Windows 7 (on /dev/sdc1)"]
etc.
Solution:
re.findall("menuentry ['\"](.*?)['\"].*?set root='(.*?)'", x, re.S)
[('Ubuntu, with Linux 3.0.0-15-generic', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-15-generic (recovery mode)', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-14-generic', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-14-generic (recovery mode)', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-13-generic', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-13-generic (recovery mode)', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-12-generic', '(hd0,msdos1)'), ('Ubuntu, with Linux 3.0.0-12-generic (recovery mode)', '(hd0,msdos1)'), ('Memory test (memtest86+)', '(hd0,msdos1)'), ('Memory test (memtest86+, serial console 115200)', '(hd0,msdos1)'), ('Windows 7 (on /dev/sdc1)', '(hd2,msdos1)')]