Whamcloud - gitweb
LU-15235 tests: skip sanity/56od in interop
[fs/lustre-release.git] / contrib / lbuild / lbuild-rhel9
1 source ${LBUILD_DIR}/lbuild-rhel
2
3 # increment this if you have made a change that should force a new kernel
4 # to build built
5 BUILD_GEN+=".0"
6
7 SPEC_NAME="kernel.spec"
8 DEVEL_PATH_ARCH_DELIMETER="."
9 USE_KABI=true
10
11 # force local definition of %dist into ~/.rpmmacros
12 # to avoid verbose extended strings like ".el9.centos"
13 # in kernel version and rpm names
14 #
15 RMAC=$HOME/.rpmmacros
16 grep '^%dist' $RMAC &> /dev/null || echo '%dist .el9' >> $RMAC
17
18 # We modify the RHEL9 kmodtool script, because it expects
19 # the kernel source to be in the correct packaged RHEL location.
20 # lbuild does not put the source in correct packaged RHEL location.
21 RHEL_KMODTOOL=/usr/lib/rpm/redhat/kmodtool
22 LBUILD_KMODTOOL="${LBUILD_DIR}/rhel9/kmodtool"
23 cp  $RHEL_KMODTOOL $LBUILD_KMODTOOL
24 pushd ${LBUILD_DIR}/rhel9
25 # Replace the hardcoded /usr/src/kernels with our build path
26 tmp="${TOPDIR}/reused/usr/src/kernels"
27 sed -i "s|/usr/src/kernels|${tmp}|g" ${LBUILD_DIR}/rhel9/kmodtool
28 chmod 755 kmodtool
29 popd
30 # Next we replace %kernel_module_package with one that is nearly
31 # identical, but calls lbuild's modified kmodtool script.
32 # We need to cleanout the previous entry
33 sed -i "/^%kernel_module_package/,/^)}$/d" $RMAC
34 sed -e "s|REPLACE_ME|$LBUILD_KMODTOOL|" -e "s|/usr/src/kernels|${tmp}|g" \
35     ${LBUILD_DIR}/rhel9/rpmmacros.template > ${LBUILD_DIR}/rhel9/rpmmacros
36 cat ${LBUILD_DIR}/rhel9/rpmmacros >> $RMAC
37
38 patch_spec_rhel9() {
39         sed -i -e '/Provides: kernel-uname-r =/a\
40 Provides: kernel-lustre = %{KVRA}%{?1:.%{1}}\\' \
41                -e '/Provides: kernel-devel-uname-r =/a\
42 Provides: kernel-devel-lustre = %{KVRA}%{?1:.%{1}}\\' \
43                -e '/^    find $RPM_BUILD_ROOT\/lib\/modules\/$KernelVer/a\
44         cp -a fs/ext4/* $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4\
45         rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/fs/ext4/ext4-inode-test*' \
46                 -e '/^%global efiuki 1/s/1/0/'\
47         SPECS/$SPEC_NAME 2>&1 ||
48                 fatal 1 "Error while editing SPECS/$SPEC_NAME"
49 }
50
51 patch_spec() {
52         local buildid="$1"
53
54         # the el9 .spec file requires patch names to begin with "patch-3."
55         # so rename the lustre patch from lbuild to one the .spec will like
56         mv $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch \
57                 $TOPDIR/SOURCES/patch-${lnxmaj}-lustre.patch
58
59         # edit the SPEC with our changes
60         patch_spec_rhel9 "$buildid"
61         sed -i -e '/^# empty final patch to facilitate testing of kernel patches/i\
62 # adds Lustre patches\
63 Patch99995: patch-%{version}-lustre.patch' \
64                -e '/^ApplyOptionalPatch linux-kernel-test.patch/i\
65 \
66 # lustre patch\
67 ApplyOptionalPatch patch-%{version}-lustre.patch\
68 ' \
69                 -e '/^# Dynamically generate kernel/a echo "CONFIG_BH_LRU_SIZE=16" >> config-generic'\
70         SPECS/$SPEC_NAME 2>&1 ||
71                 fatal 1 "Error while editing SPECS/$SPEC_NAME"
72 }
73
74 unpack_linux_devel_rpm-rhel9() {
75         local callers_rpm="$1"
76
77         unpack_linux_devel_rpm-rhel "$callers_rpm"
78 }
79
80 get_rpmbuildopts() {
81         if $KERNEL_LUSTRE_NAMING; then
82                 echo -e "--define \"variant -lustre\" \c"
83         fi
84
85         echo "--with firmware --without debug"
86 }
87
88 find_linux_rpm-rhel9() {
89         local prefix="$1"
90         local wanted_kernel="$2"
91         local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
92
93         find_linux_rpm-rhel "$prefix" "$wanted_kernel" "$pathtorpms"
94 }
95
96 kernel_srpm_location() {
97         local base_os="http://mirror.stream.centos.org/9-stream/BaseOS"
98
99         echo "$base_os/source/tree/Packages/"
100 }
101
102 kernel_debuginfo_location() {
103         local base_os="http://mirror.stream.centos.org/9-stream/BaseOS"
104
105         echo "$base_os/$TARGET_ARCH/debug/tree/Packages/"
106 }
107
108 apply_kmod_requires_conflicts() {
109         if $PATCHLESS; then
110                 # don't allow the patched kernel to be considered as
111                 # a valid kernel for the patchless client
112                 echo "Conflicts:      kernel-lustre" >> rpm/kmp-lustre.preamble
113         fi
114 }