Whamcloud - gitweb
b=16424
[fs/lustre-release.git] / build / lbuild-rhel5
1 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
2
3 # increment this if you have made a change that should force a new kernel
4 # to build built
5 BUILD_GEN=1
6
7 DEVEL_KERNEL_TYPE="devel"
8
9 prepare_and_build_srpm() {
10
11     pushd $TOPDIR >/dev/null
12     local GCC_VER=""
13     read GCC_VER < <($CC --version)
14     GCC_VER=${GCC_VER##* }
15     if [[ $GCC_VER = 4.3* ]]; then
16         # add the gcc 4.3 kernel build fix patch to it
17         cat <<"EOF" >> $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
18 diff -urp linux-2.6.18.rawops/Makefile linux-2.6.18.races/Makefile
19 --- linux-2.6.18.rawops/Makefile        2007-02-08 19:00:31.000000000 +0200
20 +++ linux-2.6.18.rawops/Makefile        2007-02-14 19:23:49.000000000 +0200
21 @@ -506,6 +506,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
22  # disable pointer signed / unsigned warnings in gcc 4.0
23  CFLAGS += $(call cc-option,-Wno-pointer-sign,)
24
25 +# workaround to avoid gcc 4.3 emitting libgcc calls (see gcc bug #32044)
26 +CFLAGS += $(call cc-option,-fno-tree-scev-cprop,)
27 +
28  # Default kernel image to build when no specific target is given.
29  # KBUILD_IMAGE may be overruled on the command line or
30  # set in the environment
31 EOF
32     fi
33
34     # create the buildid
35     local buildid="_lustre${EXTRA_VERSION##*_lustre}"
36
37     # edit the SPEC with our changes
38     sed -i -e 's/^\(%define signmodules \).*/\10/' \
39            -e "s/^#% \(define buildid\).*/%\1 ${buildid}/" \
40            -e 's/^\(Name:.*kernel\)/\1-lustre/' \
41            -e '/-e $RPM_SOURCE_DIR\/kabi_whitelist_/i\
42     rm -f $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
43            -e '/_sourcedir\/kabitool -b \./a\
44     cp $RPM_BUILD_ROOT/kabi_whitelist $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
45            -e '/^# empty final patch file to facilitate testing of kernel patches/i\
46 # adds Lustre patches\
47 Patch99995: linux-%{kversion}-lustre.patch' \
48            -e '/^# conditionally applied test patch for debugging convenience/i\
49 # lustre patch\
50 %patch99995 -p1\
51 ' \
52            -e '/^%prep$/,/^# END OF PATCH APPLICATIONS$/s/kernel-%{kversion}/%{name}-%{kversion}/g' \
53            -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
54     cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3' \
55            -e '/^Provides: glibc-kernheaders = /a\
56 Provides: kernel-headers = %{rpmversion}-%{release}
57 ' \
58            -e '/^Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
59 Provides: kernel = %{rpmversion}-%{release}
60 ' \
61            -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
62 Provides: kernel-devel = %{rpmversion}-%{release}
63 ' \
64            -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
65 Provides: kernel-debuginfo-common = %{KVERREL}
66 ' \
67            -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
68 Provides: kernel-debuginfo = %{KVERREL}
69 ' \
70           SPECS/kernel-2.6.spec
71
72     # XXX - a building-on-Ubuntu hack
73     if grep -q "Ubuntu" /etc/issue; then
74         sed  -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
75                -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
76           SPECS/kernel-2.6.spec
77     fi
78
79     # finally, work around RH bug 491775
80     # XXX - i wonder if we will need to do this enough to formalize a
81     #       patching system.  let's assume not for the time being.
82     patch -s -p0 <<"EOF"
83 --- SPECS/kernel-2.6.spec.dist  2009-03-23 20:30:55.000000000 -0400
84 +++ SPECS/kernel-2.6.spec       2009-03-23 20:37:03.000000000 -0400
85 @@ -6961,6 +6961,10 @@
86      cd include
87      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
88      cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
89 +    if [ "$Arch" = "i386" ]; then
90 +      mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
91 +      cp -a asm-x86_64/{stacktrace,k8,pci-direct}.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
92 +    fi
93      if [ "$Arch" = "x86_64" ]; then
94        cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
95      fi
96 EOF
97
98     popd >/dev/null
99
100     # this concept of being able to build a list of targets with a single
101     # lbuild is a fine idea, but in reality I think it's (very) broken.  I
102     # don't even think the lustre.spec can handle being called with "--target
103     # <multiple arches>".  It certainly can't handle the issue where each
104     # arch has it's own kernel location.
105     # but we will do the best we can and put the plumbing in place so that
106     # this could work when the other broken bits are fixed.
107     # in reality, our current use of lbuild only ever has a single arch in
108     # $BUILD_ARCHS
109     local arch
110     local targets=""
111     for arch in $BUILD_ARCHS; do
112         # XXX - ok.  so here's a hack that needs to be fixed properly
113         #       ppc64 was merged to ppc some time ago pre 2.6.18
114         if [ $arch = ppc64 ]; then
115             arch=ppc
116         fi
117         targets="--target $arch $targets"
118         # copy our .config into the RPM build tree
119         (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
120             SOURCES/kernel-2.6.18-$arch.config
121
122         # XXX - hackity hack -- until we get (or generate from the base
123         #                       config) configs for xen and debug
124         local f=""
125         for f in SOURCES/kernel-${lnxmaj}-*.config; do
126             grep -q "^CONFIG_SD_IOSTATS=y" $f || \
127                 echo "CONFIG_SD_IOSTATS=y" >> $f
128         done
129     done
130
131     # do we need any special rpm build options
132     local rpmbuildopt="-bb"
133     if $DO_SRC; then
134         rpmbuildopt="-ba"
135     fi
136     # stupid Ubuntu's rpm doesn't do debuginfo properly
137     if [ ! -f /usr/lib/rpm/debugedit ]; then
138         rpmbuildopt="$rpmbuildopt --without debuginfo"
139     fi
140
141     # XXX - need to figure this kabichk crap out -- it fails the build
142     rpmbuildopt="$rpmbuildopt --without kabichk"
143
144     # now build it
145     if ! $RPMBUILD $rpmbuildopt $targets --with baseonly \
146                    --define "_topdir $TOPDIR" \
147                    $TOPDIR/SPECS/kernel-2.6.spec >&2; then
148         fatal 1 "Failed to build kernel RPM"
149     fi
150
151 }
152
153 devel_kernel_name() {
154     local lustre=${1:-false}
155
156     if $lustre; then
157         echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
158     else
159         echo "kernel-$DEVEL_KERNEL_TYPE"
160     fi
161
162 }
163
164 rpm_BUILD_kernel_dirname() {
165     local rpmsmptype="$1"
166     local lnxmaj="$2"
167     local lnxmin="$3"
168     local arch="$4"
169
170     echo kernel-lustre${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
171 }