0e50f1f
This adds a section to the configuration file that persists the updates,
0e50f1f
so that it's not only grub2-update itself that decides what's in the
0e50f1f
configuration.
0e50f1f
0e50f1f
Lubomir Rintel <lkundrak@v3.sk>
0e50f1f
9638b56
diff -up grub2/conf/common.rmk.persistent grub2/conf/common.rmk
9638b56
--- grub2/conf/common.rmk.persistent	2008-08-27 10:49:16.000000000 +0200
9638b56
+++ grub2/conf/common.rmk	2008-08-27 13:51:33.000000000 +0200
9638b56
@@ -138,6 +138,12 @@ endif
9638b56
 
0e50f1f
 CLEANFILES += $(update-grub_SCRIPTS)
0e50f1f
 
0e50f1f
+90_persistent: util/grub.d/90_persistent.in config.status
0e50f1f
+	./config.status --file=$@:$<
0e50f1f
+	chmod +x $@
0e50f1f
+update-grub_SCRIPTS += 90_persistent
0e50f1f
+CLEANFILES += 90_persistent
0e50f1f
+
0e50f1f
 update-grub_DATA += util/grub.d/README
0e50f1f
 
0e50f1f
 
9638b56
diff -up /dev/null grub2/util/grub.d/90_persistent.in
9638b56
--- /dev/null	2008-08-24 16:09:23.777049452 +0200
9638b56
+++ grub2/util/grub.d/90_persistent.in	2008-08-27 13:51:33.000000000 +0200
0e50f1f
@@ -0,0 +1,37 @@
0e50f1f
+#! /bin/sh -e
0e50f1f
+
0e50f1f
+# update-grub helper script.
0e50f1f
+# Copyright (C) 2008  Free Software Foundation, Inc.
0e50f1f
+#
0e50f1f
+# GRUB is free software: you can redistribute it and/or modify
0e50f1f
+# it under the terms of the GNU General Public License as published by
0e50f1f
+# the Free Software Foundation, either version 3 of the License, or
0e50f1f
+# (at your option) any later version.
0e50f1f
+#
0e50f1f
+# GRUB is distributed in the hope that it will be useful,
0e50f1f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0e50f1f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0e50f1f
+# GNU General Public License for more details.
0e50f1f
+#
0e50f1f
+# You should have received a copy of the GNU General Public License
0e50f1f
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
0e50f1f
+
0e50f1f
+# The output of this script is copied from part of grub.cfg
0e50f1f
+# that correspond to itself. The achievement is that user can
0e50f1f
+# modify that part of grub.cfg directly, and it will be persistent
0e50f1f
+# across update-grub runs.
0e50f1f
+
0e50f1f
+transform="@program_transform_name@"
0e50f1f
+
0e50f1f
+ME=$(echo $0 |sed 's,/,\\/,g')
0e50f1f
+GRUBCFG=/boot/`echo grub | sed ${transform}`/grub.cfg
0e50f1f
+
0e50f1f
+# Exit gracefully if there's no configuration file yet
0e50f1f
+[ -f ${GRUBCFG} ] || exit 0
0e50f1f
+
0e50f1f
+awk "
0e50f1f
+	BEGIN {echo = 0}
0e50f1f
+	/### BEGIN $ME ###/ {echo = 1; next}
0e50f1f
+	/### END $ME ###/ {echo = 0; next}
0e50f1f
+	{if (echo) print}
0e50f1f
+" ${GRUBCFG}
9638b56
diff -up grub2/util/update-grub.in.persistent grub2/util/update-grub.in
9638b56
--- grub2/util/update-grub.in.persistent	2008-08-27 13:51:33.000000000 +0200
9638b56
+++ grub2/util/update-grub.in	2008-08-27 13:51:33.000000000 +0200
0e50f1f
@@ -176,11 +176,12 @@ echo "Updating ${grub_cfg} ..." >&2
0e50f1f
 
0e50f1f
 cat << EOF
0e50f1f
 #
0e50f1f
-# DO NOT EDIT THIS FILE
0e50f1f
-#
0e50f1f
-# It is automatically generated by $0 using templates
0e50f1f
+# This is automatically generated by $0 using templates
0e50f1f
 # from ${update_grub_dir} and settings from ${sysconfdir}/default/grub
0e50f1f
 #
0e50f1f
+# If you want your changes to persist across updates, add them
0e50f1f
+# to 90_persistent section
0e50f1f
+#
0e50f1f
 EOF
0e50f1f
 
0e50f1f
 for i in ${update_grub_dir}/* ; do