From a287727639b67ccbd42690f0f3ba4d644ed225e4 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Tue, 17 Oct 2023 00:58:05 -0400 Subject: [PATCH] Fix flatpak build When built for a flatpak in /app, we still need perl to use module packages built in /usr, both to help with bootstrapping, and also for using build-time only dependencies which should not need to be rebuilt. Similarly, /usr/bin/perl is provided so that the /app perl remains compatible with shebangs created for the /usr perl. The build of perl included in runtimes (KDE platform and all the SDKs), while built into /usr, also needs to find modules in /app, but (in the use case of SDKs used with flatpak-builder) also build modules there. The solution used here is to define vendorlib/vendorarch in /app, and add the /usr vendor directories as otherlibdirs for those perl modules which are also included in the runtimes/SDKs. manNdir always need to be defined regardless of groff, as they are relied upon later in the build. --- perl.spec | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/perl.spec b/perl.spec index 45797e7..a4dd5ac 100644 --- a/perl.spec +++ b/perl.spec @@ -4306,8 +4306,13 @@ echo "RPM Build arch: %{_arch}" %global privlib %{_prefix}/share/perl5 %global archlib %{_libdir}/perl5 +%if 0%{?flatpak_runtime} +%global perl_vendorlib /app/%{_lib}/perl5/vendor_perl +%global perl_vendorarch /app/share/perl5/vendor_perl +%else %global perl_vendorlib %{privlib}/vendor_perl %global perl_vendorarch %{archlib}/vendor_perl +%endif %global perl_abi %(echo '%{perl_version}' | sed 's/^\\([^.]*\\.[^.]*\\).*/\\1/') @@ -4329,10 +4334,8 @@ echo "RPM Build arch: %{_arch}" -Dcc='%{__cc}' \ -Dcf_by='Red Hat, Inc.' \ -Dprefix=%{_prefix} \ -%if %{without perl_enables_groff} -Dman1dir="%{_mandir}/man1" \ -Dman3dir="%{_mandir}/man3" \ -%endif -Dvendorprefix=%{_prefix} \ -Dsiteprefix=%{_prefix}/local \ -Dsitelib="%{_prefix}/local/share/perl5/%{perl_abi}" \ @@ -4342,6 +4345,13 @@ echo "RPM Build arch: %{_arch}" -Darchlib="%{archlib}" \ -Dvendorarch="%{perl_vendorarch}" \ -Darchname=%{perl_archname} \ +%if 0%{?flatpak} + -Dotherlibdirs="/usr/share/perl5/vendor_perl:/usr/%{_lib}/perl5/vendor_perl:/usr/share/perl5:/usr/%{_lib}/perl5" \ +%endif +%if 0%{?flatpak_runtime} + -Dotherlibdirs=%{archlib}/vendor_perl:%{privlib}/vendor_perl \ + -Dvendorprefix=/app \ +%endif %ifarch %{multilib_64_archs} -Dlibpth="/usr/local/lib64 /lib64 %{_prefix}/lib64" \ %endif @@ -5216,6 +5226,14 @@ popd %endif %endif +%if 0%{?flatpak} +# This symlink won't be included in the Flatpak, since it is outside of /app, +# but it is needed in the prefix=/app buildroot, since we need to be able to +# install modules that Require: /usr/bin/perl. +mkdir -p %{buildroot}/usr/bin +ln -s /app/bin/perl %{buildroot}/usr/bin/perl +%endif + %ldconfig_scriptlets libs %files @@ -5229,6 +5247,9 @@ popd %dir %{privlib}/pod %{privlib}/pod/perl.pod %{privlib}/pod/perlrun.pod +%if 0%{?flatpak} +/usr/bin/perl +%endif %files libs %license Artistic Copying