2 eval 'exec perl -S $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: hicontrast-to-theme.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
36 use File
::Temp qw
/ tempfile tempdir /;
38 my $verbosity = 1; # will be adjusted to the value of $Env{VERBOSE} below
40 # platforms which are not supported anymore, and thus can be filtered from the svn:ignore list
41 my %obsolete_platforms = (
45 # platforms whose output trees should appear in all modules' svn:ignore list
87 # .........................................................................
88 # retrieves the repository URL of the SVN working copy in the current directory
91 open( SVN
, "svn info 2>&1 |" );
98 next if ( ! /^URL: / );
105 # .........................................................................
106 # gets the "modules" below the given SVN repository URL, by calling "svn list"
111 open( SVN
, "svn list $_ 2>&1 |" );
125 # .........................................................................
126 sub set_ignore_property
128 my ($repo_url, @modules) = @_;
130 # max length of a module name
132 foreach ( @modules ) { $max_len = length( $_ ) if ( length( $_ ) > $max_len ); }
137 my $count = $#modules + 1;
138 foreach $module ( @modules )
143 if ( $verbosity > 1 )
145 my $progress = "$module ";
146 $progress .= "(" . $current . "/" . $count . ")";
148 my $dots = 3 + ( $max_len - length($module) );
149 $dots += int( digits
( $count ) ) - int( digits
( $current ) );
151 $progress .= ( "." x
$dots );
154 print STDOUT
$progress;
156 elsif ( $verbosity > 0 )
161 # retrieve the current ignore list
162 open( SVN
, "svn propget svn:ignore $module 2>&1 |" );
163 my @ignore_list = <SVN
>;
166 # the last item in the list is an empty string, usually. Don't let it confuse the below
168 my $supposed_empty = pop @ignore_list;
169 chomp( $supposed_empty );
170 push( @ignore_list, $supposed_empty ) if ( !( $supposed_empty =~ /^$/ ) );
172 # filter out obsolte entries
173 my @stripped_ignore_list = ();
174 foreach $ignore_entry (@ignore_list)
176 chomp( $ignore_entry );
177 next if ( $ignore_entry =~ /^$/ );
179 if ( ( exists $obsolete_platforms{$ignore_entry} )
180 || ( exists $obsolete_platforms{"$ignore_entry.pro"} )
185 push @stripped_ignore_list, $ignore_entry;
187 my $removed = $#ignore_list - $#stripped_ignore_list;
188 @ignore_list = @stripped_ignore_list;
190 # append the platforms which should appear in the ignore list
191 my %ignore_list = ();
192 foreach (@ignore_list) { $ignore_list{$_} = 1; }
193 foreach $platform_entry ( @platforms )
195 $ignore_list{$platform_entry} = 1;
196 $ignore_list{"$platform_entry.pro"} = 1;
198 my @extended_ignore_list = keys %ignore_list;
199 my $added = $#extended_ignore_list - $#ignore_list;
200 @ignore_list = @extended_ignore_list;
202 if ( $removed || $added )
204 # create a temporary file taking the new content of the svn_ignore property
205 my $temp_dir = tempdir
( CLEANUP
=> 1 );
206 my ($fh, $filename) = tempfile
( DIR
=> $dir );
207 open( IGNORE
, ">$filename" );
208 print IGNORE
join "\n", @ignore_list;
211 # actually set the property
212 open( SVN
, "svn propset -F $filename svn:ignore $module 2>&1 |" );
218 print STDOUT
"done (removed/added: $removed/$added)\n" if $verbosity > 1;
221 print STDOUT
"\n" if $verbosity eq 1;
222 print STDOUT
"$updated module(s) updated\n" if $verbosity > 0;
225 # .........................................................................
228 my ($number, $base) = @_;
229 $base = 10 if !defined $base;
230 return log($number)/log($base);
233 # .........................................................................
236 # initialize verbosity
237 my $verbose = $ENV{VERBOSE
};
238 if ( defined $verbose )
240 $verbose = uc( $verbose );
241 $verbosity = 2 if ( $verbose eq "TRUE" );
242 $verbosity = 0 if ( $verbose eq "FALSE" );
245 # work on the current directory
246 my $working_copy_root = cwd
();
247 die "current directory does not contain an SVN working copy" if !-d
$working_copy_root . "/\.svn";
249 # retrieve repository URL
250 my $repo_url = retrieve_repo_url
();
251 die "unable to retrieve repository URL" if !defined $repo_url;
252 print STDOUT
"repository URL: $repo_url\n" if $verbosity > 1;
255 my @modules = get_modules
( $repo_url );
256 print STDOUT
"processing " . ( $#modules + 1 ) . " modules\n" if $verbosity > 0;
258 # process modules, by setting the svn:ignore property
259 set_ignore_property
( $repo_url, @modules );