From bd63422ec57131805c4a71b81e1c09b07315429d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Thu, 9 Feb 2023 21:21:31 +0100 Subject: [PATCH] packaging: Add spec file for VisionFive MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I5ebe0cb8d04662835cb59d68b9be8edb4f4d7e4d Signed-off-by: Łukasz Stelmach --- .gbs.conf | 4 + packaging/linux-visionfive.spec | 295 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 .gbs.conf create mode 100644 packaging/linux-visionfive.spec diff --git a/.gbs.conf b/.gbs.conf new file mode 100644 index 0000000..f744dba --- /dev/null +++ b/.gbs.conf @@ -0,0 +1,4 @@ +[general] +upstream_branch = upstream +upstream_tag = v${upstreamversion} +squash_patches_until = HEAD~10 diff --git a/packaging/linux-visionfive.spec b/packaging/linux-visionfive.spec new file mode 100644 index 0000000..ee3afa9 --- /dev/null +++ b/packaging/linux-visionfive.spec @@ -0,0 +1,295 @@ +# Ignore double dash in version for rpmbuild +%define _wrong_version_format_terminate_build 0 + +%define tizen_kernel_config_dir %{_datadir}/tizen-kernel-configs +%define config_name starfive_visionfive2_defconfig +%define buildarch riscv +%define target_board visionfive +%define variant %{buildarch}-%{target_board} + +# 0 until linux-rt available for 6.1 +%define build_rt 0 + +Name: visionfive-linux-kernel +Summary: The Linux Kernel for VisionFive2 +Version: 6.1.10 +Release: 0 +License: GPL-2.0 +ExclusiveArch: riscv64 +Group: System/Kernel +Vendor: The Linux Community +URL: https://www.kernel.org +Source0: linux-kernel-%{version}.tar.xz +BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root + +%define fullVersion %{version}-%{variant} + +BuildRequires: bc +BuildRequires: module-init-tools +BuildRequires: bison +BuildRequires: flex +BuildRequires: libopenssl1.1-devel +BuildRequires: libunwind-devel +BuildRequires: libdw-devel +BuildRequires: libelf-devel +BuildRequires: elfutils +BuildRequires: xz-devel +BuildRequires: binutils-devel +BuildRequires: python3 +BuildRequires: rsync +BuildRequires: tizen-kernel-configs + +%description +The Linux Kernel, the operating system core itself + +# kernel +%package -n %{variant}-linux-kernel +License: GPL-2.0 +Summary: Tizen kernel for %{target_board} +Group: System/Kernel +Provides: %{variant}-kernel-uname-r = %{fullVersion} +Provides: linux-kernel = %{version}-%{release} + +%description -n %{variant}-linux-kernel +This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board}) + +%if %{build_rt} +%package -n %{variant}-rt-linux-kernel +License: GPL-2.0 +Summary: Tizen kernel for %{target_board} +Group: System/Kernel +Provides: %{variant}-kernel-uname-r = %{fullVersion}-rt +Provides: linux-kernel = %{version}-%{release}-rt + +%description -n %{variant}-rt-linux-kernel +This package contains the Linux kernel for Tizen (arch %{buildarch}, target board %{target_board}) +%endif + +# modules + +%package -n %{variant}-linux-kernel-modules +Summary: Kernel modules for %{target_board} +Group: System/Kernel +Provides: %{variant}-kernel-modules = %{fullVersion} +Provides: %{variant}-kernel-modules-uname-r = %{fullVersion} + +%description -n %{variant}-linux-kernel-modules +Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board} + +%if %{build_rt} +%package -n %{variant}-rt-linux-kernel-modules +Summary: Kernel modules for %{target_board} +Group: System/Kernel +Provides: %{variant}-kernel-modules = %{fullVersion}-rt +Provides: %{variant}-kernel-modules-uname-r = %{fullVersion}-rt + +%description -n %{variant}-rt-linux-kernel-modules +Kernel-modules includes the loadable kernel modules(.ko files) for %{target_board} +with the PREEMPT_RT patch +%endif + +# devel + +%package -n %{variant}-linux-kernel-devel +License: GPL-2.0 +Summary: Linux support kernel map and etc for other packages +Group: System/Kernel +Provides: %{variant}-kernel-devel = %{fullVersion} +Provides: %{variant}-kernel-devel-uname-r = %{fullVersion} + +%description -n %{variant}-linux-kernel-devel +This package provides kernel map and etc information. + +%if %{build_rt} +%package -n %{variant}-rt-linux-kernel-devel +License: GPL-2.0 +Summary: Linux support kernel map and etc for other packages +Group: System/Kernel +Provides: %{variant}-kernel-devel = %{fullVersion}-rt +Provides: %{variant}-kernel-devel-uname-r = %{fullVersion}-rt + +%description -n %{variant}-rt-linux-kernel-devel +This package provides kernel map and etc information. +%endif + +#headers +%package -n %{variant}-linux-kernel-headers +License: GPL-2.0 +Summary: Linux support headers for userspace development +Group: System/Kernel +Provides: kernel-headers-tizen-dev + +%description -n %{variant}-linux-kernel-headers +This package provides userspaces headers from the Linux kernel. These +headers are used by the installed headers for GNU glibc and other system + libraries. + +%package -n linux-kernel-perf +Summary: The perf performance counter tool +Group: System/Kernel +Provides: perf = %{version} + +%description -n linux-kernel-perf +This package provides the "perf" tool that can be used to monitor performance +counter events as well as various kernel internal events. + +%prep +%setup -q + +%build +%{?asan:/usr/bin/gcc-unforce-options} +%{?ubsan:/usr/bin/gcc-unforce-options} + +# Here be %{variant} %{variant}-rt +for target in %{variant}; do + echo "-${target}" > localversion-tizen + + # extract uapi headers + make O=build/${target} headers_install %{?_smp_mflags} + + # Set config file + case $target in + %{variant}) + ./scripts/kconfig/merge_config.sh -O build/${target} \ + %{tizen_kernel_config_dir}/references/%{buildarch}/%{config_name} \ + %{tizen_kernel_config_dir}/tizen/tizen_defconfig + + # Build perf + make O=build/${target} -s -C tools/lib/traceevent %{?_smp_mflags} + make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" %{?_smp_mflags} + ;; + %{variant}-rt) + cat _localversion-rt > localversion-rt + ./scripts/kconfig/merge_config.sh -O build/${target} \ + %{tizen_kernel_config_dir}/references/%{buildarch}/%{config_name} \ + %{tizen_kernel_config_dir}/tizen/tizen_defconfig \ + %{tizen_kernel_config_dir}/tizen/tizen_rt.config + ;; + esac + + # Build Image/Image.gz + make O=build/${target} %{?_smp_mflags} + + # Build dtbs + make O=build/${target} dtbs %{?_smp_mflags} + + # Build modules + make O=build/${target} modules %{?_smp_mflags} +done + +%install +QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT + +# Destination directories +mkdir -p %{buildroot}/boot +mkdir -p %{buildroot}/lib/modules + +# Install boot binary files +# Here be SPL & OpenSBI + +# Install kernel DTB +install -m 644 build/%{variant}/arch/%{buildarch}/boot/dts/starfive/jh71*.dtb %{buildroot}/boot/ +mkdir -p %{buildroot}/boot/overlays + +# Install kernel headers +make O=build/%{variant} headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr + +# Here be %{variant} %{variant}-rt +for target in %{variant}; do + # Install kernel binary + case $target in + %{variant}) + install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image + + # Install perf + make O=build/${target} -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" DESTDIR=%{buildroot}/usr install + rm -rf %{buildroot}/usr/etc + rm -rf %{buildroot}/usr/lib/debug + rm -rf %{buildroot}/usr/lib/perf + rm -rf %{buildroot}/usr/share + + ;; + %{variant}-rt) + install -m 644 build/${target}/arch/%{buildarch}/boot/Image %{buildroot}/boot/Image_rt + ;; + esac + + # Install modules + make O=build/${target} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install + + # Copy files for devel package + mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-${target} + rsync -r \ + --include "/scripts/**.c" \ + --exclude "/debug*.list" \ + --exclude "/documentation.list" \ + --exclude "/*.manifest" \ + --exclude "/packaging/" \ + --exclude "/.gbs.conf" \ + --exclude "/.git**" \ + --exclude ".gitignore" \ + --exclude "*\.c" \ + --exclude ".tmp_vmlinux*" \ + --exclude ".*dtb*tmp" \ + --exclude ".*dtb" \ + --exclude "*.*tmp" \ + --exclude "vmlinux" \ + --exclude "Image" \ + --exclude "zImage" \ + --exclude "Image.gz" \ + --exclude "*.cmd" \ + --exclude "*.ko" \ + --exclude "*.o" \ + --exclude "*.S" \ + --exclude "*.HEX" \ + --exclude "/build/" \ + ./ build/${target}/ %{buildroot}/boot/kernel/devel/kernel-devel-${target} +done + +%clean +rm -rf %{buildroot} + +%if %{build_rt} +%post -n %{variant}-rt-linux-kernel +mv /boot/Image_rt /boot/Image + +%preun -n %{variant}-rt-linux-kernel +mv /boot/Image /boot/Image_rt +%endif + +%files -n %{variant}-linux-kernel-modules +/lib/modules/*%{variant}/ + +%if %{build_rt} +%files -n %{variant}-rt-linux-kernel-modules +/lib/modules/*%{variant}-rt/ +%endif + +%files -n %{variant}-linux-kernel-devel +/boot/kernel/devel/*%{variant}/ + +%if %{build_rt} +%files -n %{variant}-rt-linux-kernel-devel +/boot/kernel/devel/*%{variant}-rt/ +%endif + +%files -n %{variant}-linux-kernel +%license COPYING +/boot/Image +/boot/jh71*.dtb + +%if %{build_rt} +%files -n %{variant}-rt-linux-kernel +%license COPYING +/boot/Image_rt +/boot/jh71*.dtb +%endif + +%files -n %{variant}-linux-kernel-headers +/usr/include/* + +%files -n linux-kernel-perf +%license COPYING +/usr/bin/* +/usr/libexec/* +/usr/lib/traceevent/* -- 2.7.4