File raspberrypi-userland.spec of Package raspberrypi-userland
%global snapshot_date 20241223
%global snapshot_commit a54a0dbb2b8dcf9bafdddfc9a9374fb51d97e976
%global package_release 11
%global snapshot_commit_short %(c=%{snapshot_commit}; echo ${c:0:7})
%global snapshot_info %{snapshot_date}git%{snapshot_commit_short}
%global github_user_name raspberrypi
%global github_repo_name userland
%global udev_rule 92-local-vchiq-permissions.rules
Name: %{github_user_name}-%{github_repo_name}
Version: 0.1~%{package_release}.%{snapshot_info}
Release: 1%{?dist}
Summary: ARM-side programs for interfacing to Raspberry Pi GPU
License: BSD
URL: https://github.com/%{github_user_name}/%{github_repo_name}
ExclusiveArch: %{arm} aarch64
Source0: https://github.com/%{github_user_name}/%{github_repo_name}/archive/%{snapshot_commit}/%{github_repo_name}-%{snapshot_commit}.tar.gz
Patch0: raspberrypi-userland-gcc15.patch
BuildRequires: cmake
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: make
# For '_udevrulesdir' RPM macro
BuildRequires: systemd-rpm-macros
%description
%{name} includes ARM-side binaries and libraries used on Raspberry
Pi. It provides the 'vcgencmd' program, which can be used to get information
from Raspberry Pi's VideoCore GPU.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
This package contains files for developing programs based on the libraries
provided by the %{name} package.
%package static
Summary: Static libraries for %{name}
%description static
This package contains static libraries for %{name}.
%prep
%autosetup -p1 -n %{github_repo_name}-%{snapshot_commit}
# Library path fix-up
grep -lr 'DESTINATION lib' | xargs sed -i 's/DESTINATION lib/DESTINATION %{_lib}/g'
grep -lr '${exec_prefix}/lib' | xargs sed -i 's/${exec_prefix}\/lib/${exec_prefix}\/%{_lib}/'
grep -lr '${CMAKE_INSTALL_PREFIX}/lib' | xargs sed -i 's/${CMAKE_INSTALL_PREFIX}\/lib/${CMAKE_INSTALL_PREFIX}\/%{_lib}/'
grep -lr '${VIDEOCORE_BUILD_DIR}/lib' | xargs sed -i 's/${VIDEOCORE_BUILD_DIR}\/lib/${VIDEOCORE_BUILD_DIR}\/%{_lib}/'
# Manual pages path fix-up
grep -lr 'DESTINATION man' | xargs sed -i 's/DESTINATION man/DESTINATION share\/man/g'
%build
# Generate Makefile using cmake
/usr/bin/cmake \
-DCMAKE_BUILD_TYPE=Release \
-DVMCS_INSTALL_PREFIX=%{_prefix} \
%ifarch aarch64
-DARM64=ON \
%endif
.
%make_build
%install
%make_install
# Remove the source code of 'hello_pi' test apps
rm -r %{buildroot}%{_usrsrc}/hello_pi
# Install udev rule
mkdir -p %{buildroot}%{_udevrulesdir}
cat > %{buildroot}%{_udevrulesdir}/%{udev_rule} <<- _EOF_
KERNEL=="vchiq",GROUP="video",MODE="0660"
_EOF_
chmod 0644 %{buildroot}%{_udevrulesdir}/%{udev_rule}
%post
udevadm trigger /dev/vchiq
%files
%license LICENCE
%{_bindir}/*
%{_libdir}/*.so
%{_mandir}/*
%{_udevrulesdir}/%{udev_rule}
%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/*
%files static
%{_libdir}/*.a