Whamcloud - gitweb
LU-4416 build: add build files for SLES 12 client build
[fs/lustre-release.git] / contrib / lbuild / lbuild-sles12
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 this distribution (only -- if you want to force a kernel
5 # build on all distributions, update the BUILD_GEN variable in build/lbuild)
6 BUILD_GEN+=".0"
7
8 # This distro does not support zfs, so define WITH_ZFS
9 # use words that make the bash log readable.
10 WITH_ZFS="Zfs Not Supported"
11
12 source ${LBUILD_DIR}/lbuild-sles
13 # LU-6490 work around
14 CONFIGURE_FLAGS="$CONFIGURE_FLAGS --disable-gss"
15
16 edit_specs() {
17
18     # edit the SPECs with our changes
19     local spec
20     (cd $TOPDIR/SOURCES; ./mkspec --release ${lnxrel})
21     for spec in $RPMSMPTYPE source; do
22         #cp $TOPDIR/SOURCES/kernel-$spec.spec{,.orig}
23         sed -i -e "s/^\(Release: *\).*$/\1${lnxrel}_${buildid}/" \
24                -e '/^%setup /a\
25 cp  %_sourcedir/linux-3.0-lustre.patch %_builddir/%{name}-%{version}/lustre.patch\
26 ! grep -q lustre.patch %_sourcedir/series.conf && echo -e "\\n\\tlustre.patch" >> %_sourcedir/series.conf' \
27           SOURCES/kernel-${spec}.spec || \
28             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
29
30         if $KERNEL_LUSTRE_NAMING; then
31             # these are all of the changes needed because we change the package names
32             # to kernel-lustre-*.  these should all go away when we stop this insanity
33             sed -i -e 's/^\(Name:.*kernel-\)\(.*\)/\1lustre-\2/' \
34                    -e "/^Provides:  *kernel = /a\
35 Provides:       kernel-$spec = %{version}-%{release}
36 " \
37                    -e 's/^\([   ][      ]*-i %_builddir\/kernel-\)\(source-2.6.27.21\/\$patch; then\)/\1lustre-\2/' \
38                    -e '/^%build/,/^%changelog/s/\(kernel-\)\(source\.files\)/\1lustre-\2/g' \
39                    -e '/--no-backup-if-mismatch/,/fi/s/kernel-source-/kernel-lustre-source-/g' \
40                    -e "s/^\(%package -n kernel-\)\(.*\)/\1lustre-\2/" \
41                    -e "s/^\(%description -n kernel-\)\(.*\)/\1lustre-\2/" \
42                    -e "s/^\(%files -n kernel-\)\(.*\)/\1lustre-\2/" \
43                    -e "s/^\(Provides:.*kernel-\)\(.*\)/\1lustre-\2/" \
44                    -e "s/^\(Requires:.*kernel-\)\(.*\)/\1lustre-\2/" \
45                    -e "s/^\(Supplements:.*kernel-\)\(.*\)/\1lustre-\2/" \
46                 SOURCES/kernel-${spec}.spec || \
47                 fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
48         fi
49
50         # XXX - a building-on-Ubuntu hack
51         if grep -q "Ubuntu" /etc/issue; then
52             sed -i -e '/^%_sourcedir\/install-configs %_sourcedir .*/i\
53 curl ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17/2.6.17-mm1/broken-out/i386-use-c-code-for-current_thread_info.patch | patch -p1' \
54                    -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
55                    -e 's/%(\(chmod .*\))$/%(bash -c "\1")/' \
56                    -e 's/ -a 109//' \
57               SOURCES/kernel-${spec}.spec || \
58             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
59         fi
60     done
61 }
62
63 unpack_linux_devel_rpm-sles12() {
64     local callers_rpm="$1"
65
66     local rpmdir="${callers_rpm%/*}"
67
68     local kernelrpm
69     local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}"
70
71     # this is a hack that should go away when the modified lustre kernel
72     # Provides kernel-default-devel                       vvvvvvvvv
73     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?default-devel = $wanted_kernel"); then
74         fatal 1 "Could not find the kernel-default-devel in $rpmdir/"
75     fi
76
77     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
78         fatal 1 "Unpack error for $kernelrpm"
79     fi
80
81     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?devel = $wanted_kernel"); then
82         fatal 1 "Could not find the kernel-devel in $rpmdir/"
83     fi
84
85     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
86         fatal 1 "Unpack error for $kernelrpm"
87     fi
88
89     # SLES also needs the kernel-source together with the kernel-default-devel
90     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-source = $wanted_kernel"); then
91         fatal 1 "Could not find the kernel-source in $rpmdir/"
92     fi
93
94     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
95         fatal 1 "Unpack error for $kernelrpm"
96     fi
97
98 }
99
100 find_linux_rpm-sles12() {
101     local prefix="$1"
102     local wanted_kernel="$2"
103     local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
104
105     local PLEV=$(sed -n -e 's/^PATCHLEVEL = //p' /etc/SuSE-release)
106     local site="https://nu.novell.com/repo/\$RCE/SLES12-SP${PLEV}-Updates/sle-12-$(resolve_arch $TARGET_ARCH)/rpm/$(resolve_arch $TARGET_ARCH)"
107     if [ ! -f $pathtorpms/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm ]; then
108         fetch_url "$site/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm" $pathtorpms
109     fi
110     # SLES also needs the kernel-source along with kernel-devel
111     if [ ! -f $pathtorpms/kernel-source-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm ]; then
112         fetch_url "$site/kernel-source-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm" $pathtorpms
113     fi
114     echo "kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm"
115
116     return 0
117
118 }