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