Whamcloud - gitweb
LU-11927 kernel: new kernel [SLES12 SP4 4.12.14-95.6.1]
[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
14 kernel_srpm_location() {
15
16     local site
17     local kminor
18     local kdir
19     case $lnxmaj in
20     3.12)
21         site="http://mgmt/cobbler/repo_mirror/updates-sles12.1-src"
22         ;;
23     4.4)
24         kminor=${lnxmin##.}
25         kdir=updates-sles12.2-src
26         if [ $kminor -eq 114 -o $kminor -eq 120 ]
27         then
28                 if [ ${lnxrel%%.*} -gt 92 ]
29                 then
30                         kdir=updates-sles12.3-src
31                 fi
32         elif [ $kminor -eq 103 ]
33         then
34                 if [ ${lnxrel%%.*} -lt 90 ]
35                 then
36                         kdir=updates-sles12.3-src
37                 fi
38         elif [ $kminor -eq 82 -o $kminor -gt 91 ]
39         then
40                 kdir=updates-sles12.3-src
41         fi
42         site="http://mgmt/cobbler/repo_mirror/$kdir"
43         ;;
44     esac
45     echo "$site/src/"
46
47 }
48
49 edit_specs() {
50
51     # edit the SPECs with our changes
52     local spec
53     (cd $TOPDIR/SOURCES; ./mkspec --release ${lnxrel})
54     for spec in $RPMSMPTYPE source syms; do
55         #cp $TOPDIR/SOURCES/kernel-$spec.spec{,.orig}
56         case $lnxmaj in
57         4.4)
58         sed -i -e "s/^\(Release: *\).*$/\1${lnxrel}_${buildid}/" \
59                -e '/^%setup /a\
60 cp  %_sourcedir/linux-4.4-lustre.patch %_builddir/%{name}-%{version}/lustre.patch\
61 ! grep -q lustre.patch %_sourcedir/series.conf && echo -e "\\n\\tlustre.patch" >> %_sourcedir/series.conf' \
62           SOURCES/kernel-${spec}.spec || \
63             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
64         ;;
65         3.12)
66         sed -i -e "s/^\(Release: *\).*$/\1${lnxrel}_${buildid}/" \
67                -e '/^%setup /a\
68 cp  %_sourcedir/linux-3.12-lustre.patch %_builddir/%{name}-%{version}/lustre.patch\
69 ! grep -q lustre.patch %_sourcedir/series.conf && echo -e "\\n\\tlustre.patch" >> %_sourcedir/series.conf' \
70           SOURCES/kernel-${spec}.spec || \
71             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
72         ;;
73         esac
74
75         if $KERNEL_LUSTRE_NAMING; then
76             # these are all of the changes needed because we change the package names
77             # to kernel-lustre-*.  these should all go away when we stop this insanity
78             sed -i -e 's/^\(Name:.*kernel-\)\(.*\)/\1lustre-\2/' \
79                    -e "/^Provides:  *kernel = /a\
80 Provides:       kernel-$spec = %{version}-%{release}
81 " \
82                    -e 's/^\([   ][      ]*-i %_builddir\/kernel-\)\(source-2.6.27.21\/\$patch; then\)/\1lustre-\2/' \
83                    -e '/^%build/,/^%changelog/s/\(kernel-\)\(source\.files\)/\1lustre-\2/g' \
84                    -e '/--no-backup-if-mismatch/,/fi/s/kernel-source-/kernel-lustre-source-/g' \
85                    -e "s/^\(%package -n kernel-\)\(.*\)/\1lustre-\2/" \
86                    -e "s/^\(%description -n kernel-\)\(.*\)/\1lustre-\2/" \
87                    -e "s/^\(%files -n kernel-\)\(.*\)/\1lustre-\2/" \
88                    -e "s/^\(Provides:.*kernel-\)\(.*\)/\1lustre-\2/" \
89                    -e "s/^\(Requires:.*kernel-\)\(.*\)/\1lustre-\2/" \
90                    -e "s/^\(Supplements:.*kernel-\)\(.*\)/\1lustre-\2/" \
91                 SOURCES/kernel-${spec}.spec || \
92                 fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
93         fi
94
95         # XXX - a building-on-Ubuntu hack
96         if grep -q "Ubuntu" /etc/issue; then
97             sed -i -e '/^%_sourcedir\/install-configs %_sourcedir .*/i\
98 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' \
99                    -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
100                    -e 's/%(\(chmod .*\))$/%(bash -c "\1")/' \
101                    -e 's/ -a 109//' \
102               SOURCES/kernel-${spec}.spec || \
103             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
104         fi
105     done
106 }
107
108 unpack_linux_devel_rpm-sles12() {
109     local callers_rpm="$1"
110
111     local rpmdir="${callers_rpm%/*}"
112
113     local kernelrpm
114     local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}"
115
116     # this is a hack that should go away when the modified lustre kernel
117     # Provides kernel-default-devel                       vvvvvvvvv
118     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?default-devel = $wanted_kernel"); then
119         fatal 1 "Could not find the kernel-default-devel in $rpmdir/"
120     fi
121
122     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
123         fatal 1 "Unpack error for $kernelrpm"
124     fi
125
126     if [ -d "${rpmdir}/../noarch" ]; then
127         rpmdir="${rpmdir%/*}"
128         rpmdir="${rpmdir}/noarch"
129     fi
130
131     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?devel = $wanted_kernel"); then
132         fatal 1 "Could not find the kernel-devel in $rpmdir/"
133     fi
134
135     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
136         fatal 1 "Unpack error for $kernelrpm"
137     fi
138
139     # SLES also needs the kernel-source together with the kernel-default-devel
140     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-source = $wanted_kernel"); then
141         fatal 1 "Could not find the kernel-source in $rpmdir/"
142     fi
143
144     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
145         fatal 1 "Unpack error for $kernelrpm"
146     fi
147
148 }
149
150 find_linux_rpm-sles12() {
151     local prefix="$1"
152     local wanted_kernel="$2"
153     local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
154     local wanted_kernel_org="$wanted_kernel"
155
156         if [ "x$rpmfix_diff" != "x" ] && [ $wanted_kernel != "${lnxmaj}${lnxmin}-${lnxrel}${rpmfix_diff}" ]; then
157                 wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}${rpmfix_diff}"
158         fi
159     local site
160     local kminor
161     local kdir
162     case $lnxmaj in
163     3.12)
164         site="http://mgmt/cobbler/repo_mirror/updates-sles12.1-x86_64"
165         ;;
166     4.4)
167         kminor=${lnxmin##.}
168         kdir=updates-sles12.2-x86_64
169         if [ $kminor -eq 114 -o $kminor -eq 120 ]
170         then
171                 if [ ${lnxrel%%.*} -gt 92 ]
172                 then
173                         kdir=updates-sles12.3-x86_64
174                 fi
175         elif [ $kminor -eq 103 ]
176         then
177                 if [ ${lnxrel%%.*} -lt 90 ]
178                 then
179                         kdir=updates-sles12.3-x86_64
180                 fi
181         elif [ $kminor -eq 82 -o $kminor -gt 91 ]
182         then
183                 kdir=updates-sles12.3-x86_64
184         fi
185         site="http://mgmt/cobbler/repo_mirror/$kdir"
186         ;;
187     4.12)
188         site="http://mgmt/cobbler/repo_mirror/updates-sles12.4-x86_64"
189         ;;
190     esac
191     if [ ! -f $pathtorpms/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm ]; then
192         fetch_url "$site/x86_64/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm" $pathtorpms
193     fi
194     # SLES 12 also needs kernel-devel in addition to kernel-default-devel
195     if [ ! -f $pathtorpms/kernel-devel-$wanted_kernel_org.noarch.rpm ]; then
196         fetch_url "$site/noarch/kernel-devel-$wanted_kernel_org.noarch.rpm" $pathtorpms
197     fi
198     # SLES also needs the kernel-source along with kernel-devel
199     if [ ! -f $pathtorpms/kernel-source-$wanted_kernel_org.noarch.rpm ]; then
200         fetch_url "$site/noarch/kernel-source-$wanted_kernel_org.noarch.rpm" $pathtorpms
201     fi
202     echo "kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm"
203
204     return 0
205
206 }