diff options
Diffstat (limited to 'mandriva/kheader')
-rw-r--r-- | mandriva/kheader | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/mandriva/kheader b/mandriva/kheader new file mode 100644 index 00000000..d237fe20 --- /dev/null +++ b/mandriva/kheader @@ -0,0 +1,110 @@ +#!/bin/sh +# (c) Mandriva, Chmouel Boudjnah <chmouel@mandriva.com> +# $Id$ +# +# kheader: This shell script regenerate the /boot/kernel.h header for \ +# /usr/src/linux/include/{autoconf,version}.h +# +# chkconfig: 235 95 20 +# description: This shell script regenerate the /boot/kernel.h header for \ +# /usr/src/linux/include/{autoconf,version}.h +# + +. /etc/rc.d/init.d/functions + +: ${KERNEL_H:=/boot/kernel.h} +: ${HEADERFILE:=${KERNEL_H}-`uname -r`} +[ -d $(dirname $HEADERFILE) ] || exit 0 + +table() { +k=$(uname -r|sed 's/.*mdk//') +case $k in + fb) + ENT=0;FB=1;SMP=0;SECURE=0;STD=0; + ;; + smp) + ENT=0;FB=0;SMP=1;SECURE=0;STD=0; + ;; + enterprise) + ENT=1;FB=0;SMP=0;SECURE=0;STD=0; + ;; + secure) + ENT=0;FB=0;SMP=0;SECURE=1;STD=0; + ;; + *) + ENT=0;FB=0;SMP=0;SECURE=0;STD=1; + esac +} + +generate () { + table; + # do not overwrite exsisting header, it confuses + # kernel make and forces it to recompile everything + cat > $HEADERFILE.tmp << EOF +/* This file is automatically generated at boot time. */ +#ifndef __BOOT_KERNEL_H_ +#define __BOOT_KERNEL_H_ + +#ifndef __BOOT_KERNEL_SMP +#define __BOOT_KERNEL_SMP $SMP +#endif + +#ifndef __BOOT_KERNEL_FB +#define __BOOT_KERNEL_FB $FB +#endif + +#ifndef __BOOT_KERNEL_SECURE +#define __BOOT_KERNEL_SECURE $SECURE +#endif + +#ifndef __BOOT_KERNEL_ENTERPRISE +#define __BOOT_KERNEL_ENTERPRISE $ENT +#endif + +#ifndef __BOOT_KERNEL_UP +#define __BOOT_KERNEL_UP $STD +#endif + +#endif +EOF + +cmp -s $HEADERFILE $HEADERFILE.tmp || mv -f $HEADERFILE.tmp $HEADERFILE +rm -f $HEADERFILE.tmp + +if [ -f $KERNEL_H ] ; then + rm -f $KERNEL_H +fi + +ln -sf $HEADERFILE $KERNEL_H +} + +function remove_orphaned { + local version= i= + for i in /boot/kernel.h-* /boot/System.map-* /boot/config-*; do + version=${i#*-} + [[ -f /boot/vmlinuz-${version} ]] || rm -f ${i} + done +} + +case $1 in + start) + # We don't log this command, because most users don't want to hear this (c) Chmou + generate + touch /var/lock/subsys/kheader + ;; + restart) + ;; + reload) + generate + ;; + stop) + remove_orphaned; + rm -f /var/lock/subsys/kheader + ;; + status) + ;; + *) + gprintf "Usage: %s\n" "$(basename $0) {start|stop|reload|restart}" + exit 0 + ;; +esac |