File: desktop-check-mime-types

package info (click to toggle)
gnome-pkg-tools 0.21.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 152 kB
  • sloc: perl: 163; makefile: 9
file content (44 lines) | stat: -rwxr-xr-x 1,176 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl -T
# compares MIME types in installed .desktop files with the ones installed in
# debian/*.mime files

use warnings;
use strict;

my @debian_mime_types;
foreach my $mime_file (glob "debian/*.mime") {
    open MIME_FILE,$mime_file or die "Can't open $mime_file: $!";
    while (<MIME_FILE>) {
        chomp;
        s/\s*;.*//;
        next if /^#/;
        next if /^$/;
        push @debian_mime_types, $_;
    }
}

my @desktop_mime_types;
foreach my $desktop_file (glob "debian/*/usr/share/applications/*.desktop") {

    open DESKTOP_FILE,$desktop_file or die "Can't open $desktop_file: $!";
    while (<DESKTOP_FILE>) {
        chomp;
        next unless /^MimeType\s*=/;
        s/.*=\s*//;
        push @desktop_mime_types, split(/;/);
    }
}

my @missing_mime_types;
foreach my $desktop_mime_type (@desktop_mime_types) {
     next if grep($desktop_mime_type eq $_, @debian_mime_types);
     push @missing_mime_types, $desktop_mime_type;
}

if (@missing_mime_types) {
    print "The following MIME types are listed in some .desktop files but are missing from debian/*.mime:\n";
    print join("\n", @missing_mime_types);
    print "\n";
    exit(2);
}