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