grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] add a snapshot version string to GRUB title


From: Christian Franke
Subject: [PATCH] add a snapshot version string to GRUB title
Date: Thu, 02 Jul 2009 22:20:00 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090403 SeaMonkey/1.1.16

Many "GNU GRUB version 1.96" used in production are likely builds from more recent SVN snapshots. It would (IMO) be useful to have some info about the actual installed version.

This patch adds a script to generate some version info from ChangeLog and (if available) from SVN.

The version syntax is "PACKAGE_VERSION+DATE-N-rSVN" where DATE is the most recent date in ChangeLog and 'N' is the number of the entries for this date. If the last ChangeLog entry suggests that this is an official release, only "PACKAGE_VERSION" is used.

The current string is "1.96+20090702-1-r2391" or "1.96+20090702-1" if 'svn info' is not available.

The string is added to grub title only, utils are left out for now.


Regards,
Christian Franke


2009-07-02  Christian Franke  <address@hidden>

        Auto-generate a snapshot version string for GRUB title.

        * Makefile.in: Add targets for genversionstr.sh.
        Add target and dependency for grub_version.h.

        * configure.ac: Add genversionstr.sh to AC_CONFIG_FILES.

        * genversionstr.sh.in: New script.  Generates GRUB_VERSION
        string from ChangeLog.

        * normal/main.c: Add include "grub_version.h".
        (grub_normal_init_page): Replace PACKAGE_VERSION by
        GRUB_VERSION in TITLE.


diff --git a/Makefile.in b/Makefile.in
index 3d208e7..6b56c83 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -419,6 +419,16 @@ gensymlist.sh: gensymlist.sh.in config.status
 genkernsyms.sh: genkernsyms.sh.in config.status
        $(SHELL) ./config.status
 
+genversionstr.sh: genversionstr.sh.in config.status
+       $(SHELL) ./config.status
+
+# Build version string
+grub_version.h: genversionstr.sh ChangeLog
+       $(SHELL) ./genversionstr.sh > $@ || (rm -f $@ ; exit 1)
+
+normal_mod-normal_main.o: grub_version.h
+
+
 .PHONY: all install install-strip uninstall clean mostlyclean distclean
 .PHONY: maintainer-clean info dvi dist check
 
diff --git a/configure.ac b/configure.ac
index 8b12c58..890cf3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -529,6 +529,6 @@ else
   rm -rf include/grub/machine
   cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 
2>/dev/null
 fi
-AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
+AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh genversionstr.sh])
 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
 AC_OUTPUT
diff --git a/genversionstr.sh.in b/genversionstr.sh.in
new file mode 100644
index 0000000..6e58fb3
--- /dev/null
+++ b/genversionstr.sh.in
@@ -0,0 +1,77 @@
+#! /bin/sh
+#
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This genversionstr.sh.in is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+### The configure script will replace these variables.
+
address@hidden@
+
+
+cat <<EOF
+/* This file is automatically generated by genversionstr.sh. DO NOT EDIT! */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+EOF
+
+
+if sed -n '2,/^20/p' $srcdir/ChangeLog \
+   | grep 'configure.ac (AC_INIT): Bumped' >/dev/null 2>/dev/null
+then
+  # Last entry documents new PACKAGE_VERSION, assume official release
+
+  cat <<EOF
+#ifndef GRUB_VERSION
+  #define GRUB_VERSION PACKAGE_VERSION
+#endif
+EOF
+
+else
+  # Extract most recent date string from ChangeLog.
+  # Append number of log entries for this date.
+  datestr=`
+    sed -n 's,^\(20[0-9][0-9]-[01][0-9]-[0-3][0-9]\) .*$,\1,p;1000q' 
$srcdir/ChangeLog \
+    | uniq -c \
+    | sed -n 's,^ *\([0-9][0-9]*\) 
\(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$,+\2\3\4-\1,p;1q'
+  `
+
+  # get SVN revision if possible
+  svnstr=
+  if [ -d $srcdir/.svn ] ; then
+    svnstr=`
+      ( cd $srcdir && svn info ) 2> /dev/null \
+      | sed -n 's,^Revision: *\(.*\)$,-r\1,p'
+    `
+  fi
+
+  cat <<EOF
+#ifndef GRUB_VERSION
+  #define GRUB_VERSION PACKAGE_VERSION "${datestr}${svnstr}"
+#endif
+EOF
+fi
+
diff --git a/normal/main.c b/normal/main.c
index 7f6336e..a412827 100644
--- a/normal/main.c
+++ b/normal/main.c
@@ -29,6 +29,8 @@
 #include <grub/reader.h>
 #include <grub/menu_viewer.h>
 
+#include "grub_version.h"
+
 #define GRUB_DEFAULT_HISTORY_SIZE      50
 
 /* Read a line from the file FILE.  */
@@ -375,7 +377,7 @@ grub_normal_init_page (void)
 {
   grub_uint8_t width, margin;
 
-#define TITLE ("GNU GRUB  version " PACKAGE_VERSION)
+#define TITLE ("GNU GRUB  version " GRUB_VERSION)
 
   width = grub_getwh () >> 8;
   margin = (width - (sizeof(TITLE) + 7)) / 2;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]