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