Bug 37759

Summary: RFE: version.h: kernel spec should pay more attention
Product: [Retired] Red Hat Linux Reporter: giulioo
Component: kernelAssignee: Arjan van de Ven <arjanv>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: low    
Version: 7.0Keywords: FutureFeature
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-04-26 10:24:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description giulioo 2001-04-26 10:23:59 UTC
The problem described here can now be easily solved by editing the spec, 
but it would be nice if you consider this issue next time you'll redesign 
part of the kernel spec, so that this would be taken care of automatically.

Problem:
At the top of the spec file there are %define's to include various kind of 
kernels in the rpm build: smp, BOOT, enterprise, ....
I usually set all of them to off, to build just the "normal" up kernel.

You use this "trick" to build the version.h
===
echo "#include <linux/rhconfig.h>" >> version.h
keyword=if
for i in smp BOOT BOOTsmp enterprise up; do
    verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
    if [ -n "$verh" -a -f "$verh" ]; then
   if [ "$i" = up ]; then
       echo "#else" >> version.h
   else
       echo "#$keyword defined(__module__$i)" >> version.h
       keyword=elif
   fi
   grep UTS_RELEASE $verh >> version.h
   fi
done
echo "#endif" >> version.h
===

Guess what happens if you build the rpm with just the up kernel... :)
You end up with a version.h like

===
#include <linux/rhconfig.h>
#else
#define UTS_RELEASE "x.x.x"
#endif
#define LINUX_VERSION_CODE 131600
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
===

Maybe, since rhconfig.h defines __module__up, you could take out the up 
particular case and use something like this (not tested), which should 
always produce a correct version.h. If you want to maintain a catch-all 
rule you could add it after "done", before "#endif".

===
echo "#include <linux/rhconfig.h>" >> version.h
keyword=if
for i in smp BOOT BOOTsmp enterprise up; do
	verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print 
$1 } '`
	if [ -n "$verh" -a -f "$verh" ]; then
		echo "#$keyword defined(__module__$i)" >> version.h
		keyword=elif
		grep UTS_RELEASE $verh >> version.h
	fi
done
echo "#endif" >> version.h
===

Comment 1 Arjan van de Ven 2001-04-26 10:44:29 UTC
fixed; thanks for the report.