Whamcloud - gitweb
LU-9222 build: workaround for sles11sp4 MOFED
[fs/lustre-release.git] / contrib / lbuild / lbuild-sles
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+=".2" #LU-3337 add missing build files for sles11sp2 server
6
7 DEVEL_KERNEL_TYPE="default-devel"
8 RPM_HELPERS_DIR="/usr/lib/rpm"
9 RMAC=$HOME/.rpmmacros
10 SUSE_MACROS=/etc/rpm/macros.kernel-source
11
12 prepare_and_build_srpm() {
13
14     pushd $TOPDIR >/dev/null
15
16     # generate our buildid
17     local buildid="lustre${EXTRA_VERSION##*_lustre}"
18
19     # do release specific spec editing
20     edit_specs
21
22     # XXX - need to flesh this out per the rhel5 method
23     local targets
24     for arch in $BUILD_ARCHS; do
25         targets="--target $arch $targets"
26         mkdir -p config/$(basearch $arch)
27         cp $CONFIG_FILE config/$(basearch $arch)/$RPMSMPTYPE
28     done
29
30     tar cjf SOURCES/config.tar.bz2 config
31     rm -rf config
32
33     # do we need any special rpm build options
34     local rpmbuildopt="-bb"
35     if $DO_SRC; then
36         rpmbuildopt="-ba"
37     fi
38
39     # XXX - ignore the kabi changes.  need to figure out what this is really
40     #       all about.
41     touch SOURCES/IGNORE-KABI-BADNESS
42
43
44 # XXX testing speedup hack - never let an inspection pass without this
45 #     commented out!  in fact it should be removed completely before a
46 #     landing.
47 #if false; then
48     # now build it
49     if ! rpmbuild $rpmbuildopt $targets \
50                    --define "_topdir $TOPDIR" \
51                    $TOPDIR/SOURCES/kernel-$RPMSMPTYPE.spec 2>&1; then
52         fatal 1 "Failed to build kernel RPM"
53     fi
54 #fi
55
56     # for SLES, we also need to build the kernel-source rpm
57     if ! rpmbuild $rpmbuildopt $targets \
58                    --define "_topdir $TOPDIR" \
59                    $TOPDIR/SOURCES/kernel-source.spec 2>&1; then
60         fatal 1 "Failed to build kernel source RPM"
61     fi
62
63     # for SLES, we also need to build the kernel-syms rpm
64     if ! rpmbuild $rpmbuildopt $targets \
65                    --define "_topdir $TOPDIR" \
66                    $TOPDIR/SOURCES/kernel-syms.spec 2>&1; then
67         fatal 1 "Failed to build kernel syms RPM"
68     fi
69
70 }
71
72 devel_kernel_name() {
73     local lustre=${1:-false}
74
75     if $lustre; then
76         echo "kernel-lustre-$DEVEL_KERNEL_TYPE"
77     else
78         echo "kernel-$DEVEL_KERNEL_TYPE"
79     fi
80
81 }
82
83 rpm_BUILD_kernel_dirname() {
84     local rpmsmptype="$1"
85     local lnxmaj="$2"
86     local lnxmin="$3"
87     local arch="$4"
88
89     local lustre=""
90     if $KERNEL_LUSTRE_NAMING; then
91         $lustre="-lustre"
92     fi
93     echo kernel${lustre}-${rpmsmptype}-${lnxmaj}${lnxmin}/linux-${lnxmaj}
94 }
95
96 resolve_arch() {
97     local arch="$1"
98     # because we build an i686 kernel, we need to know if the arch we are
99     # resolving for is for the patched or patchless kernel (which is i586)
100     # we really should be building an i586 kernel to match what Novell does
101     local for_patchless=${2:-true}
102     local canonical=${3:-false}
103
104     case $arch in
105         ppc64)  arch=powerpc
106                 ;;
107         i?86)   if $canonical; then
108                     arch=i386
109                 elif $(eval $for_patchless); then
110                     arch=i586
111                 fi
112                 ;;
113     esac
114
115     echo "$arch"
116
117 }
118
119 find_linux_devel_paths() {
120         local path="$1"
121         local linuxobjpath=$path/usr/src/linux-${lnxmaj}${lnxmin}-${lnxrel}-obj/$(resolve_arch $TARGET_ARCH $PATCHLESS)/$RPMSMPTYPE
122
123         LINUX=$path/usr/src/linux-${lnxmaj}${lnxmin}-${lnxrel}
124         LINUXOBJ=$path/usr/src/linux-obj/$(resolve_arch $TARGET_ARCH $PATCHLESS)/$RPMSMPTYPE
125
126         # symlink the linux-obj to linux-version-obj
127         ln -s $linuxobjpath $LINUXOBJ
128         # We need to copy the headers from the source to the object tree for
129         # MOFED to be able to compile (a bug in ofed?)
130         if [ -e ${LINUX}/include ] && [ -e ${LINUXOBJ}/include ]; then
131                 cp -rf ${LINUX}/include ${LINUXOBJ}
132         fi
133         # We modify %kernel_module_package macro to use the linux obj
134         # that lbuild install, not the OS installed /usr/src
135         sed -i -e "/^%kernel_module_package/,/^)}$/d" \
136             -e "/^# A few cross-distro definitions/d" $RMAC
137         sed -e "s/\/usr\/src/${path//\//\\/}\/usr\/src/" \
138             -e "s/\/boot/${path//\//\\/}\/boot/" ${SUSE_MACROS} >> $RMAC
139
140         return 0
141 }
142
143 mcpu_rpmbuild_opt() {
144
145     echo "--define \'jobs $(/usr/bin/getconf _NPROCESSORS_ONLN)\'"
146     return 0
147 }
148
149 # This function digs out the linux release from a linux-obj tree
150 find_linux_release() {
151     _find_linux_release $LINUXOBJ
152 }
153
154 # cleanup the modified/added rpmmacros
155 cleanup_rpmmacros() {
156         sed -i -e "/^%kernel_module_package/,/^)}$/d" \
157             -e "/^# A few cross-distro definitions/d" $RMAC
158 }