1 Star 0 Fork 19

baiguo/risc-v-kernel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
kernel.spec 10.51 KB
一键复制 编辑 原始数据 按行查看 历史
%global KernelVer %{version}-%{release}.%{_target_cpu}
# The obs worker of RISC-V runs in cross-arch qemu virt, which support
# multi-thread maxmium of 8.
%global _smp_mflags -j8
%define with_source 1
%global debug_package %{nil}
Name: kernel
Version: 5.10
Release: 3
Summary: Linux Kernel for RISC-V
URL: http://www.kernel.org/
License: GPLv2
%global commit 937381741d02cc6594477c593b2f3a087b3a0bc1
# The source tarball is compressed by OBS automactically, if you wanted to do a local rpmbuilding, the tarball can be obtained via : https://gitee.com/openeuler/kernel/repository/archive/OLK-%{version}.zip
# The
Source0: risc-v-kernel-%{version}.tar.bz2
Source1: openEuler_riscv64_defconfig
Source2: 0001-PATCH-Build-fix-compile-error-of-iommu_bind_guest_ms.patch
BuildRequires: module-init-tools, patch >= 2.5.4, bash >= 2.03, tar
BuildRequires: bzip2, xz, findutils, gzip, m4, perl, make >= 3.78, diffutils, gawk
BuildRequires: gcc >= 3.4.2, binutils >= 2.12
BuildRequires: hostname, net-tools, bc
BuildRequires: xmlto, asciidoc
BuildRequires: openssl-devel
BuildRequires: ncurses-devel
BuildRequires: elfutils-libelf-devel
BuildRequires: rpm >= 4.14.2
BuildRequires: elfutils-devel zlib-devel binutils-devel newt-devel python-devel perl(ExtUtils::Embed) bison
BuildRequires: audit-libs-devel
BuildRequires: pciutils-devel gettext
BuildRequires: rpm-build, elfutils
BuildRequires: numactl-devel python3-devel glibc-static python3-docutils
BuildRequires: perl-generators perl(Carp) gtk2-devel libbabeltrace-devel
BuildRequires: rsync
AutoReq: no
AutoProv: yes
Provides:kernel-%{_target_cpu} = %{version}-%{release}
ExclusiveArch: riscv64
ExclusiveOS: Linux
%ifarch riscv64
%define arch_config %{SOURCE1}
%define hd_arch riscv
%endif
%description
This is the Linux kernel Image for RISC-V openSBI(Supervisor Binary Interface) booting with QEMU RISC-V virt machine.
%package devel
Summary: Development package for building kernel modules to match the %{KernelVer} kernel
AutoReqProv: no
Provides: %{name}-headers = %{version}
Obsoletes: %{name}-headers < %{version}
Provides: glibc-kernheaders
Provides: kernel-devel-uname-r = %{KernelVer}
%description devel
This package provides kernel headers and makefiles sufficient to build modules.
%if 0%{?with_perf}
%package -n perf
Summary: Performance monitoring for the Linux kernel
%description -n perf
This package contains the perf tool, which enables performance monitoring
of the Linux kernel.
%if 0%{?with_python2}
%package -n python2-perf
Provides: python-perf = %{version}-%{release}
Obsoletes: python-perf
Summary: Python bindings for apps which will manipulate perf events
%description -n python2-perf
A Python module that permits applications written in the Python programming
language to use the interface to manipulate perf events.
%endif
%package -n python3-perf
Summary: Python bindings for apps which will manipulate perf events
%description -n python3-perf
A Python module that permits applications written in the Python programming
language to use the interface to manipulate perf events.
# with_perf
%endif
%package -n bpftool
Summary: Inspection and simple manipulation of eBPF programs and maps
%description -n bpftool
This package contains the bpftool, which allows inspection and simple
manipulation of eBPF programs and maps.
%if 0%{?with_source}
%package source
Summary: the kernel source
%description source
This package contains various source files from the kernel.
%endif
%package headers
Summary: Header files for the Linux kernel for use by glibc
Obsoletes: glibc-kernheaders < 3.0-46
Provides: glibc-kernheaders = 3.0-46
%description headers
Kernel-headers includes the C header files that specify the interface
between the Linux kernel and userspace libraries and programs. The
header files define structures and constants that are needed for
building most standard programs and are also needed for rebuilding the
glibc package.
%prep
%setup -n risc-v-kernel-%{version} -c
mv ./risc-v-kernel-%{version}/kernel linux-%{KernelVer}
cd linux-%{KernelVer}
# a temporary patch to fix compile error
patch -p1 < %{SOURCE2}
find . \( -name "*.orig" -o -name "*~" -o -name "\.*" \) -exec rm -f {} \; >/dev/null
find . -name .gitignore -exec rm -f {} \; >/dev/null
%if 0%{?with_source}
# Copy directory backup for kernel-source
cp -a ../linux-%{KernelVer} ../linux-%{KernelVer}-source
%endif
%build
cd linux-%{KernelVer}
# merge additional configure to defconfig
ARCH=$(head -1 %{arch_config} | gawk -F' ' '{print $2}')
cat %{arch_config} >> arch/${ARCH}/configs/defconfig
make -s mrproper
make ARCH=${ARCH} defconfig
make ARCH=${ARCH} %{?_smp_mflags}
make ARCH=${ARCH} %{?_smp_mflags} modules
# bpftool
pushd tools/bpf/bpftool
make %{?_smp_mflags}
popd
%install
%if 0%{?with_source}
%define _python_bytecompile_errors_terminate_build 0
mkdir -p $RPM_BUILD_ROOT/usr/src/
mv linux-%{KernelVer}-source $RPM_BUILD_ROOT/usr/src/linux-%{KernelVer}
cp linux-%{KernelVer}/.config $RPM_BUILD_ROOT/usr/src/linux-%{KernelVer}/
%endif
cd linux-%{KernelVer}
# Currently need the flatten kernel image as opensbi payload
TargetImage=$(find . -name Image)
TargetgzImage=$(find . -name Image.gz)
mkdir -p $RPM_BUILD_ROOT/boot
install -m 755 ${TargetImage} $RPM_BUILD_ROOT/boot
install -m 755 ${TargetgzImage} $RPM_BUILD_ROOT/boot
install -m 644 .config $RPM_BUILD_ROOT/boot/config-%{KernelVer}
# kernel_headers
make ARCH=%{hd_arch} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install
make ARCH=%{hd_arch} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_check
find $RPM_BUILD_ROOT/usr/include -name "\.*" -exec rm -f {} \; >/dev/null
# modules
make ARCH=%{hd_arch} INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=%{KernelVer} mod-fw=
make ARCH=%{hd_arch} INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=%{KernelVer}
# bpftool
pushd tools/bpf/bpftool
make DESTDIR=%{buildroot} prefix=%{_prefix} bash_compdir=%{_sysconfdir}/bash_completion.d/ mandir=%{_mandir} install doc-install
popd
############ to do collect devel file #########
# deal with /lib/module/ path- sub path: build source kernel
rm -f $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build
rm -f $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/source
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/extra
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/updates
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/weak-updates
# 1. Makefile And Kconfig, .config sysmbol
# 2. scrpits dir
# 3. .h file
find -type f \( -name "Makefile*" -o -name "Kconfig*" \) -exec cp --parents {} $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build \;
for f in Module.symvers System.map Module.markers .config;do
test -f $f || continue
cp $f $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build
done
cp -a scripts $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build
if [ -d arch/%{Arch}/scripts ]; then
cp -a arch/%{Arch}/scripts $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/arch/%{_arch} || :
fi
if [ -f arch/%{Arch}/*lds ]; then
cp -a arch/%{Arch}/*lds $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/arch/%{_arch}/ || :
fi
find $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/scripts/ -name "*.o" -exec rm -rf {} \;
if [ -d arch/%{Arch}/include ]; then
cp -a --parents arch/%{Arch}/include $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/
fi
cp -a include $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/include
%ifarch aarch64
# Needed for systemtap
cp -a --parents arch/arm64/kernel/module.lds $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/
cp -a --parents arch/arm/include/asm $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/
%endif
# copy objtool for kernel-devel (needed for building external modules)
if grep -q CONFIG_STACK_VALIDATION=y .config; then
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/tools/objtool
cp -a tools/objtool/objtool $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/tools/objtool
fi
# Make sure the Makefile and version.h have a matching timestamp so that
# external modules can be built
touch -r $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/Makefile $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/include/generated/uapi/linux/version.h
touch -r $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/.config $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/include/generated/autoconf.h
# for make prepare
if [ ! -f $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/include/config/auto.conf ];then
cp .config $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build/include/config/auto.conf
fi
# mv modules to src/kernels/ver
mkdir -p %{buildroot}/usr/src/kernels
mv $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/build $RPM_BUILD_ROOT/usr/src/kernels/%{KernelVer}
find $RPM_BUILD_ROOT/usr/src/linux-%{KernelVer} -name ".*.cmd" -exec rm -f {} \;
pushd $RPM_BUILD_ROOT/lib/modules/%{KernelVer}
ln -sf /usr/src/kernels/%{KernelVer} build
ln -sf build source
popd
%files
%defattr (-, root, root)
%doc
/boot/config-*
/boot/Image*
/lib/modules/%{KernelVer}/
%exclude /lib/modules/%{KernelVer}/source
%files devel
%defattr (-, root, root)
%doc
/lib/modules/%{KernelVer}/source
/lib/modules/%{KernelVer}/build
/usr/src/kernels/%{KernelVer}
%files headers
%defattr (-, root, root)
/usr/include/*
%files -n bpftool
%{_sbindir}/bpftool
%{_sysconfdir}/bash_completion.d/bpftool
%{_mandir}/man8/bpftool-cgroup.8.gz
%{_mandir}/man8/bpftool-map.8.gz
%{_mandir}/man8/bpftool-prog.8.gz
%{_mandir}/man8/bpftool-perf.8.gz
%{_mandir}/man8/bpftool.8.gz
%{_mandir}/man8/bpftool-btf.8.gz
%{_mandir}/man8/bpftool-feature.8.gz
%{_mandir}/man8/bpftool-gen.8.gz
%{_mandir}/man8/bpftool-iter.8.gz
%{_mandir}/man8/bpftool-link.8.gz
%{_mandir}/man8/bpftool-net.8.gz
%{_mandir}/man8/bpftool-struct_ops.8.gz
%{_mandir}/man7/bpf-helpers.7.gz
%license linux-%{KernelVer}/COPYING
%if 0%{?with_source}
%files source
%defattr(-,root,root)
/usr/src/linux-%{KernelVer}/*
/usr/src/linux-%{KernelVer}/.config
%endif
%changelog
* Wed Aug 11 2021 whoisxxx <zhangxuzhou4@huawei.com> -5.10-3-riscv64
- Make kernel source as a submodule of risc-v-kernel
* Tue Jul 27 2021 whoisxxx <zhangxuzhou4@huawei.com> -5.10-2-riscv64
- Add subpackages: kernel-headers bpftool source;
- Disable bytecompile error terminate build
* Fri Apr 23 2021 whoisxxx <zhangxuzhou4@huawei.com> -5.10-1-riscv64
- Update to openEuler OLK-5.10
* Sat Oct 31 2020 whoisxxx <zhangxuzhou4@huawei.com> -5.5.19-3-riscv64
- kernel.spec: Delete redundant definition in KernelVer
* Mon Oct 12 2020 liyuanr <liyuanrong1@huawei.com> -5.5.19-2-riscv64
- kernel.spec: Add collection of devel file
* Tue Jul 28 2020 whoisxxx <zhangxuzhou4@huawei.com> - 5.5.19-1-riscv64
- Build the flatten Linux Kernel 5.5.19 Image for openEuler RISC-V
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/baiguoguo/risc-v-kernel.git
git@gitee.com:baiguoguo/risc-v-kernel.git
baiguoguo
risc-v-kernel
risc-v-kernel
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385