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