1 Star 0 Fork 1.3K

wangjunqiang / d1-kernel

forked from openEuler / kernel 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
kernel.spec 11.68 KB
一键复制 编辑 原始数据 按行查看 历史
wangjunqiang 提交于 2022-12-10 06:35 . update kernel.spec.
%define kernelversion 6.1.0
%define rctag rc3
%define pkg_release 3.%{?rctag}
%define KernelVer %{kernelversion}-%{?rctag}
# 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
%define with_release 1
%global debug_package %{nil}
Name: kernel
Version: %{kernelversion}
Release: %{pkg_release}
Summary: Linux Kernel for RISC-V
URL: http://www.kernel.org/
License: GPLv2
# 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: extend_defconfig
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} linux-%{KernelVer}
cd linux-%{KernelVer}
touch .scmversion
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}
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}.%{_target_cpu}/" Makefile
# merge additional configure to defconfig
ARCH=$(head -1 %{arch_config} | gawk -F' ' '{print $2}')
cat %{arch_config} >> arch/${ARCH}/configs/nezha_defconfig
cat %{SOURCE2} >> arch/${ARCH}/configs/nezha_defconfig
perl -p -i -e 's/^CONFIG_LOCALVERSION.*/CONFIG_LOCALVERSION=""/' arch/${ARCH}/configs/nezha_defconfig
make -s mrproper
make ARCH=${ARCH} nezha_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}
mkdir -p $RPM_BUILD_ROOT/boot
install -m 644 .config $RPM_BUILD_ROOT/boot/config-%{KernelVer}
# Currently need the flatten kernel image as opensbi payload
%if 0%{!?with_release}
TargetImage=$(find . -name Image)
TargetgzImage=$(find . -name Image.gz)
install -m 755 ${TargetImage} $RPM_BUILD_ROOT/boot
install -m 755 ${TargetgzImage} $RPM_BUILD_ROOT/boot
%else
make ARCH=%{hd_arch} INSTALL_PATH=$RPM_BUILD_ROOT/boot zinstall KERNELRELEASE=%{KernelVer}
dd if=/dev/zero of=$RPM_BUILD_ROOT/boot/initramfs-%{KernelVer}.img bs=1M count=20
%endif
mkdir -p $RPM_BUILD_ROOT/boot/dtbs
make ARCH=%{hd_arch} INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/boot/dtbs dtbs_install KERNELRELEASE=%{KernelVer}
# kernel_headers
make ARCH=%{hd_arch} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install
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}
%if 0%{?with_release}
install -m 644 .config $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/config
install -m 644 System.map $RPM_BUILD_ROOT/lib/modules/%{KernelVer}/System.map
%endif
# 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-*
%if 0%{!?with_release}
/boot/Image*
/boot/*.dtb
%else
/boot/System.map-*
/boot/vmlinuz-*
/boot/initramfs-*
%dir /boot/dtbs/
/boot/dtbs/*
%endif
/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
%license linux-%{KernelVer}/COPYING
%if 0%{?with_source}
%files source
%defattr(-,root,root)
/usr/src/linux-%{KernelVer}/*
/usr/src/linux-%{KernelVer}/.config
%endif
%changelog
* Mon Nov 28 2022 wangjunqiang <wangjunqiang@iscas.ac.cn> -6.1.0-3-riscv64
- Update to 6.1.0-rc3
* Mon Nov 28 2022 wangjunqiang <wangjunqiang@iscas.ac.cn> -5.19.0-3-riscv64
- add release format
* Thu Oct 13 2022 jchzhou <zhoujiacheng@iscas.ac.cn> -5.19.0-2-riscv64
- Add defconfig for consistency with other hardware
* Wed Oct 12 2022 wangjunqiang <wangjunqiang@iscas.ac.cn> -5.19.0-1-riscv64
- Update to D1 official repo version
* Fri Apr 15 2022 wangjunqiang <wangjunqiang@iscas.ac.cn> -5.18-1-riscv64
- Update to D1 official repo version
* 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
C
1
https://gitee.com/geasscore/d1-kernel.git
git@gitee.com:geasscore/d1-kernel.git
geasscore
d1-kernel
d1-kernel
rpm

搜索帮助