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