merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / update_module_ignore_lists.pl
bloba73694097bcdcde6b12034886d874f3d522a70d2
2 eval 'exec perl -S $0 ${1+"$@"}'
3 if 0;
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 #
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: hicontrast-to-theme.pl,v $
14 # $Revision: 1.4 $
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 #*************************************************************************
35 use Cwd;
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 = (
43 # (none so far)
45 # platforms whose output trees should appear in all modules' svn:ignore list
46 my @platforms = (
47 "common",
48 "unxlngi6",
49 "unxlngx6",
50 "unxsols4",
51 "unxsolu4",
52 "unxsoli4",
53 "wntmsci12",
54 "unxmacxi",
55 "unxubit8",
56 "unxaixp",
57 "unxbsda",
58 "unxbsdi2",
59 "unxbsdi",
60 "unxbsds",
61 "unxfbsdi",
62 "unxfbsd",
63 "unxfbsdx",
64 "unxhpgr",
65 "unxhpxr",
66 "unxirgm",
67 "unxirxm3",
68 "unxirxm",
69 "unxlnga",
70 "unxlngm68k",
71 "unxlngmips",
72 "unxlngp",
73 "unxlngppc4",
74 "unxlngppc64",
75 "unxlngppc",
76 "unxlngr",
77 "unxlngs3904",
78 "unxlngs390x",
79 "unxlngs",
80 "unxlnxi",
81 "unxmacxp",
82 "unxsogi",
83 "unxsogs"
87 # .........................................................................
88 # retrieves the repository URL of the SVN working copy in the current directory
89 sub retrieve_repo_url
91 open( SVN, "svn info 2>&1 |" );
92 my @result = <SVN>;
93 close( SVN );
95 foreach (@result)
97 chomp;
98 next if ( ! /^URL: / );
99 s/^URL: //;
100 return $_;
102 return undef;
105 # .........................................................................
106 # gets the "modules" below the given SVN repository URL, by calling "svn list"
107 sub get_modules
109 my @modules = ();
111 open( SVN, "svn list $_ 2>&1 |" );
112 my @result = <SVN>;
113 close( SVN );
115 foreach (@result)
117 chomp;
118 s/\/$//;
119 push @modules, $_;
122 return @modules;
125 # .........................................................................
126 sub set_ignore_property
128 my ($repo_url, @modules) = @_;
130 # max length of a module name
131 my $max_len = 0;
132 foreach ( @modules ) { $max_len = length( $_ ) if ( length( $_ ) > $max_len ); }
134 my $updated = 0;
136 my $current = 0;
137 my $count = $#modules + 1;
138 foreach $module ( @modules )
140 ++$current;
142 # print progress
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 );
152 $progress .= " ";
154 print STDOUT $progress;
156 elsif ( $verbosity > 0 )
158 print STDOUT ".";
161 # retrieve the current ignore list
162 open( SVN, "svn propget svn:ignore $module 2>&1 |" );
163 my @ignore_list = <SVN>;
164 close( SVN );
166 # the last item in the list is an empty string, usually. Don't let it confuse the below
167 # code
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"} )
183 next;
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;
209 close( IGNORE );
211 # actually set the property
212 open( SVN, "svn propset -F $filename svn:ignore $module 2>&1 |" );
214 ++$updated;
217 # statistics
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 # .........................................................................
226 sub digits
228 my ($number, $base) = @_;
229 $base = 10 if !defined $base;
230 return log($number)/log($base);
233 # .........................................................................
234 # 'main'
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;
254 # list modules
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 );