aboutsummaryrefslogtreecommitdiffstats
path: root/check_desktop_files
blob: 2885a152bb90d1552b32c54b09fda953d05a018f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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 {
                # xsession files are not *really* desktop files
                # https://bugs.freedesktop.org/show_bug.cgi?id=85938
                return if $File::Find::dir eq $buildroot . '/usr/share/xsessions' ||
                          $File::Find::dir eq $buildroot . '/usr/share/wayland-sessions';

                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);