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
0e50f1f
diff -Nurp grub2.orig/conf/common.rmk grub2/conf/common.rmk
0e50f1f
--- grub2.orig/conf/common.rmk	2008-08-07 21:37:16.000000000 +0200
0e50f1f
+++ grub2/conf/common.rmk	2008-08-08 07:14:01.000000000 +0200
0e50f1f
@@ -123,6 +123,12 @@ CLEANFILES += update-grub_lib
0e50f1f
 update-grub_SCRIPTS = 00_header 10_linux 10_hurd 10_windows 30_os-prober 40_custom
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
 
0e50f1f
diff -Nurp grub2.orig/util/grub.d/90_persistent.in grub2/util/grub.d/90_persistent.in
0e50f1f
--- grub2.orig/util/grub.d/90_persistent.in	1970-01-01 01:00:00.000000000 +0100
0e50f1f
+++ grub2/util/grub.d/90_persistent.in	2008-08-08 07:14:01.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}
0e50f1f
diff -Nurp grub2.orig/util/update-grub.in grub2/util/update-grub.in
0e50f1f
--- grub2.orig/util/update-grub.in	2008-08-08 07:13:41.000000000 +0200
0e50f1f
+++ grub2/util/update-grub.in	2008-08-08 07:14:01.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