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