use rpm macros instead of RPM's exported shell vars

This commit is contained in:
Pratham Patel 2023-10-10 13:22:18 +05:30
parent 5185339240
commit 83491b1a09
No known key found for this signature in database

View File

@ -111,18 +111,18 @@ sed -i 's@KBUILD_IMAGE := $(boot)/Image.gz@KBUILD_IMAGE := $(boot)/Image@' arch/
%{make} PYTHON=%{__python3} %{make_targets} %{make} PYTHON=%{__python3} %{make_targets}
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf %{buildroot}
mkdir -p $RPM_BUILD_ROOT mkdir -p %{buildroot}
# install the kernel # install the kernel
mkdir -p $RPM_BUILD_ROOT/boot mkdir -p %{buildroot}/boot
cp $(%{make} -s image_name) $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL} cp $(%{make} -s image_name) %{buildroot}/boot/vmlinuz-%{KVERREL}
chmod 755 $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL} chmod 755 %{buildroot}/boot/vmlinuz-%{KVERREL}
echo "%{KVERREL}" > $RPM_BUILD_ROOT/boot/.uname-%{KVERREL} echo "%{KVERREL}" > %{buildroot}/boot/.uname-%{KVERREL}
# install DTBs # install DTBs
%ifarch aarch64 || riscv64 %ifarch aarch64 || riscv64
%{make} INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/boot/dtb-%{KVERREL} dtbs_install %{make} INSTALL_DTBS_PATH=%{buildroot}/boot/dtb-%{KVERREL} dtbs_install
# delete "arch/%{build_arch}/boot/dts" because "$PWD" will be packaged in "%devel" # delete "arch/%{build_arch}/boot/dts" because "$PWD" will be packaged in "%devel"
find arch/%{build_arch}/boot/dts -name '*.dtb' -type f -delete find arch/%{build_arch}/boot/dts -name '*.dtb' -type f -delete
%endif %endif
@ -130,33 +130,33 @@ find arch/%{build_arch}/boot/dts -name '*.dtb' -type f -delete
# install modules # install modules
# '$(mod-fw)' is overridden because there is no reason to install any firmware # '$(mod-fw)' is overridden because there is no reason to install any firmware
# since we already have 'linux-firmware' package as the dependency of this package. # since we already have 'linux-firmware' package as the dependency of this package.
%{make} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$RPM_BUILD_ROOT mod-fw= modules_install %{make} INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} mod-fw= modules_install
# install headers # install headers
%{make} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install %{make} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
# install other key files too # install other key files too
install -m 644 .config $RPM_BUILD_ROOT/boot/config-%{KVERREL} install -m 644 .config %{buildroot}/boot/config-%{KVERREL}
install -m 644 .config $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/config install -m 644 .config %{buildroot}/lib/modules/%{KVERREL}/config
install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-%{KVERREL} install -m 644 System.map %{buildroot}/boot/System.map-%{KVERREL}
install -m 644 System.map $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/System.map install -m 644 System.map %{buildroot}/lib/modules/%{KVERREL}/System.map
# fix links # fix links
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/build rm -rf %{buildroot}/lib/modules/%{KVERREL}/build
rm -rf $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/source rm -rf %{buildroot}/lib/modules/%{KVERREL}/source
ln -fns /usr/src/kernels/%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/build ln -fns /usr/src/kernels/%{KVERREL} %{buildroot}/lib/modules/%{KVERREL}/build
ln -fns /usr/src/kernels/%{KVERREL} $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/source ln -fns /usr/src/kernels/%{KVERREL} %{buildroot}/lib/modules/%{KVERREL}/source
# install actual Linux src to /usr/src/kernels/%{KVERREL} # install actual Linux src to /usr/src/kernels/%{KVERREL}
mkdir -p $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL} mkdir -p %{buildroot}/usr/src/kernels/%{KVERREL}
if [ -f scripts/package/install-extmod-build ]; then if [ -f scripts/package/install-extmod-build ]; then
%{make} run-command KBUILD_RUN_COMMAND='${RPM_BUILD_DIR}/%{src_dir}/scripts/package/install-extmod-build $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}' %{make} run-command KBUILD_RUN_COMMAND='%{_builddir}/%{src_dir}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KVERREL}'
else else
touch $RPM_BUILD_ROOT/usr/src/kernels/%{KVERREL}/MAYBE_THIS_WORKS touch %{buildroot}/usr/src/kernels/%{KVERREL}/MAYBE_THIS_WORKS
fi fi
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf %{buildroot}
%post %post
set -xeuf -o pipefail set -xeuf -o pipefail