Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 17 additions & 166 deletions SPECS/linux-lts-kmhv2/linux-lts-kmhv2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,18 @@
# SPDX-FileContributor: Jingwiw <wangjingwei@iscas.ac.cn>
# SPDX-FileContributor: Zheng Junjie <zhengjunjie@iscas.ac.cn>
# SPDX-FileContributor: misaka00251 <liuxin@iscas.ac.cn>
# SPDX-FileContributor: Hangfan Li <lihangfan@iscas.ac.cn>
#
# SPDX-License-Identifier: MulanPSL-2.0

%bcond rust 1

%global modpath %{_prefix}/lib/modules/%{kver}

%ifarch riscv64
#!BuildConstraint: hardware:jobs 32
%endif

# Whether dtbs needed for arch
%ifarch riscv64
%global need_dtbs 1
%bcond dtbs 1
%else
%global need_dtbs 0
%bcond dtbs 0
%endif
%bcond rust 1

%global kver %{version}-%{release}
%global kernel_make_flags LD=ld.bfd KBUILD_BUILD_VERSION=%{release}

%if "%{?openruyi_riscv_arch}" == "-march=rva20u64"
%global arch_suffix -rva20
%else
%global arch_suffix %{nil}
%endif
%global variant_name lts-kmhv2

Name: linux-lts-kmhv2
Version: 6.18.38
Expand All @@ -46,161 +32,26 @@ Source4: config.riscv64-rva20

ExclusiveArch: riscv64

BuildRequires: gcc
BuildRequires: bison
BuildRequires: binutils
BuildRequires: glibc-devel
BuildRequires: make
BuildRequires: perl
BuildRequires: flex
BuildRequires: bc
BuildRequires: cpio
BuildRequires: dwarves
BuildRequires: gettext
BuildRequires: python3
BuildRequires: rsync
BuildRequires: tar
BuildRequires: xz
BuildRequires: zstd
BuildRequires: libdebuginfod-dummy-devel
BuildRequires: pkgconfig(ncurses)
BuildRequires: pkgconfig(libcap)
BuildRequires: pkgconfig(libssh)
BuildRequires: pkgconfig(libdw)
BuildRequires: pkgconfig(libelf)
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(python3)
BuildRequires: pkgconfig(slang)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(openssl)
BuildRequires: kmod
BuildRequires: rpm-config-openruyi

%if %{with rust}
BuildRequires: bindgen
BuildRequires: cargo
BuildRequires: rust
%if "%{?openruyi_riscv_arch}" == "-march=rva20u64"
%global arch_suffix -rva20
%else
%global arch_suffix %{nil}
%endif

Requires: %{name}-core%{?_isa} = %{version}-%{release}
Requires: %{name}-modules%{?_isa} = %{version}-%{release}
%if %{need_dtbs}
Requires: %{name}-dtbs%{?_isa} = %{version}-%{release}
%endif
Requires(post): kmod
Requires(post): kernel-install
Requires(postun): kernel-install
BuildSystem: linux
BuildOption(prep): -n linux-%{version} -p1
BuildOption(conf): %{_sourcedir}/config.%{_arch}%{arch_suffix}

BuildRequires: openruyi-linux-build
%linux_package_dependencies

%patchlist
%include %{SOURCE1}

%description
This is a meta-package that installs the core kernel image and modules.
For a minimal boot environment, install the 'linux-core' package instead.

%package core
Summary: The core Linux kernel image and initrd

%description core
Contains the bootable kernel image (vmlinuz) and a generic, pre-built initrd,
providing the minimal set of files needed to boot the system.

%package modules
Summary: Kernel modules for the Linux kernel
Requires: %{name}-core = %{version}-%{release}

%description modules
Contains all the kernel modules (.ko files) and associated metadata for
the hardware drivers and kernel features.

%package devel
Summary: Development files for building external kernel modules
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: dwarves
This is the meta package that handles standard %{name} kernel installation.

%description devel
This package provides the kernel headers and Makefiles necessary to build
external kernel modules against the installed kernel. The development files are
located at %{_usrsrc}/kernels/%{kver}, with symlinks provided under
%{_prefix}/lib/modules/%{kver}/ for compatibility.

%if %{need_dtbs}
%package dtbs
Summary: Devicetree blob files from Linux sources

%description dtbs
This package provides the DTB files built from Linux sources that may be used
for booting.
%endif

%prep
%autosetup -p1 -n linux-%{version}
cp -v %{_sourcedir}/config.%{_arch}%{arch_suffix} .config
echo "-%{release}" > localversion

%conf
%make_build %{kernel_make_flags} olddefconfig

%build

%make_build %{kernel_make_flags}

%if %{need_dtbs}
%make_build %{kernel_make_flags} dtbs
%endif

%install
%define ksrcpath %{buildroot}%{_usrsrc}/kernels/%{kver}
install -d %{buildroot}%{modpath} %{ksrcpath}

%make_build %{kernel_make_flags} INSTALL_MOD_PATH=%{buildroot}%{_prefix} INSTALL_MOD_STRIP=1 DEPMOD=true modules_install

%if %{need_dtbs}
%make_build %{kernel_make_flags} INSTALL_DTBS_PATH=%{buildroot}%{modpath}/dtb dtbs_install
%endif

%make_build run-command %{kernel_make_flags} KBUILD_RUN_COMMAND="$(pwd)/scripts/package/install-extmod-build %{ksrcpath}"

pushd %{buildroot}%{modpath}
rm -f build source
ln -sf %{_usrsrc}/kernels/%{kver} build
ln -sf %{_usrsrc}/kernels/%{kver} source
popd

install -Dm644 $(make %{kernel_make_flags} -s image_name) %{buildroot}%{modpath}/vmlinuz

echo "Module signing would happen here for version %{kver}."

%post
%{_bindir}/kernel-install add %{kver} %{modpath}/vmlinuz

%postun
if [ $1 -eq 0 ] ; then
%{_bindir}/kernel-install remove %{kver}
fi

%files
%license COPYING
%doc README

%files core
%{modpath}/vmlinuz

%files modules
%{modpath}/*
%exclude %{modpath}/vmlinuz
%exclude %{modpath}/build
%exclude %{modpath}/source

%files devel
%{_usrsrc}/kernels/%{kver}/
%{modpath}/build
%{modpath}/source

%if %{need_dtbs}
%files dtbs
%{modpath}/dtb
%endif
%linux_package_implementation

%changelog
%autochangelog
Loading
Loading