Whamcloud - gitweb
LU-5614 build: use %kernel_module_package in rpm spec
[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=true
12
13 # force local definition of %dist into ~/.rpmmacros
14 # to avoid verbose extended strings like ".el7.centos"
15 # in kernel version and rpm names
16 #
17 RMAC=$HOME/.rpmmacros
18 grep '%dist' $RMAC &> /dev/null || echo '%dist .el7' >> $RMAC
19
20 # We modify the RHEL7 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}/rhel7/kmodtool"
25 cp  $RHEL_KMODTOOL $LBUILD_KMODTOOL
26 pushd ${LBUILD_DIR}/rhel7
27 patch -p1 < kmodtool.patch
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 sed -e "s|REPLACE_ME|$LBUILD_KMODTOOL|" \
33     ${LBUILD_DIR}/rhel7/rpmmacros.template > ${LBUILD_DIR}/rhel7/rpmmacros
34 cat ${LBUILD_DIR}/rhel7/rpmmacros >> $RMAC
35
36 patch_spec() {
37     local buildid="$1"
38
39     # the el7 .spec file requires patch names to begin with "patch-3."
40     # so rename the lustre patch from lbuild to one the .spec will like
41     mv $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch \
42         $TOPDIR/SOURCES/patch-${lnxmaj}-lustre.patch
43
44     # edit the SPEC with our changes
45     patch_spec_common "$buildid"
46     sed -i -e '/^# empty final patch to facilitate testing of kernel patches/i\
47 # adds Lustre patches\
48 Patch99995: patch-%{version}-lustre.patch' \
49            -e '/^ApplyOptionalPatch linux-kernel-test.patch/i\
50 \
51 # lustre patch\
52 ApplyOptionalPatch patch-%{version}-lustre.patch\
53 ' \
54            -e '/rm -f include\/generated\/kernel.cross/i\
55   # lustre kernel config.\
56   if [ -f %{_topdir}/lustre/lustre/kernel_patches/kernel_configs/kernel-%{version}-3.10-rhel7-%{_target_cpu}.config ]; then\
57     echo "# $Arch" > configs/kernel-%{version}-%{_target_cpu}.config\
58     cat %{_topdir}/lustre/lustre/kernel_patches/kernel_configs/kernel-%{version}-3.10-rhel7-%{_target_cpu}.config >> configs/kernel-%{version}-%{_target_cpu}.config\
59   fi'\
60            -e '/^# Dynamically generate kernel/a echo "CONFIG_BH_LRU_SIZE=16" >> config-generic'\
61            -e '/^%define listnewconfig_fail 1/s/1/0/'\
62           SPECS/$SPEC_NAME 2>&1 || \
63         fatal 1 "Error while editing SPECS/$SPEC_NAME"
64
65
66     return 0
67
68 }
69
70 unpack_linux_devel_rpm-rhel7() {
71     local callers_rpm="$1"
72
73     unpack_linux_devel_rpm-rhel "$callers_rpm"
74
75
76     return 0
77
78 }
79
80 get_rpmbuildopts() {
81
82     if $KERNEL_LUSTRE_NAMING; then
83         echo -e "--define \"variant -lustre\" \c"
84     fi
85     echo "--with firmware"
86
87     return 0
88
89 }
90
91 find_linux_rpm-rhel7() {
92     local prefix="$1"
93     local wanted_kernel="$2"
94     local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
95
96     find_linux_rpm-rhel "$prefix" "$wanted_kernel" "$pathtorpms"
97
98 }
99
100 kernel_srpm_location() {
101
102     echo "http://vault.centos.org/centos/7/updates/Source/SPackages/"
103
104 }