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