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