1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
Multiple flavours of the same kernel version
======== ======== == === ==== ====== =======
NOTE: THIS IS NOW OBSOLETE. Use the append_to_version flag instead
There is an expressed need from people to have several
alternative flavors of a single kernel version around. It is
certainly useful to have a backup flavour of a kernel version around
when one is experimenting with device driver variations (it may not
be possible to run a different version of a kernel and hence have
that as a backup).
Unfortunately, this is more complicated than it initially
appears, since the presence of possibly incompatible modules has to
be addressed.
Firstly, the modules from different flavours have to be
installed in separate directories, the modutils have to be made aware
of this alternative directory, and also, the kernel (and klogd)
should be able to load the right set of symbols from a System.map
file (which are different enough in different flavours that klogd
refuses to load the wrong one).
The proper way to address this may well be to modify the
kernel version in some fashion (Note: this would involve modifying
the kernel source's top level Makefile). Unfortunately, SUBLEVEL
needs to stay numeric (and under 255, as far as I can tell), so it is
a wee bit more complex than just modifying the SUBLEVEL variable.
The solution seems to be to add a FLAVOUR field to the end of
UTS_RELEASE, which uname then reads properly. As of 2.1.47, this
variable is used purely for output purposes (nothing seems to parse
it). Oh, please note that the FLAVOUR field needs be all lowercase to
meet Debian policy; and the packaging tools may reject the kernel
image package unless the resulting package name is all lower case
(and the kernel image name is going to be kernel-image-VERSION-FLAVOUR).
This way, the user has to modify the kernel Makefile (an sample
patch is provided below) to read, say, "FLAVOUR := speed_hack", and
the kernel would be installed as /boot/vmlinuz-2.0.30-speed_hack, the
modules would be installed under /lib/modules/2.0.30-speed_hack,
uname -r would report the version as 2.0.30-speed_hack. Note: Debian
users should keep the Flavour lower case, in order to comply with
Debian package naming conventions.
There is a patch appended to the bottom of this message that
would allow klogd to discover the new System.map file, and to not
choke on the non-numeric kernel version.
This effort has been based on the ideas and work of Bill
Mitchell <mitchell@mozcom.com> and Noel Maddy <ncm@biostat.hfh.edu>.
The following patch works for newer 2.2 kernels (please note
that the patch may not apply cleanly, but the intent should surely be
clear). This should be used as a guideline; we are adding a new
variable, and adding it to the tail end of KERNELRELEASE. (Make sure
that the MODLIB accomodates the Flavour, or else the installed kernel
shall not be able to see its modules).
======================================================================
--- Makefile.~1~ Wed Apr 28 14:38:52 1999
+++ Makefile Fri May 14 14:18:50 1999
@@ -5,2 +5,13 @@
+# FLAVOUR is like EXTRAVERSION, but it's meant for local use, and the
+# dash between it and the rest of the version is supplied here. It's used
+# by make-kpkg's --flavour switch, see /usr/share/doc/kernel-package/Flavours.
+#FLAVOUR =
+
+ifneq ($(strip $(FLAVOUR)),)
+INT_FLAV := +$(FLAVOUR)
+else
+INT_FLAV :=
+endif
+
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
@@ -61,3 +72,3 @@
-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(INT_FLAV)
======================================================================
The patch provided below is from the sources for 2.4.2
kernel, and may not apply cleanly on other versions of the kernel. It is
recommended that you use it purely as a guideline.
======================================================================
diff -Naur linux-2.4.2.orig/Documentation/kbuild/makefiles.txt linux-2.4.2/Documentation/kbuild/makefiles.txt
--- linux-2.4.2.orig/Documentation/kbuild/makefiles.txt Wed Feb 14 00:13:42 2001
+++ linux-2.4.2/Documentation/kbuild/makefiles.txt Wed Feb 28 09:59:30 2001
@@ -127,7 +127,7 @@
The top Makefile exports the following variables:
- VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
+ VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION, FLAVOUR
These variables define the current kernel version. A few arch
Makefiles actually use these values directly; they should use
@@ -140,6 +140,9 @@
$(EXTRAVERSION) defines an even tinier sublevel for pre-patches
or additional patches. It is usually some non-numeric string
such as "-pre4", and is often blank.
+
+ $(FLAVOR) can be locally set to enable multiple installation
+ of a kernel with the same version number, without modules clashing.
KERNELRELEASE
diff -Naur linux-2.4.2.orig/Makefile linux-2.4.2/Makefile
--- linux-2.4.2.orig/Makefile Thu Feb 22 02:54:15 2001
+++ linux-2.4.2/Makefile Wed Feb 28 09:59:51 2001
@@ -3,7 +3,10 @@
SUBLEVEL = 2
EXTRAVERSION =
-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+ifdef FLAVOUR
+ INT_FLAVOUR:=+$(FLAVOUR)
+endif
+KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(INT_FLAVOUR)
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
diff -Naur linux-2.4.2.orig/arch/arm/boot/Makefile linux-2.4.2/arch/arm/boot/Makefile
--- linux-2.4.2.orig/arch/arm/boot/Makefile Fri Feb 9 02:32:44 2001
+++ linux-2.4.2/arch/arm/boot/Makefile Wed Feb 28 09:45:36 2001
@@ -129,10 +129,10 @@
@test "$(INITRD)" != "" || (echo You must specify INITRD; exit -1)
install: $(CONFIGURE) Image
- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"
+ sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"
zinstall: $(CONFIGURE) zImage
- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"
+ sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"
clean:
$(RM) Image zImage bootpImage
diff -Naur linux-2.4.2.orig/scripts/Menuconfig linux-2.4.2/scripts/Menuconfig
--- linux-2.4.2.orig/scripts/Menuconfig Sun Oct 8 19:30:40 2000
+++ linux-2.4.2/scripts/Menuconfig Wed Feb 28 09:46:05 2001
@@ -1372,7 +1372,7 @@
DIALOG="./scripts/lxdialog/lxdialog"
-kernel_version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
+kernel_version="${KERNELRELEASE}"
backtitle="Linux Kernel v$kernel_version Configuration"
======================================================================
The patch provided below is from the Makefile for 2.1.47
kernel, and may not apply cleanly on other Makefiles. It is
recommended that you use it purely as a guideline, and modify the
Makefile manually.
======================================================================
--- Makefile.dist Mon Aug 4 12:18:57 1997
+++ Makefile Mon Aug 4 12:24:55 1997
@@ -2,6 +2,22 @@
PATCHLEVEL = 1
SUBLEVEL = 47
+# This is an example only: Uncomment the FLAVOUR line below and name
+# this flavour.
+#
+# If you want to have more than one kernel configuration per kernel
+# version, set FLAVOUR -- it will be appended to UTS_RELEASE in
+# version.h (separated by a hyphen)
+#
+#FLAVOUR = speed_hack
+
+ifneq ($(strip $(FLAVOUR)),)
+INT_FLAV := +$(FLAVOUR)
+else
+INT_FLAV :=
+endif
+
+
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)
#
@@ -244,7 +260,7 @@
@mv -f .ver $@
include/linux/version.h: ./Makefile
- @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > .ver
+ @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(INT_FLAV)\" > .ver
@echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver
@mv -f .ver $@
@@ -289,7 +305,7 @@
modules_install:
@( \
- MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \
+ MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(INT_FLAV); \
cd modules; \
MODULES=""; \
inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \
______________________________________________________________________
______________________________________________________________________
From: Yann Dirson <ydirson@a2points.com>
Ah, there still were some minor corrections to do. Here's my final
version (compiled fine with glibc 2.0.6, but had to replace
<sys/module.h> with <linux/module.h> in ksym_mod.c).
kern.log now says:
====
Mar 24 11:18:52 bylbo kernel: klogd 1.3-3, log source = /proc/kmsg started.
Mar 24 11:18:53 bylbo kernel: Loaded 2589 symbols from /boot/System.map-2.0.33-std.
Mar 24 11:18:53 bylbo kernel: Symbols match kernel version 2.0.33-std.
====
====
--- ksym.c.orig Mon Mar 23 23:23:03 1998
+++ ksym.c Tue Mar 24 11:18:09 1998
@@ -105,7 +105,7 @@
static int num_syms = 0;
static int i_am_paranoid = 0;
-static char vstring[12];
+static char vstring[65]; /* see /usr/include/linux/utsname.h */
static struct sym_table *sym_array = (struct sym_table *) 0;
static char *system_maps[] =
@@ -438,7 +438,7 @@
{
- auto int vnum,
+ auto int vnum, kvnum,
major,
minor,
patch;
@@ -458,42 +458,41 @@
/*
- * Since the symbol looks like a kernel version we can start
- * things out by decoding the version string into its component
- * parts.
+ * Get the numeric code from the system map.
*/
vnum = atoi(version + strlen(prefix));
- major = vnum / 65536;
- vnum -= (major * 65536);
- minor = vnum / 256;
- patch = vnum - (minor * 256);
- if ( debugging )
- fprintf(stderr, "Version string = %s, Major = %d, " \
- "Minor = %d, Patch = %d.\n", version +
- strlen(prefix), major, minor, \
- patch);
- sprintf(vstring, "%d.%d.%d", major, minor, patch);
/*
- * We should now have the version string in the vstring variable in
- * the same format that it is stored in by the kernel. We now
- * ask the kernel for its version information and compare the two
- * values to determine if our system map matches the kernel
- * version level.
+ * We now ask the kernel for its version information and
+ * compare the two values to determine if our system map
+ * matches the kernel version level.
*/
if ( uname(&utsname) < 0 )
{
Syslog(LOG_ERR, "Cannot get kernel version information.");
return(0);
}
+
+ if ( sscanf (utsname.release, "%d.%d.%d", &major, &minor, &patch) < 3 )
+ {
+ Syslog(LOG_ERR, "Kernel send bogus release string `%s'.",
+ utsname.release);
+ return(0);
+ }
+
+ /* Compute the version code from data sent by the kernel */
+ kvnum = (major << 16) | (minor << 8) | patch;
+
if ( debugging )
- fprintf(stderr, "Comparing kernel %s with symbol table %s.\n",\
- utsname.release, vstring);
+ fprintf(stderr, "Comparing kernel %s with symbol table 0x%6x.\n",\
+ utsname.release, vnum);
/* Failure. */
- if ( strcmp(vstring, utsname.release) != 0 )
+ if ( vnum != kvnum )
return(-1);
+ strcpy (vstring, utsname.release);
+
/* Success. */
return(1);
}
====
______________________________________________________________________
Old solution; that does not work cleanly:
One can edit /etc/init.d/syslogd (or however you start klogd)
like so (this is from the Debian init.d directory)
----------------------------------------------------------------------
# Use KLOGD="-k /boot/System.map-$(uname -r)" to specify System.map
#
KLOGD="-k /boot/System.map-$(uname -r)"
....
.... /sbin/klogd $KLOGD
----------------------------------------------------------------------
|