diff --git a/check-desktop-files b/check-desktop-files new file mode 100644 index 0000000000000000000000000000000000000000..e640e1185f63782c256defc95b733585b847b28a --- /dev/null +++ b/check-desktop-files @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +# Copyright 2016 by Shlomi Fish +# This program is distributed under the MIT (X11) License: +# http://www.opensource.org/licenses/mit-license.php + +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|/$||; + +my $FILTER = qr/\.desktop\z/; + +sub main +{ + find( + { + wanted => + sub { + # check files only in /usr/share/applications + return unless $File::Find::dir eq $buildroot . '/usr/share/applications'; + + my $fn = $File::Find::name; + if ($fn =~ $FILTER) + { + if (system('desktop-file-validate', $fn) != 0) + { + die "Validating <$fn> failed!"; + } + } + }, + no_chdir => 1, + }, + $buildroot + ); + + exit(0); +} + +main(@ARGV); diff --git a/macros b/macros index 6336de828f4e5cd231af8676ba9b304345f51b77..e55f72583772708628238aac92d32099ecd264ab 100644 --- a/macros +++ b/macros @@ -256,6 +256,8 @@ print(result) %__brp_relink_symlinks /usr/lib/rpm/anolis/relink_symlinks +%__brp_check_desktop_files /usr/lib/rpm/anolis/check-desktop-files + # 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 @@ -274,6 +276,7 @@ print(result) %{?__brp_mangle_shebangs} \ %{?__brp_remove_info_dir} \ %{?__brp_relink_symlinks} \ + %{?__brp_check_desktop_files} \ %{__os_install_post_python} \ %{nil} diff --git a/system-rpm-config.spec b/system-rpm-config.spec index 03216229f77d6820975f5ce82e25e3625a180404..d6d5477465f86e76c71bff1f3661671fbd82e265 100644 --- a/system-rpm-config.spec +++ b/system-rpm-config.spec @@ -1,10 +1,11 @@ -%define anolis_release 15 +%define anolis_release 16 Summary: Anolis OS specific rpm configuration files Name: system-rpm-config Version: 23 Release: %{anolis_release}%{?dist} -License: MulanPSLv2 +# check-desktop-files licensed under MIT, other script under MulanPSLv2 +License: MulanPSLv2 and MIT URL: https://gitee.com/src-anolis-os/system-rpm-config # Core rpm settings @@ -56,6 +57,7 @@ Source402: remove-info-dir Source403: fix-dlsearch-path-in-libtool Source404: generate-compatibility-deps Source405: relink_symlinks +Source406: check-desktop-files # 2022-05-25 Snapshots from http://git.savannah.gnu.org/gitweb/?p=config.git Source500: config.guess @@ -92,6 +94,9 @@ Requires: %{_bindir}/grep Requires: %{_bindir}/sed Requires: %{_bindir}/xargs +# for brp_check_desktop_files +Requires: desktop-file-utils + # for brp-llvm-compile-lto-elf Requires: (llvm if clang) @@ -131,6 +136,7 @@ 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} check-desktop-files install -p -m 755 -t %{buildroot}%{rrcdir} find-* mkdir -p %{buildroot}%{rrcdir}/find-provides.d @@ -159,6 +165,7 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %{rrcdir}/anolis-hardened-* %{rrcdir}/anolis-annobin-* %{rrcdir}/config.* +%{rrcdir}/check-desktop-files %{rrcdir}/find-provides %{rrcdir}/find-requires %{rrcdir}/remove-info-dir @@ -182,6 +189,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/anolis/srpm forge.lua %license MulanPSL %changelog +* Thu Dec 8 2022 Funda Wang - 23.16 +- Add check script from Mageia for .desktop files + * 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