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