[augeas-devel] augeas: master - Grub: add support for Debian's update-grub (ticket #50)
David Lutterkort
lutter at fedoraproject.org
Fri Mar 27 23:28:59 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=8f7b100caa504bf87946de3e3a0da7b04ed1ceb8
Commit: 8f7b100caa504bf87946de3e3a0da7b04ed1ceb8
Parent: 8e1f1fb649be15f27878347c40f953a655af2088
Author: Raphael Pinson <raphink at gmail.com>
AuthorDate: Wed Mar 25 16:39:45 2009 -0700
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Mar 25 16:39:45 2009 -0700
Grub: add support for Debian's update-grub (ticket #50)
Bug reported by Micah Anderson
---
lenses/grub.aug | 53 ++++++++++++++++++++++++++++++++++---
lenses/tests/test_grub.aug | 61 ++++++++++++++++++++++++++------------------
2 files changed, 84 insertions(+), 30 deletions(-)
diff --git a/lenses/grub.aug b/lenses/grub.aug
index aca6528..b9c7dce 100644
--- a/lenses/grub.aug
+++ b/lenses/grub.aug
@@ -5,9 +5,9 @@ module Grub =
(* expanded to cover more (and more esoteric) directives *)
(* It is good enough to handle the grub.conf on my Fedora 8 box *)
- let value_to_eol = store /[^= \t][^\n]*/
- let eol = Util.del_str "\n"
- let del_to_eol = del /[^\n]*/ ""
+ let value_to_eol = store /[^= \t\n][^\n]*[^= \t\n]|[^= \t\n]/
+ let eol = Util.eol
+ let del_to_eol = del /[^ \t\n]*/ ""
let opt_ws = Util.del_opt_ws ""
let value_sep (dflt:string) = del /[ \t]*[ \t=][ \t]*/ dflt
@@ -60,13 +60,56 @@ module Grub =
| kw_boot_arg "initrd"
| kw_boot_arg "rootnoverify"
| kw_boot_arg "chainloader"
+ | kw_boot_arg "uuid"
| kw_pres "quiet" (* Seems to be a Ubuntu extension *)
| kw_pres "savedefault"
| module_lines
let boot = [ label "title" . title . boot_setting* ]
- let comment = [ del /(#.*|[ \t]*)\n/ "#\n" ]
+ let comment_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+ - "# ## Start Default Options ##"
+ - "# ## End Default Options ##"
- let lns = (comment | menu_setting | boot)*
+ let comment =
+ [ Util.indent . label "#comment" . del /#[ \t]*/ "# "
+ . store comment_re . eol ]
+ let empty = Util.empty
+
+
+ let debian_header = "## ## Start Default Options ##\n"
+ let debian_footer = "## ## End Default Options ##\n"
+ let debian_comment_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+ - "## End Default Options ##"
+ let debian_comment =
+ [ Util.indent . label "#comment" . del /##[ \t]*/ "## "
+ . store debian_comment_re . eol ]
+ let debian_value_sep = del /[ \t]*=/ "="
+ let debian_kw_arg (kw:regexp) =
+ [ Util.del_opt_ws "" . key kw . debian_value_sep
+ . value_to_eol? . eol ]
+
+ let debian_setting_re = "kopt"
+ | "groot"
+ | "alternative"
+ | "lockalternative"
+ | "defoptions"
+ | "lockold"
+ | "xenhopt"
+ | "xenkopt"
+ | "altoptions"
+ | "howmany"
+ | "memtest86"
+ | "updatedefaultentry"
+ | "savedefault"
+
+ let debian_setting = debian_kw_arg debian_setting_re
+
+ let debian_entry = del "#" "#" . debian_setting
+ let debian = [ label "debian"
+ . del debian_header debian_header
+ . (debian_comment|empty|debian_entry)*
+ . del debian_footer debian_footer ]
+
+ let lns = (comment | empty | menu_setting | boot | debian)*
let xfm = transform lns (incl "/etc/grub.conf")
diff --git a/lenses/tests/test_grub.aug b/lenses/tests/test_grub.aug
index fd1a275..4b7818f 100644
--- a/lenses/tests/test_grub.aug
+++ b/lenses/tests/test_grub.aug
@@ -34,36 +34,47 @@ title Fedora (2.6.24.3-34.fc8)
"
test Grub.lns get conf =
- {} {} {} {} {} {} {} {} {}
- { "password" = "$1$M9NLj$p2gs87vwNv48BUu.wAfVw0"
- { "md5" } }
- { "default" = "0" }
- { "timeout" = "5" }
- { "splashimage" = "(hd0,0)/grub/splash.xpm.gz" }
- { "hiddenmenu" }
- { "title" = "Fedora (2.6.24.4-64.fc8)"
- { "root" = "(hd0,0)" }
- { "kernel" = "/vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00" }
- { "initrd" = "/initrd-2.6.24.4-64.fc8.img" } }
- { "title" = "Fedora (2.6.24.3-50.fc8)"
- { "root" = "(hd0,0)" }
- { "kernel" = "/vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00" }
- { "initrd" = "/initrd-2.6.24.3-50.fc8.img" } }
- { "title" = "Fedora (2.6.21.7-3.fc8xen)"
- { "root" = "(hd0,0)" }
- { "kernel" = "/xen.gz-2.6.21.7-3.fc8" }
- { "modules" = "/vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00" }
- { "modules" = "/initrd-2.6.21.7-3.fc8xen.img" } }
- { "title" = "Fedora (2.6.24.3-34.fc8)"
- { "root" = "(hd0,0)" }
- { "kernel" = "/vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00" }
- { "initrd" = "/initrd-2.6.24.3-34.fc8.img" } }
+ { "#comment" = "grub.conf generated by anaconda" }
+ {}
+ { "#comment" = "Note that you do not have to rerun grub after making changes to this file" }
+ { "#comment" = "NOTICE: You have a /boot partition. This means that" }
+ { "#comment" = "all kernel and initrd paths are relative to /boot/, eg." }
+ { "#comment" = "root (hd0,0)" }
+ { "#comment" = "kernel /vmlinuz-version ro root=/dev/vg00/lv00" }
+ { "#comment" = "initrd /initrd-version.img" }
+ { "#comment" = "boot=/dev/sda" }
+ { "password" = "$1$M9NLj$p2gs87vwNv48BUu.wAfVw0"
+ { "md5" } }
+ { "default" = "0" }
+ { "timeout" = "5" }
+ { "splashimage" = "(hd0,0)/grub/splash.xpm.gz" }
+ { "hiddenmenu" }
+ { "title" = "Fedora (2.6.24.4-64.fc8)"
+ { "root" = "(hd0,0)" }
+ { "kernel" = "/vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00" }
+ { "initrd" = "/initrd-2.6.24.4-64.fc8.img" } }
+ { "title" = "Fedora (2.6.24.3-50.fc8)"
+ { "root" = "(hd0,0)" }
+ { "kernel" = "/vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00" }
+ { "initrd" = "/initrd-2.6.24.3-50.fc8.img" } }
+ { "title" = "Fedora (2.6.21.7-3.fc8xen)"
+ { "root" = "(hd0,0)" }
+ { "kernel" = "/xen.gz-2.6.21.7-3.fc8" }
+ { "modules" = "/vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00" }
+ { "modules" = "/initrd-2.6.21.7-3.fc8xen.img" } }
+ { "title" = "Fedora (2.6.24.3-34.fc8)"
+ { "root" = "(hd0,0)" }
+ { "kernel" = "/vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00" }
+ { "initrd" = "/initrd-2.6.24.3-34.fc8.img" } }
test Grub.lns put conf after set "default" "0" = conf
test Grub.lns get "# menu.lst - See: grub(8), info grub, update-grub(8)
-## default num\n" = {} {} {}
+## default num\n" =
+ { "#comment" = "menu.lst - See: grub(8), info grub, update-grub(8)" }
+ {}
+ { "#comment" = "# default num" }
(* Color directive *)
test Grub.lns get "color cyan/blue white/blue\n" =
More information about the augeas-devel
mailing list