Whamcloud - gitweb
Branch b1_8
[fs/lustre-release.git] / build / lbuild-sles11
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
6 BUILD_GEN=2     # bz19952: remove -lustre tag from kernel RPM names
7
8 source ${0%/*}/lbuild-sles
9
10 # this is what lnxrel really should be, once bug 19336 lands
11 real_lnxrel=${lnxrel##${lnxmin#.}-}
12
13 edit_specs() {
14
15     # edit the SPECs with our changes
16     local spec
17     for spec in $RPMSMPTYPE source; do
18         #cp $TOPDIR/SPECS/kernel-$spec.spec{,.orig}
19         sed -i -e "s/^\(Release: *\).*$/\1${real_lnxrel}_${buildid}/" \
20                -e "s/^ExclusiveArch:.*/& ppc ppc64/" \
21                -e '/^%setup /a\
22 cp  %_sourcedir/linux-2.6.27-lustre.patch %_builddir/%{name}-%{version}/lustre.patch\
23 ! grep -q lustre.patch %_sourcedir/series.conf && echo -e "\\n\\tlustre.patch" >> %_sourcedir/series.conf' \
24                -e "/flavor=\${config/a\
25     [ \"\$flavor\" == \"$RPMSMPTYPE\" ] || continue" \
26                -e "s/^\(BuildRequires:  kernel-dummy\)/# \1/" \
27           SPECS/kernel-${spec}.spec
28
29         if $KERNEL_LUSTRE_NAMING; then
30             # these are all of the changes needed because we change the package names
31             # to kernel-lustre-*.  these should all go away when we stop this insanity
32         sed -i -e 's/^\(Name:.*kernel-\)\(.*\)/\1lustre-\2/' \
33                -e "/^Provides:  *kernel = /a\
34 Provides:       kernel-$spec = %{version}-%{release}
35 " \
36                -e 's/^\([       ][      ]*-i %_builddir\/kernel-\)\(source-2.6.27.21\/\$patch; then\)/\1lustre-\2/' \
37                -e '/^%build/,/^%changelog/s/\(kernel-\)\(source\.files\)/\1lustre-\2/g' \
38                -e '/--no-backup-if-mismatch/,/fi/s/kernel-source-/kernel-lustre-source-/g' \
39                -e "s/^\(%package -n kernel-\)\(.*\)/\1lustre-\2/" \
40                -e "s/^\(%description -n kernel-\)\(.*\)/\1lustre-\2/" \
41                -e "s/^\(%files -n kernel-\)\(.*\)/\1lustre-\2/" \
42                -e "s/^\(Provides:.*kernel-\)\(.*\)/\1lustre-\2/" \
43                -e "s/^\(Requires:.*kernel-\)\(.*\)/\1lustre-\2/" \
44                -e "s/^\(Supplements:.*kernel-\)\(.*\)/\1lustre-\2/" \
45           SPECS/kernel-${spec}.spec
46         fi
47
48     # XXX - a building-on-Ubuntu hack
49         if grep -q "Ubuntu" /etc/issue; then
50             sed -i -e '/^%_sourcedir\/install-configs %_sourcedir .*/i\
51 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' \
52                    -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
53                    -e 's/%(\(chmod .*\))$/%(bash -c "\1")/' \
54                    -e 's/ -a 109//' \
55               SPECS/kernel-${spec}.spec
56     fi
57     done
58 }
59
60 unpack_linux_devel_rpm-sles11() {
61     local callers_rpm="$1"
62
63     local rpmdir="${callers_rpm%/*}"
64
65     local kernelrpm
66     local wanted_kernel="${lnxmaj}${lnxmin}${TARGET_DELIMITER}${lnxrel}"
67     # this is a hack that should go away when the modified lustre kernel
68     # Provides kernel-default-base                        vvvvvvvvv
69     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?default-base = $wanted_kernel"); then
70         fatal 1 "Could not find the kernel-default-base in $rpmdir/"
71     fi
72
73     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
74         fatal 1 "Unpack error for $kernelrpm"
75     fi
76
77 }
78
79 # this is actually valid for sles10 and sles11 but let's test it on sles11 only, first
80 find_linux_devel_paths() {
81     local path="$1"
82
83     LINUX=$path/usr/src/linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}
84
85     local objects=$TARGET_ARCH/$RPMSMPTYPE
86     if [ -d $path/usr/src/linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}-obj/powerpc ]; then
87         objects="powerpc/$TARGET_ARCH"
88     elif [ $TARGET_ARCH == 'i686' ]; then
89         objects="i386/$RPMSMPTYPE"
90     fi
91
92     LINUXOBJ=$path/usr/src/linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}-obj/$objects
93
94     LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
95     if [ -z "$LINUXRELEASE" ]; then
96         echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
97         RC=255
98     fi
99 }