1 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
3 # increment this if you have made a change that should force a new kernel
6 #BUILD_GEN=2 # bz19952: remove -lustre tag from kernel RPM names
7 BUILD_GEN=3 # bz19975 enable the building of src.rpms by default
9 DEVEL_KERNEL_TYPE="devel"
10 RPM_HELPERS_DIR="/usr/lib/rpm/redhat"
12 prepare_and_build_srpm() {
14 pushd $TOPDIR >/dev/null
16 read GCC_VER < <($CC --version)
17 GCC_VER=${GCC_VER##* }
18 if [[ $GCC_VER = 4.3* ]]; then
19 # add the gcc 4.3 kernel build fix patch to it
20 cat <<"EOF" >> $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
21 diff -urp linux-2.6.18.rawops/Makefile linux-2.6.18.races/Makefile
22 --- linux-2.6.18.rawops/Makefile 2007-02-08 19:00:31.000000000 +0200
23 +++ linux-2.6.18.rawops/Makefile 2007-02-14 19:23:49.000000000 +0200
24 @@ -506,6 +506,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
25 # disable pointer signed / unsigned warnings in gcc 4.0
26 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
28 +# workaround to avoid gcc 4.3 emitting libgcc calls (see gcc bug #32044)
29 +CFLAGS += $(call cc-option,-fno-tree-scev-cprop,)
31 # Default kernel image to build when no specific target is given.
32 # KBUILD_IMAGE may be overruled on the command line or
33 # set in the environment
38 local buildid="_lustre${EXTRA_VERSION##*_lustre}"
40 # edit the SPEC with our changes
41 sed -i -e 's/^\(%define signmodules \).*/\10/' \
42 -e "s/^#% \(define buildid\).*/%\1 ${buildid}/" \
43 -e '/-e $RPM_SOURCE_DIR\/kabi_whitelist_/i\
44 rm -f $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
45 -e '/_sourcedir\/kabitool -b \./a\
46 cp $RPM_BUILD_ROOT/kabi_whitelist $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
47 -e '/^# empty final patch file to facilitate testing of kernel patches/i\
48 # adds Lustre patches\
49 Patch99995: linux-%{kversion}-lustre.patch' \
50 -e '/^# conditionally applied test patch for debugging convenience/i\
54 -e '/^%prep$/,/^# END OF PATCH APPLICATIONS$/s/kernel-%{kversion}/%{name}-%{kversion}/g' \
55 -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
56 cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3 \
57 cp -a fs/ext4/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4' \
58 SPECS/kernel-2.6.spec 2>&1 || \
59 fatal 1 "Error while editing SPECS/kernel-2.6.spec"
61 if $KERNEL_LUSTRE_NAMING; then
62 # these are all of the changes needed because we change the package names
63 # to kernel-lustre-*. these should all go away when we stop this insanity
64 sed -i -e 's/^\(Name:.*kernel\)/\1-lustre/' \
65 -e '/^Provides: glibc-kernheaders = /a\
66 Provides: kernel-headers = %{rpmversion}-%{release}
67 Obsoletes: kernel-headers
69 -e '/^Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
70 Provides: kernel = %{rpmversion}-%{release}
72 -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
73 Provides: kernel-devel = %{rpmversion}-%{release}
74 Obsoletes: kernel-devel
76 -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
77 Provides: kernel-debuginfo-common = %{KVERREL}
78 Obsoletes: kernel-debuginfo-common
80 -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
81 Provides: kernel-debuginfo = %{KVERREL}
82 Obsoletes: kernel-debuginfo
84 SPECS/kernel-2.6.sp 2>&1 || \
85 fatal 1 "Error while editing SPECS/kernel-2.6.spec"ec
88 # XXX - a building-on-Ubuntu hack
89 if grep -q "Ubuntu" /etc/issue; then
90 sed -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
91 -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
92 -e 's/sha512hmac/md5sum/g' \
93 SPECS/kernel-2.6.spec 2>&1 || \
94 fatal 1 "Error while editing SPECS/kernel-2.6.spec"
97 # finally, work around RH bug 491775, if needed
98 if ! grep -q "cp -a asm-x86_64 \$RPM_BUILD_ROOT/lib/modules/\$KernelVer/build/include" \
99 SPECS/kernel-2.6.spec; then
100 # XXX - i wonder if we will need to do this ad-hoc patching enough to
101 # formalize a patching system. let's assume not for the time
103 patch -s -p0 <<"EOF" 2>&1 || \
104 fatal 1 "Error while patching SPECS/kernel-2.6.spec"
105 --- SPECS/kernel-2.6.spec.dist 2009-03-23 20:30:55.000000000 -0400
106 +++ SPECS/kernel-2.6.spec 2009-03-23 20:37:03.000000000 -0400
107 @@ -6961,6 +6961,10 @@
109 cp -a acpi config keys linux math-emu media mtd net pcmcia rdma rxrpc scsi sound video asm asm-generic $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
110 cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
111 + if [ "$Arch" = "i386" ]; then
112 + mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
113 + cp -a asm-x86_64/{stacktrace,k8,pci-direct}.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
115 if [ "$Arch" = "x86_64" ]; then
116 cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
123 # this concept of being able to build a list of targets with a single
124 # lbuild is a fine idea, but in reality I think it's (very) broken. I
125 # don't even think the lustre.spec can handle being called with "--target
126 # <multiple arches>". It certainly can't handle the issue where each
127 # arch has it's own kernel location.
128 # but we will do the best we can and put the plumbing in place so that
129 # this could work when the other broken bits are fixed.
130 # in reality, our current use of lbuild only ever has a single arch in
134 for arch in $BUILD_ARCHS; do
135 # XXX - ok. so here's a hack that needs to be fixed properly
136 # ppc64 was merged to ppc some time ago pre 2.6.18
137 if [ $arch = ppc64 ]; then
140 targets="--target $arch $targets"
141 # copy our .config into the RPM build tree
142 (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
143 SOURCES/kernel-2.6.18-$arch.config
145 # XXX - hackity hack -- until we get (or generate from the base
146 # config) configs for xen and debug
148 for f in SOURCES/kernel-${lnxmaj}-*.config; do
149 grep -q "^CONFIG_SD_IOSTATS=y" $f || \
150 echo "CONFIG_SD_IOSTATS=y" >> $f
154 # do we need any special rpm build options
155 local rpmbuildopt="-bb"
159 # stupid Ubuntu's rpm doesn't do debuginfo properly
160 if [ ! -f /usr/lib/rpm/debugedit ]; then
161 rpmbuildopt="$rpmbuildopt --without debuginfo"
164 # XXX - need to figure this kabichk crap out -- it fails the build
165 rpmbuildopt="$rpmbuildopt --without kabichk"
168 if ! $RPMBUILD $rpmbuildopt $targets --with baseonly \
169 --define "_topdir $TOPDIR" \
170 $TOPDIR/SPECS/kernel-2.6.spec 2>&1; then
178 devel_kernel_name() {
179 local lustre=${1:-false}
182 echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
184 echo "kernel-$DEVEL_KERNEL_TYPE"
189 rpm_BUILD_kernel_dirname() {
190 local rpmsmptype="$1"
196 if $KERNEL_LUSTRE_NAMING; then
199 echo kernel${lustre}${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
202 find_linux_devel_paths() {
204 local ARCH=$TARGET_ARCH
206 # If DEVEL_PATH_ARCH is set, use it. Added for fc11 as it needs i586 string for i686.
207 if [ $DEVEL_PATH_ARCH ];then
208 ARCH=$DEVEL_PATH_ARCH
211 LINUX=$path/usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}${ARCH}
212 # RHEL doesn't have the -obj tree
214 # XXX - i don't think we need this any more
215 #LINUXRELEASE=$(find_linux_release "$LINUX")
216 #if [ -z "$LINUXRELEASE" ]; then
217 # echo "Failed to find linux release in $LINUX"
224 unpack_linux_devel_rpm-rhel5() {
225 local callers_rpm="$1"
227 # now just sanity check that everything needed to build properly versioned
228 # modules is in place
229 if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}-$TARGET_ARCH/Module.symvers ]; then
230 fatal 1 "cannot build kernel modules: the Kernel's Module.symvers is missing."
233 if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}-$TARGET_ARCH/symsets-${lnxmaj}${lnxmin}-${lnxrel}.tar.gz ]; then
234 fatal 1 "cannot build modules: the Kernel's symsets is missing."