Whamcloud - gitweb
b=20339
[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 #BUILD_GEN=2    # bz19952: remove -lustre tag from kernel RPM names
7 BUILD_GEN=3     # bz19975 enable the building of src.rpms by default
8
9 DEVEL_KERNEL_TYPE="devel"
10
11 prepare_and_build_srpm() {
12
13     pushd $TOPDIR >/dev/null
14     local GCC_VER=""
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,)
26
27 +# workaround to avoid gcc 4.3 emitting libgcc calls (see gcc bug #32044)
28 +CFLAGS += $(call cc-option,-fno-tree-scev-cprop,)
29 +
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
33 EOF
34     fi
35
36     # create the buildid
37     local buildid="_lustre${EXTRA_VERSION##*_lustre}"
38
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\
50 # lustre patch\
51 %patch99995 -p1\
52 ' \
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
58
59     if $KERNEL_LUSTRE_NAMING; then
60         # these are all of the changes needed because we change the package names
61         # to kernel-lustre-*.  these should all go away when we stop this insanity
62         sed -i -e 's/^\(Name:.*kernel\)/\1-lustre/' \
63                -e '/^Provides: glibc-kernheaders = /a\
64 Provides: kernel-headers = %{rpmversion}-%{release}
65 Obsoletes: kernel-headers
66 ' \
67                -e '/^Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
68 Provides: kernel = %{rpmversion}-%{release}
69 ' \
70                -e '/^Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}$/a\
71 Provides: kernel-devel = %{rpmversion}-%{release}
72 Obsoletes: kernel-devel
73 ' \
74                -e '/^Provides: %{name}-debuginfo-common-%{_target_cpu} = %{KVERREL}$/a\
75 Provides: kernel-debuginfo-common = %{KVERREL}
76 Obsoletes: kernel-debuginfo-common
77 ' \
78                -e '/^Provides: %{name}-debuginfo-%{_target_cpu} = %{KVERREL}$/a\
79 Provides: kernel-debuginfo = %{KVERREL}
80 Obsoletes: kernel-debuginfo
81 ' \
82               SPECS/kernel-2.6.spec
83     fi
84
85     # XXX - a building-on-Ubuntu hack
86     if grep -q "Ubuntu" /etc/issue; then
87         sed  -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
88                -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
89           SPECS/kernel-2.6.spec
90     fi
91
92     # finally, work around RH bug 491775
93     # XXX - i wonder if we will need to do this enough to formalize a
94     #       patching system.  let's assume not for the time being.
95     patch -s -p0 <<"EOF"
96 --- SPECS/kernel-2.6.spec.dist  2009-03-23 20:30:55.000000000 -0400
97 +++ SPECS/kernel-2.6.spec       2009-03-23 20:37:03.000000000 -0400
98 @@ -6961,6 +6961,10 @@
99      cd include
100      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
101      cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
102 +    if [ "$Arch" = "i386" ]; then
103 +      mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
104 +      cp -a asm-x86_64/{stacktrace,k8,pci-direct}.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/asm-x86_64
105 +    fi
106      if [ "$Arch" = "x86_64" ]; then
107        cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
108      fi
109 EOF
110
111     popd >/dev/null
112
113     # this concept of being able to build a list of targets with a single
114     # lbuild is a fine idea, but in reality I think it's (very) broken.  I
115     # don't even think the lustre.spec can handle being called with "--target
116     # <multiple arches>".  It certainly can't handle the issue where each
117     # arch has it's own kernel location.
118     # but we will do the best we can and put the plumbing in place so that
119     # this could work when the other broken bits are fixed.
120     # in reality, our current use of lbuild only ever has a single arch in
121     # $BUILD_ARCHS
122     local arch
123     local targets=""
124     for arch in $BUILD_ARCHS; do
125         # XXX - ok.  so here's a hack that needs to be fixed properly
126         #       ppc64 was merged to ppc some time ago pre 2.6.18
127         if [ $arch = ppc64 ]; then
128             arch=ppc
129         fi
130         targets="--target $arch $targets"
131         # copy our .config into the RPM build tree
132         (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
133             SOURCES/kernel-2.6.18-$arch.config
134
135         # XXX - hackity hack -- until we get (or generate from the base
136         #                       config) configs for xen and debug
137         local f=""
138         for f in SOURCES/kernel-${lnxmaj}-*.config; do
139             grep -q "^CONFIG_SD_IOSTATS=y" $f || \
140                 echo "CONFIG_SD_IOSTATS=y" >> $f
141         done
142     done
143
144     # do we need any special rpm build options
145     local rpmbuildopt="-bb"
146     if $DO_SRC; then
147         rpmbuildopt="-ba"
148     fi
149     # stupid Ubuntu's rpm doesn't do debuginfo properly
150     if [ ! -f /usr/lib/rpm/debugedit ]; then
151         rpmbuildopt="$rpmbuildopt --without debuginfo"
152     fi
153
154     # XXX - need to figure this kabichk crap out -- it fails the build
155     rpmbuildopt="$rpmbuildopt --without kabichk"
156
157     # now build it
158     if ! $RPMBUILD $rpmbuildopt $targets --with baseonly \
159                    --define "_topdir $TOPDIR" \
160                    $TOPDIR/SPECS/kernel-2.6.spec >&2; then
161         fatal 1 "Failed to build kernel RPM"
162     fi
163
164 }
165
166 devel_kernel_name() {
167     local lustre=${1:-false}
168
169     if $lustre; then
170         echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
171     else
172         echo "kernel-$DEVEL_KERNEL_TYPE"
173     fi
174
175 }
176
177 rpm_BUILD_kernel_dirname() {
178     local rpmsmptype="$1"
179     local lnxmaj="$2"
180     local lnxmin="$3"
181     local arch="$4"
182
183     local lustre=""
184     if $KERNEL_LUSTRE_NAMING; then
185         $lustre="-lustre"
186     fi
187     echo kernel${lustre}${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
188 }