packaging: add rpm packaging spec 47/315547/1
authorYongtaek Jeon <ytjeon@samsung.com>
Fri, 29 Nov 2024 00:40:39 +0000 (09:40 +0900)
committerYongtaek Jeon <ytjeon@samsung.com>
Tue, 3 Dec 2024 04:48:00 +0000 (13:48 +0900)
For tizen packaging, add rpm packaging spec to build kvim board.

Changes compared to linux-amlogic v4.9.
- Update the Version tag.
- Add python3-devel support for build dependencies.
- Add make option for perf installation to include NO_LIBTRACEEVENT=1.
- Remove traceevent library files during the installation process.
- Change kernel image location(/boot/Image.gz).

Change-Id: I876217310f04b8f2d6fc3a6cc4126ac1c8470805
Signed-off-by: Yongtaek Jeon <ytjeon@samsung.com>
packaging/linux-amlogic.spec [new file with mode: 0644]

diff --git a/packaging/linux-amlogic.spec b/packaging/linux-amlogic.spec
new file mode 100644 (file)
index 0000000..aadf488
--- /dev/null
@@ -0,0 +1,234 @@
+# Ignore double dash in version for rpmbuild
+%define _wrong_version_format_terminate_build 0
+
+%ifarch aarch64
+%define buildarch arm64
+%define KERNEL_IMAGE Image.gz
+%else
+%define buildarch arm
+%define KERNEL_IMAGE zImage
+%endif
+
+%define CHIPSET amlogic
+%define TARGET_VIMS kvim
+%define VIMS_DT_PREFIX meson
+%define TARGETS %{TARGET_VIMS}
+
+Name: linux-amlogic
+Summary: The Linux Kernel for amlogic boards
+Version: 6.12
+Release: 0
+License: GPL-2.0
+ExclusiveArch: %{arm} aarch64
+Group: System/Kernel
+Vendor: The Linux Community
+URL: https://www.kernel.org
+Source0: %{name}-%{version}.tar.xz
+
+BuildRequires: bc
+BuildRequires: module-init-tools
+BuildRequires: bison
+BuildRequires: flex
+BuildRequires: pkgconfig(openssl3)
+BuildRequires: libunwind-devel
+BuildRequires: libdw-devel
+BuildRequires: libelf-devel
+BuildRequires: elfutils
+BuildRequires: xz-devel
+BuildRequires: binutils-devel
+BuildRequires: rsync
+BuildRequires: python3-devel
+
+%description
+The Linux Kernel, the operating system core itself
+
+## Start of Packages lists
+# kernel-headers package for all amlogic targets both for arm and arm64
+%package -n kernel-headers-amlogic
+License: GPL-2.0
+Summary: Linux support headers for amlogic userspace development
+Group: System/Kernel
+Provides: kernel-headers-tizen-dev
+Provides: kernel-headers-amlogic-kvim = %{version}_%{CHIPSET}_kvim
+
+%description -n kernel-headers-amlogic
+This package provides userspaces headers from the Linux kernel for Amlogic.
+These headers are used by the installed headers for GNU glibc and other
+system libraries.
+
+# ARM64 Build result pagckages for each target
+%ifarch aarch64
+%package -n linux-kernel-amlogic-kvim
+License: GPL-2.0
+Summary: Tizen kernel for amlogic kadas vim3/vim3l boards
+Group: System/Kernel
+Provides: linux-amlogic-kvim = %{version}_%{CHIPSET}_kvim
+
+%description -n linux-kernel-amlogic-kvim
+This package contains the Tizen Linux kernel for amlogic khadas vim3/vim3l boards
+
+%package -n linux-kernel-modules-amlogic-kvim
+Summary: Kernel modules for amlogic khadas vim3/vim3l boards
+Group: System/Kernel
+Provides: linux-kernel-modules-amlogic-kvim = %{version}_%{CHIPSET}_kvim
+
+%description -n linux-kernel-modules-amlogic-kvim
+Kernel-modules includes the loadable kernel modules(.ko files) for amlogic khadas vim3/vim3l
+
+%package -n linux-kernel-devel-amlogic-kvim
+License: GPL-2.0
+Summary: Linux support kernel map and etc for other packages
+Group: System/Kernel
+Provides: linux-kernel-devel-amlogic-kvim = %{version}_%{CHIPSET}_kvim
+
+%description -n linux-kernel-devel-amlogic-kvim
+This package provides kernel map and etc information.
+
+%endif
+
+%package -n linux-kernel-perf
+Summary: The perf performance counter tool
+Group: System/Kernel
+Provides: perf = %{version}_%{buildarch}_%{CHIPSET}
+
+%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.
+## End of Packages lists
+
+%prep
+%setup -q
+
+%build
+%{?asan:/usr/bin/gcc-unforce-options}
+%{?ubsan:/usr/bin/gcc-unforce-options}
+
+## Start of Build steps
+
+# Build for each target for arm64
+%ifarch aarch64
+for target_board in %{TARGETS}; do
+       %define variant TIZEN-%{CHIPSET}-${target_board}
+
+       mkdir -p %{_builddir}/build/${target_board}
+       echo "-%{variant}" > %{_builddir}/build/${target_board}/localversion-tizen
+
+       case $target_board in
+       %{TARGET_VIMS})
+               CONFIG_NAME=kvims
+               DT_PREFIX=%{VIMS_DT_PREFIX}
+       ;;
+       esac
+
+       # Set defconfig file
+       rm -f %{_builddir}/build/${target_board}/.config
+       make O=%{_builddir}/build/${target_board} tizen_${CONFIG_NAME}_defconfig
+
+       # Build kernel image, dtb and modules
+       make O=%{_builddir}/build/${target_board} %{KERNEL_IMAGE} %{?_smp_mflags}
+       make O=%{_builddir}/build/${target_board} dtbs %{?_smp_mflags}
+       make O=%{_builddir}/build/${target_board} modules %{?_smp_mflags}
+done
+%endif
+## End of Build steps
+
+%install
+## Start of install steps
+QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT
+
+rm -f localversion*
+
+# Install files for arm64
+
+# Install uapi headers
+make headers_install %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr
+find %{buildroot}/usr \( -name .install -o -name ..install.cmd \) -delete
+make mrproper
+
+%ifarch aarch64
+# Install files
+for target_board in %{TARGETS}; do
+       case $target_board in
+       %{TARGET_VIMS})
+               DT_PREFIX=%{VIMS_DT_PREFIX}
+               ;;
+       esac
+
+       mkdir -p %{buildroot}/boot/${target_board}/kernel/devel/
+
+       install -m 644 %{_builddir}/build/${target_board}/arch/%{buildarch}/boot/%{KERNEL_IMAGE} %{buildroot}/boot/
+       install -m 644 %{_builddir}/build/${target_board}/arch/%{buildarch}/boot/dts/amlogic/${DT_PREFIX}*.dtb %{buildroot}/boot/
+       make O=%{_builddir}/build/${target_board} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install
+
+       rsync -lr \
+             --include "/scripts/**.c" \
+             --exclude ".install" \
+             --exclude "..install.cmd" \
+             --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" \
+             ./ %{_builddir}/build/${target_board}/ %{buildroot}/boot/${target_board}/kernel/devel/
+
+       rm -f %{buildroot}/lib/modules/*${target_board}*/build \
+             %{buildroot}/lib/modules/*${target_board}*/source \
+              %{buildroot}/boot/${target_board}/kernel/devel/source
+done
+%endif
+
+# Install perf
+install -d %{buildroot}/usr
+WERROR=0 make -s -C tools/perf EXTRA_CFLAGS="-fPIE -rdynamic" DESTDIR=%{buildroot}/usr install NO_LIBTRACEEVENT=1
+rm -rf %{buildroot}/usr/etc
+rm -rf %{buildroot}/usr/lib/debug
+rm -rf %{buildroot}/usr/lib/perf
+rm -rf %{buildroot}/usr/share
+# End of install steps
+
+%clean
+rm -rf %{buildroot}
+rm -rf %{_builddir}/usr
+rm -rf %{_builddir}/boot
+rm -rf %{_builddir}/lib
+
+## Start of rpm pack
+# uapi headers
+%files -n kernel-headers-amlogic
+/usr/include/*
+
+# ARM64 Build result pagckages for each target
+%ifarch aarch64
+%files -n linux-kernel-amlogic-kvim
+%license COPYING
+/boot/%{VIMS_DT_PREFIX}*.dtb
+/boot/%{KERNEL_IMAGE}
+
+%files -n linux-kernel-modules-amlogic-kvim
+/lib/modules/*%{TARGET_VIMS}/*
+
+%files -n linux-kernel-devel-amlogic-kvim
+/boot/%{TARGET_VIMS}/kernel/*
+%endif
+
+%files -n linux-kernel-perf
+%license COPYING
+/usr/bin/*
+/usr/libexec/*
+## End of rpm pack