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

Last change on this file since 10274 was 7714, checked in by joerg, 11 years ago

map-icons/debian/: reorganise icons to have one package for each theme

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/usr/bin/perl -w
2# This little helper copies according to the icons.xml File
3# all icons will be placed into there package directory
4# For more Info see --man option
5
6use strict;
7use warnings;
8use Data::Dumper;
9use XML::Simple;
10use File::Basename;
11use File::Path;
12use File::Copy;
13use Getopt::Long;
14use Pod::Usage;
15
16my $file = 'icons';
17
18die "Can't find file \"$file.xml\""
19    unless -f "$file.xml";
20
21my $dst_path="usr/share/icons/map-icons";
22my $src_dir="build/";
23my $package_path = 'debian/openstreetmap-map-icons';
24
25
26my @theme_dirs=qw(classic.big classic.small
27                  japan japan_tn
28                  nickw
29                  square.big square.small
30                  svg svg_tn
31                  );
32
33my ($man,$help,$DEBUG,$VERBOSE)=(0,0,0,0);
34my $NO_RESTRICTED=0;
35# Set defaults and get options from command line
36Getopt::Long::Configure('no_ignore_case');
37GetOptions ( 
38             'd+'                 => \$DEBUG,
39             'debug+'             => \$DEBUG,     
40             'verbose'            => \$VERBOSE,
41             'exclude-restricted' => \$NO_RESTRICTED,
42             'v+'                 => \$VERBOSE,
43             'h|help|x'           => \$help, 
44             'MAN'                => \$man, 
45             'man'                => \$man, 
46             )
47    or pod2usage(1);
48
49pod2usage(1) if $help;
50pod2usage(-verbose=>2) if $man;
51
52
53#-----------------------------------------------------------------------------
54my $rules = XMLin("$file.xml",
55                  ForceArray => [ 'condition' ],
56    );
57my @rules=@{$rules->{rule}};
58for my $rule (@rules) {
59    print Dumper(\$rule) if $DEBUG >10;
60    my $restricted = $rule->{'geoinfo'}->{'restricted'}||'';
61    my $names = $rule->{'condition'};
62    my ($name) = grep { $_->{k} =~ /^poi|rendering$/ } @{$names};
63    $name = $name->{v};
64    print "name: '$name'\n" if $VERBOSE;
65    if ( ! $name ) {
66        warn "Undefined Name\n";
67        warn Dumper(\$rule);
68        next;
69    }
70    $name =~ s,\.,/,g;
71
72    # Do not copy the restricted Icons
73    # This is untested, but might work ;-)
74    if ( $NO_RESTRICTED && $restricted ) {
75        next;
76    }
77
78    for my $theme ( @theme_dirs) {
79        #print STDERR "Copy  $theme/$name for Theme\n";
80        my $found=0;
81        for my $fn_icon ( "$theme/$name.png","$theme/$name.svg"){
82            my $src_fn="$src_dir/$fn_icon";
83            my $dst_fn="${package_path}-${theme}/$dst_path/$fn_icon";
84            if ( -s $src_fn) {
85                print STDERR "$fn_icon  ---> $dst_fn\n" if $VERBOSE>2 || $DEBUG;
86                my $dir = dirname($dst_fn);
87                mkpath $dir  || warn "Cannot create $dir:$!\n";
88                copy($src_fn,$dst_fn)  || warn "Cannot copy $src_fn,$dst_fn:$!\n";;
89                $found++;
90            }   
91        }
92        # print STDERR "No File for $theme/$name found\n" unless $found;
93    };
94};
95 
96my $write_output=0;
97if ( $write_output) {
98    my $xml = XMLout($rules);
99    my $fo = IO::File->new(">$file-out.xml");
100    print  $fo $xml;
101    $fo->close();
102}
103
104
105__END__
106
107=head1 NAME
108
109B<copy_icons_to_debian_package_dirs.pl> Version 0.1
110
111=head1 DESCRIPTION
112
113B<copy_icons_to_debian_package_dirs.pl> is a program to copy
114the icons Files into the apropriate debian Directories.
115This little helper copies according to the icons.xml File
116all files into the new structure.
117All icons will be placed into there package directory
118the default src_dir if build/*
119
120
121=head1 SYNOPSIS
122
123B<Common usages:>
124
125geoinfo.pl [-d] [--man]
126
127=item B<--man>
128
129Print this small usage
130
131=item B<-d>
132
133Add some more Debug Output
134
135=back
Note: See TracBrowser for help on using the repository browser.