Whamcloud - gitweb
525a665c33490ff658a381fceb9eda14df0a323a
[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 '/-e $RPM_SOURCE_DIR\/kabi_whitelist_/i\
38     rm -f $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
39            -e '/_sourcedir\/kabitool -b \./a\
40     cp $RPM_BUILD_ROOT/kabi_whitelist $RPM_SOURCE_DIR/kabi_whitelist_%{_target_cpu}$Flavour' \
41            -e '/^# empty final patch file to facilitate testing of kernel patches/i\
42 # adds Lustre patches\
43 Patch99995: linux-%{kversion}-lustre.patch' \
44            -e '/^# conditionally applied test patch for debugging convenience/i\
45 # lustre patch\
46 %patch99995 -p1\
47 ' \
48            -e '/^%prep$/,/^# END OF PATCH APPLICATIONS$/s/kernel-%{kversion}/%{name}-%{kversion}/g' \
49            -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
50     cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3' \
51            -e '/^Provides: glibc-kernheaders = /a\
52 Provides: kernel-headers = %{rpmversion}-%{release}
53 ' \
54            -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
55 Provides: kernel-devel = %{rpmversion}-%{release}
56 ' \
57            -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
58 Provides: kernel-debuginfo-common = %{KVERREL}
59 ' \
60            -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
61 Provides: kernel-debuginfo = %{KVERREL}
62 ' \
63           SPECS/kernel-2.6.spec
64
65     # XXX - a building-on-Ubuntu hack
66     if grep -q "Ubuntu" /etc/issue; then
67         sed  -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
68                -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
69           SPECS/kernel-2.6.spec
70     fi
71
72     # finally, work around RH bug 491775
73     # XXX - i wonder if we will need to do this enough to formalize a
74     #       patching system.  let's assume not for the time being.
75     patch -s -p0 <<"EOF"
76 --- SPECS/kernel-2.6.spec.dist  2009-03-23 20:30:55.000000000 -0400
77 +++ SPECS/kernel-2.6.spec       2009-03-23 20:37:03.000000000 -0400
78 @@ -6961,6 +6961,10 @@
79      cd include
80      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
81      cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
82 +    if [ "$Arch" = "i386" ]; then
83 +      mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
84 +      cp -a asm-x86_64/{stacktrace,k8,pci-direct}.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
85 +    fi
86      if [ "$Arch" = "x86_64" ]; then
87        cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
88      fi
89 EOF
90
91     popd >/dev/null
92
93     # this concept of being able to build a list of targets with a single
94     # lbuild is a fine idea, but in reality I think it's (very) broken.  I
95     # don't even think the lustre.spec can handle being called with "--target
96     # <multiple arches>".  It certainly can't handle the issue where each
97     # arch has it's own kernel location.
98     # but we will do the best we can and put the plumbing in place so that
99     # this could work when the other broken bits are fixed.
100     # in reality, our current use of lbuild only ever has a single arch in
101     # $BUILD_ARCHS
102     local arch
103     local targets=""
104     for arch in $BUILD_ARCHS; do
105         # XXX - ok.  so here's a hack that needs to be fixed properly
106         #       ppc64 was merged to ppc some time ago pre 2.6.18
107         if [ $arch = ppc64 ]; then
108             arch=ppc
109         fi
110         targets="--target $arch $targets"
111         # copy our .config into the RPM build tree
112         (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
113             SOURCES/kernel-2.6.18-$arch.config
114
115         # XXX - hackity hack -- until we get (or generate from the base
116         #                       config) configs for xen and debug
117         local f=""
118         for f in SOURCES/kernel-${lnxmaj}-*.config; do
119             grep -q "^CONFIG_SD_IOSTATS=y" $f || \
120                 echo "CONFIG_SD_IOSTATS=y" >> $f
121         done
122     done
123
124     # do we need any special rpm build options
125     local rpmbuildopt="-bb"
126     if $DO_SRC; then
127         rpmbuildopt="-ba"
128     fi
129     # stupid Ubuntu's rpm doesn't do debuginfo properly
130     if [ ! -f /usr/lib/rpm/debugedit ]; then
131         rpmbuildopt="$rpmbuildopt --without debuginfo"
132     fi
133
134     # XXX - need to figure this kabichk crap out -- it fails the build
135     rpmbuildopt="$rpmbuildopt --without kabichk"
136
137     # now build it
138     if ! $RPMBUILD $rpmbuildopt $targets --with baseonly \
139                    --define "_topdir $TOPDIR" \
140                    $TOPDIR/SPECS/kernel-2.6.spec >&2; then
141         fatal 1 "Failed to build kernel RPM"
142     fi
143
144 }
145
146 devel_kernel_name() {
147     local lustre=${1:-false}
148
149     if $lustre; then
150         echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
151     else
152         echo "kernel-$DEVEL_KERNEL_TYPE"
153     fi
154
155 }
156
157 rpm_BUILD_kernel_dirname() {
158     local rpmsmptype="$1"
159     local lnxmaj="$2"
160     local lnxmin="$3"
161     local arch="$4"
162
163     echo kernel-lustre${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
164 }