1 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
3 # increment this if you have made a change that should force a new kernel
4 # to build built for all releases of this distribution (only -- if you want
5 # to force a kernel build on all distributions, update the BUILD_GEN variable
8 #BUILD_GEN+=".1" # refactor both rhel5 and rhel6
9 #BUILD_GEN+=".0" # TT-107: don't cache the BUILD dir (reset major to 5)
10 BUILD_GEN+=".2" # LU-9850
12 DEVEL_KERNEL_TYPE="devel"
13 RPM_HELPERS_DIR="/usr/lib/rpm/redhat"
15 # a method which can be overriden by the release specific code
22 # patching common to all releases
25 sed -i -e '/Provides: kernel-uname-r =/a\
26 Provides: kernel-lustre = %{KVRA}%{?1:.%{1}}\\' \
27 -e '/Provides: kernel-devel-uname-r =/a\
28 Provides: kernel-devel-lustre = %{KVRA}%{?1:.%{1}}\\' \
29 -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
30 cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3 \
31 cp -a fs/ext4/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4' \
32 SPECS/$SPEC_NAME 2>&1 || \
33 fatal 1 "Error while editing SPECS/$SPEC_NAME"
35 # XXX - a building-on-Ubuntu hack
36 if grep -q "Ubuntu" /etc/issue; then
37 sed -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
38 -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
39 -e 's/sha512hmac/md5sum/g' \
40 SPECS/$SPEC_NAME 2>&1 || \
41 fatal 1 "Error while editing SPECS/$SPEC_NAME"
47 prepare_and_build_srpm() {
49 pushd $TOPDIR >/dev/null
52 local buildid="_lustre${EXTRA_VERSION##*_lustre}"
54 # edit the SPEC with our changes
59 # this concept of being able to build a list of targets with a single
60 # lbuild is a fine idea, but in reality I think it's (very) broken. I
61 # don't even think the lustre.spec can handle being called with "--target
62 # <multiple arches>". It certainly can't handle the issue where each
63 # arch has it's own kernel location.
64 # but we will do the best we can and put the plumbing in place so that
65 # this could work when the other broken bits are fixed.
66 # in reality, our current use of lbuild only ever has a single arch in
70 for arch in $BUILD_ARCHS; do
71 # XXX - ok. so here's a hack that needs to be fixed properly
72 # ppc64 was merged to ppc some time ago pre 2.6.18
73 if [ $arch = ppc64 ]; then
76 targets="--target $arch $targets"
77 # copy our .config into the RPM build tree
78 (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
79 SOURCES/kernel-$lnxmaj-$arch.config
81 # XXX - hackity hack -- until we get (or generate from the base
82 # config) configs for xen and debug
84 for f in SOURCES/kernel-${lnxmaj}-*.config; do
85 grep -q "^CONFIG_SD_IOSTATS=y" $f || \
86 echo "CONFIG_SD_IOSTATS=y" >> $f
90 # do we need any special rpm build options
91 local rpmbuildopt="-bb"
96 # stupid Ubuntu's rpm doesn't do debuginfo properly
97 if [ ! -f /usr/lib/rpm/debugedit ]; then
98 rpmbuildopt="$rpmbuildopt --without debuginfo"
101 # XXX - need to figure this kabichk crap out -- it fails the build
103 rpmbuildopt="$rpmbuildopt --without kabichk"
106 # get any release specific build options
107 rpmbuildopt="$rpmbuildopt $(get_rpmbuildopts)"
110 if ! eval rpmbuild $rpmbuildopt $targets --with baseonly \
111 --define \"_topdir $TOPDIR\" \
112 --define \"buildid $buildid\" \
113 --define \"_tmppath $TMPDIR\" \
114 $TOPDIR/SPECS/$SPEC_NAME 2>&1; then
118 # for informative purposes, display a diff between the .config that
119 # was actually built and what we proposed as a .config
120 echo "Diffs between $(basename $CONFIG_FILE) and the built kernel's .config:"
121 local rpmname="$TOPDIR/RPMS/${BUILD_ARCHS# }/kernel-${lnxmaj}-${lnxrel}${buildid}.${BUILD_ARCHS# }.rpm"
122 rpmcfg=$(rpm -qpl $rpmname | grep '/boot/config-')
123 rpm2cpio $rpmname | cpio -id .$rpmcfg
124 diff -u $CONFIG_FILE .$rpmcfg
131 devel_kernel_name() {
132 local lustre=${1:-false}
135 echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
137 echo "kernel-$DEVEL_KERNEL_TYPE"
142 rpm_BUILD_kernel_dirname() {
143 local rpmsmptype="$1"
149 if $KERNEL_LUSTRE_NAMING; then
152 echo kernel${lustre}${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
155 find_linux_devel_paths() {
157 local ARCH=$TARGET_ARCH
159 # If DEVEL_PATH_ARCH is set, use it. Added for fc11 as it needs i586 string for i686.
160 if [ $DEVEL_PATH_ARCH ];then
161 ARCH=$DEVEL_PATH_ARCH
164 LINUX=$path/usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}${ARCH}
165 # RHEL doesn't have the -obj tree
171 unpack_linux_devel_rpm-rhel() {
172 local callers_rpm="$1"
174 # now just sanity check that everything needed to build properly versioned
175 # modules is in place
176 if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}$TARGET_ARCH/Module.symvers ]; then
177 fatal 1 "cannot build kernel modules: the Kernel's Module.symvers is missing."
184 # this of course requires a sudo rule on the builder for real RHEL:
185 # hudson ALL= NOPASSWD: /usr/bin/yumdownloader
186 # also must disable the requiretty attribute in the sudoers file
187 find_linux_rpm-rhel() {
189 local wanted_kernel="$2"
190 local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
192 local tmpdir=$(mktemp -d $pathtorpms/yumXXXXXX)
194 if [ "$(lsb_release -s -i)" = "RedHatEnterpriseServer" ]; then
197 if ! $sudo yumdownloader --destdir "$tmpdir" kernel-devel-"$wanted_kernel" > /dev/null; then
198 fatal 1 "failed to fetch kernel-devel-$wanted_kernel with yumdownloader."
200 local rpm=$(cd $tmpdir; echo *)
201 mv "$tmpdir/$rpm" "$pathtorpms"
209 # This function digs out the linux release from the linux source tree
210 find_linux_release() {
211 _find_linux_release $LINUX