diff --git a/macros b/macros index 5d64699716d880b63bab88c71e9658c5b6907e85..6336de828f4e5cd231af8676ba9b304345f51b77 100644 --- a/macros +++ b/macros @@ -254,6 +254,8 @@ print(result) %__brp_remove_info_dir /usr/lib/rpm/anolis/remove-info-dir +%__brp_relink_symlinks /usr/lib/rpm/anolis/relink_symlinks + # note: %%__os_install_post_python is defined in python-srpm-macros and contains several policies # don't remove it from %%__os_install_post unless coordinating the change with Python maintainers # packagers, don't undefine the entire macro, see the individual macros in /usr/lib/rpm/macros.d/macros.python-srpm @@ -268,9 +270,10 @@ print(result) %{?__brp_strip_lto} \ %{?__brp_strip_static_archive} \ %{?__brp_check_rpaths} \ - %{?__brp_mangle_shebangs} \ %{?__brp_remove_la_files} \ + %{?__brp_mangle_shebangs} \ %{?__brp_remove_info_dir} \ + %{?__brp_relink_symlinks} \ %{__os_install_post_python} \ %{nil} diff --git a/relink_symlinks b/relink_symlinks new file mode 100755 index 0000000000000000000000000000000000000000..f9642df78563791e8a43d5625f5978b441835402 --- /dev/null +++ b/relink_symlinks @@ -0,0 +1,29 @@ +#!/usr/bin/perl +# relativize absolute symlinks + +use strict; +use warnings; +use File::Find; + +my $buildroot = $ENV{RPM_BUILD_ROOT}; +die "No build root defined" unless $buildroot; +die "Invalid build root" unless -d $buildroot; +# normalize build root +$buildroot =~ s|/$||; + +sub relativize { + return unless -l $_; + + my $link = readlink($_); + return unless $link =~ m{^/} && $link !~ m{^/(dev|proc|sys)/}; + + $link =~ s{^/}{}; + my $dirname = $File::Find::dir; + $dirname =~ s/^\Q$buildroot\E//; + $dirname =~ s{/[^/]+}{../}g; + + unlink $_; + symlink $dirname . $link, $_; +} + +find(\&relativize, $buildroot); diff --git a/remove-info-dir b/remove-info-dir old mode 100644 new mode 100755 diff --git a/system-rpm-config.spec b/system-rpm-config.spec index da1808306244ae74f5d3497d16c34355c85e2db8..03216229f77d6820975f5ce82e25e3625a180404 100644 --- a/system-rpm-config.spec +++ b/system-rpm-config.spec @@ -1,4 +1,4 @@ -%define anolis_release 14 +%define anolis_release 15 Summary: Anolis OS specific rpm configuration files Name: system-rpm-config @@ -55,6 +55,7 @@ Source401: gpgverify Source402: remove-info-dir Source403: fix-dlsearch-path-in-libtool Source404: generate-compatibility-deps +Source405: relink_symlinks # 2022-05-25 Snapshots from http://git.savannah.gnu.org/gitweb/?p=config.git Source500: config.guess @@ -129,6 +130,7 @@ install -p -m 755 -t %{buildroot}%{rrcdir} brp-* install -p -m 755 -t %{buildroot}%{rrcdir} remove-info-dir install -p -m 755 -t %{buildroot}%{rrcdir} fix-dlsearch-path-in-libtool install -p -m 755 -t %{buildroot}%{rrcdir} generate-compatibility-deps +install -p -m 755 -t %{buildroot}%{rrcdir} relink_symlinks install -p -m 755 -t %{buildroot}%{rrcdir} find-* mkdir -p %{buildroot}%{rrcdir}/find-provides.d @@ -159,8 +161,8 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %{rrcdir}/config.* %{rrcdir}/find-provides %{rrcdir}/find-requires -%{rrcdir}/brp-ldconfig %{rrcdir}/remove-info-dir +%{rrcdir}/relink_symlinks %{rrcdir}/fix-dlsearch-path-in-libtool %{rrcdir}/generate-compatibility-deps %{_fileattrsdir}/*.attr @@ -180,6 +182,10 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %license MulanPSL %changelog +* Sun Nov 20 2022 Funda Wang - 23.15 +- Add symlink relink helper from Mageia to reduce absolute symlink +- move la_file removal step ahead, so that they do not trigger shebangs + * Wed Nov 9 2022 Funda Wang - 23.14 - Compress man-pages and info-pages as zstd to save disk space for users.