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