source: subversion/applications/share/map-icons/copy_icons_to_debian_package_dirs.pl @ 6405

Last change on this file since 6405 was 6401, checked in by joerg, 13 years ago

map-icons/debian: move icons to folder /usr/share/icons/map-icons

  • Property svn:executable set to *
File size: 1.8 KB
RevLine 
[3983]1#!/usr/bin/perl -w
2# This little helper copies according to the icons.xml File
3# and the geoinfo->restrictions tag
4# all icons will be placed into there package directory
5
6use strict;
7use warnings;
8use Data::Dumper;
9use XML::Simple;
10use File::Basename;
11use File::Path;
12use File::Copy;
13
14my $file = 'icons';
15
16die "Can't find file \"$file.xml\""
17    unless -f "$file.xml";
18
[6401]19my $dst_path="/usr/share/icons/map-icons";
[3983]20my $src_dir="build/";
21my $package_path = {
22    ''      => 'debian/openstreetmap-map-icons',
23    'brand' => 'debian/openstreetmap-map-icons-restricted',
24};
25
26
27my @theme_dirs=qw(classic.big classic.small
[4193]28                  japan japan_tn
[3983]29                  nickw
30                  square.big square.small
31                  svg svg_tn
32                  );
33
34#-----------------------------------------------------------------------------
35my $rules = XMLin("$file.xml");
36my @rules=@{$rules->{rule}};
37for my $rule (@rules) {
38    #print Dumper(\$rule);
39    my $restricted = $rule->{'geoinfo'}->{'restricted'}||'';
40    my $name = $rule->{'geoinfo'}->{'name'};
[4159]41    $name =~s,\.,/,g;
[3983]42    if ( ! defined($package_path->{$restricted})) {
43        die "Wrong or unknown restriction '$restricted'\n";
44    }
45   
46    for my $theme ( @theme_dirs) {
[4159]47        #print STDERR "Copy  $theme/$name for Theme\n";
48        my $found=0;
[3983]49        for my $fn_icon ( "$theme/$name.png","$theme/$name.svg"){
50            my $src_fn="$src_dir/$fn_icon";
51            my $dst_fn=$package_path->{$restricted}."$dst_path/".$fn_icon;
52            if ( -s $src_fn) {
[4159]53                #print STDERR "$fn_icon ---> $dst_fn\n";
54                my $dir = dirname($dst_fn);
55                mkpath $dir  || warn "Cannot create $dir:$!\n";
56                copy($src_fn,$dst_fn)  || warn "Cannot copy $src_fn,$dst_fn:$!\n";;
57                $found++;
58            }   
[3983]59        }
[4159]60        # print STDERR "No File for $theme/$name found\n" unless $found;
[3983]61    };
62};
63 
64my $write_output=0;
65if ( $write_output) {
66    my $xml = XMLout($rules);
67    my $fo = IO::File->new(">$file-out.xml");
68    print  $fo $xml;
69    $fo->close();
70}
71
Note: See TracBrowser for help on using the repository browser.