Whamcloud - gitweb
LU-812 kernel: AUTOCONF_INCLUDED removed
[fs/lustre-release.git] / build / lbuild-rhel
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 for all releases of this distribution (only -- if you want
5 # to force a kernel build on all distributions, update the BUILD_GEN variable
6 # in build/lbuild)
7 #BUILD_GEN+=".0"
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
11 DEVEL_KERNEL_TYPE="devel"
12 RPM_HELPERS_DIR="/usr/lib/rpm/redhat"
13
14 # a method which can be overriden by the release specific code
15 get_rpmbuildopts() {
16
17     return 0
18
19 }
20
21 # patching common to all releases
22 patch_spec_common() {
23
24     sed -i -e '/find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
25     cp -a fs/ext3/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext3 \
26     cp -a fs/ext4/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4' \
27           SPECS/$SPEC_NAME 2>&1 || \
28         fatal 1 "Error while editing SPECS/$SPEC_NAME"
29
30     # XXX - a building-on-Ubuntu hack
31     if grep -q "Ubuntu" /etc/issue; then
32         sed  -i -e 's/^\(BuildPreReq: .*\)$/#NOU \1/g' \
33                -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
34                -e 's/sha512hmac/md5sum/g' \
35             SPECS/$SPEC_NAME 2>&1 || \
36                 fatal 1 "Error while editing SPECS/$SPEC_NAME"
37     fi
38
39
40 }
41
42 prepare_and_build_srpm() {
43
44     pushd $TOPDIR >/dev/null
45
46     # create the buildid
47     local buildid="_lustre${EXTRA_VERSION##*_lustre}"
48
49     # edit the SPEC with our changes
50     patch_spec
51
52     popd >/dev/null
53
54     # this concept of being able to build a list of targets with a single
55     # lbuild is a fine idea, but in reality I think it's (very) broken.  I
56     # don't even think the lustre.spec can handle being called with "--target
57     # <multiple arches>".  It certainly can't handle the issue where each
58     # arch has it's own kernel location.
59     # but we will do the best we can and put the plumbing in place so that
60     # this could work when the other broken bits are fixed.
61     # in reality, our current use of lbuild only ever has a single arch in
62     # $BUILD_ARCHS
63     local arch
64     local targets=""
65     for arch in $BUILD_ARCHS; do
66         # XXX - ok.  so here's a hack that needs to be fixed properly
67         #       ppc64 was merged to ppc some time ago pre 2.6.18
68         if [ $arch = ppc64 ]; then
69             arch=ppc
70         fi
71         targets="--target $arch $targets"
72         # copy our .config into the RPM build tree
73         (echo "# $(basearch $arch)"; cat $CONFIG_FILE) > \
74             SOURCES/kernel-$lnxmaj-$arch.config
75
76         # XXX - hackity hack -- until we get (or generate from the base
77         #                       config) configs for xen and debug
78         local f=""
79         for f in SOURCES/kernel-${lnxmaj}-*.config; do
80             grep -q "^CONFIG_SD_IOSTATS=y" $f || \
81                 echo "CONFIG_SD_IOSTATS=y" >> $f
82         done
83     done
84
85     # do we need any special rpm build options
86     local rpmbuildopt="-bb"
87     if $DO_SRC; then
88         rpmbuildopt="-ba"
89     fi
90
91     # stupid Ubuntu's rpm doesn't do debuginfo properly
92     if [ ! -f /usr/lib/rpm/debugedit ]; then
93         rpmbuildopt="$rpmbuildopt --without debuginfo"
94     fi
95
96     # XXX - need to figure this kabichk crap out -- it fails the build
97     if ! $USE_KABI; then
98         rpmbuildopt="$rpmbuildopt --without kabichk"
99     fi
100
101     # get any release specific build options
102     rpmbuildopt="$rpmbuildopt $(get_rpmbuildopts)"
103
104     # now build it
105     if ! eval $RPMBUILD $rpmbuildopt $targets --with baseonly \
106                    --define \"_topdir $TOPDIR\" \
107                    --define \"buildid $buildid\" \
108                    --define \"_tmppath $TMPDIR\" \
109                    $TOPDIR/SPECS/$SPEC_NAME 2>&1; then
110         return 1
111     fi
112
113     # for informative purposes, display a diff between the .config that
114     # was actually built and what we proposed as a .config
115     echo "Diffs between $(basename $CONFIG_FILE) and the built kernel's .config:"
116     local rpmname="$TOPDIR/RPMS/${BUILD_ARCHS# }/kernel-${lnxmaj}-${lnxrel}${buildid}.${BUILD_ARCHS# }.rpm"
117     rpmcfg=$(rpm -qpl $rpmname | grep '/boot/config-')
118     rpm2cpio $rpmname | cpio -id .$rpmcfg
119     diff -u $CONFIG_FILE .$rpmcfg
120     rm -rf .$rpmcfg
121
122     return 0
123
124 }
125
126 devel_kernel_name() {
127     local lustre=${1:-false}
128
129     if $lustre; then
130         echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
131     else
132         echo "kernel-$DEVEL_KERNEL_TYPE"
133     fi
134
135 }
136
137 rpm_BUILD_kernel_dirname() {
138     local rpmsmptype="$1"
139     local lnxmaj="$2"
140     local lnxmin="$3"
141     local arch="$4"
142
143     local lustre=""
144     if $KERNEL_LUSTRE_NAMING; then
145         $lustre="-lustre"
146     fi
147     echo kernel${lustre}${lnxmaj}${lnxmin}/linux-${lnxmaj}.$arch
148 }
149
150 find_linux_devel_paths() {
151     local path="$1"
152     local ARCH=$TARGET_ARCH
153
154     # If DEVEL_PATH_ARCH is set, use it. Added for fc11 as it needs i586 string for i686.
155     if [ $DEVEL_PATH_ARCH ];then
156         ARCH=$DEVEL_PATH_ARCH
157     fi
158
159     LINUX=$path/usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}${ARCH}
160     # RHEL doesn't have the -obj tree
161     LINUXOBJ=""
162     # XXX - i don't think we need this any more
163     #LINUXRELEASE=$(find_linux_release "$LINUX")
164     #if [ -z "$LINUXRELEASE" ]; then
165     #    echo "Failed to find linux release in $LINUX"
166     #    return 255
167     #fi
168
169     return 0
170 }
171
172 unpack_linux_devel_rpm-rhel() {
173     local callers_rpm="$1"
174
175     # now just sanity check that everything needed to build properly versioned
176     # modules is in place
177     if [ ! -f usr/src/kernels/${lnxmaj}${lnxmin}-${lnxrel}${DEVEL_PATH_ARCH_DELIMETER:-"-"}$TARGET_ARCH/Module.symvers ]; then
178         fatal 1 "cannot build kernel modules: the Kernel's Module.symvers is missing."
179     fi
180
181     return 0
182
183 }
184
185 # this of course requires a sudo rule on the builder for real RHEL:
186 # hudson ALL= NOPASSWD: /usr/bin/yumdownloader
187 # also must disable the requiretty attribute in the sudoers file
188 find_linux_rpm-rhel() {
189     local prefix="$1"
190     local wanted_kernel="$2"
191     local pathtorpms=${3:-"${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${TARGET_ARCH}"}
192
193     local tmpdir=$(mktemp -d $pathtorpms/yumXXXXXX)
194     local sudo=""
195     if [ "$(lsb_release -s -i)" = "RedHatEnterpriseServer" ]; then
196         sudo="sudo"
197     fi
198     if ! $sudo yumdownloader --destdir "$tmpdir" kernel-devel-"$wanted_kernel" > /dev/null; then
199         fatal 1 "failed to fetch kernel-devel-$wanted_kernel with yumdownloader."
200     fi
201     local rpm=$(cd $tmpdir; echo *)
202     mv "$tmpdir/$rpm" "$pathtorpms"
203     rmdir $tmpdir
204     echo "$rpm"
205
206     return 0
207
208 }