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