2 eval 'exec perl -S $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2000, 2010 Oracle and/or its affiliates.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # This file is part of OpenOffice.org.
14 # OpenOffice.org is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU Lesser General Public License version 3
16 # only, as published by the Free Software Foundation.
18 # OpenOffice.org is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public License version 3 for more details
22 # (a copy is included in the LICENSE file that accompanied this code).
24 # You should have received a copy of the GNU Lesser General Public License
25 # version 3 along with OpenOffice.org. If not, see
26 # <http://www.openoffice.org/license.html>
27 # for a copy of the LGPLv3 License.
29 #*************************************************************************
31 # oochkpatch - check patch flags against CWS modules
40 use File
::Temp qw
/ tempfile tempdir /;
44 # configuration goes here
45 ##########################################################
47 # uncomment this, if in pure OOo environment
48 #my $toplevel_module = "instsetoo_native";
49 #my $scp_module = "scp2";
50 #my $setup_file = "setup_osl";
52 # uncomment this, if within the StarOffice environment
53 my $toplevel_module = "instset_native";
54 my $scp_module = "scp2so";
55 my $setup_file = "setup";
57 my $deliver = "solenv/bin/deliver.pl";
58 my $build = "solenv/bin/build.pl";
60 # list of hardcoded exceptions (files that are _never_ considered
61 # missing from the patch)
62 my %hardcoded_exceptions = ('build.lst' => 1);
65 # no configuration below this point, please!
66 ##########################################################
77 GetOptions
('help|?' => \
$help,
79 'verbose' => \
$verbose,
80 'from=s' => \
$from_module ) or pod2usage
(2);
81 pod2usage
(1) if $help;
82 pod2usage
(-exitstatus
=> 0, -verbose
=> 2) if $man;
84 # process remaining args
85 print "Processing args...\n" if $verbose;
86 foreach my $argument (@ARGV)
88 print " Checking module ", $argument, "\n" if $verbose;
89 push @modules, $argument;
92 # platform-dependent stuff
93 if( $^O
eq 'MSWin32' )
95 $perl = "$ENV{COMSPEC} -c $ENV{PERL}";
96 $setup_file = $setup_file . ".inf";
101 $setup_file = $setup_file . ".ins";
104 # read some SOLAR stuff from env
105 my $SRC_ROOT = $ENV{"SRC_ROOT"};
106 my $INPATH = $ENV{"INPATH"};
108 # process --from modules
111 print "Checking all modules upwards and including ", $from_module, "\n" if $verbose;
113 # append build.pl-generated list of modules
114 chdir "$SRC_ROOT/$toplevel_module" or
115 chdir "$SRC_ROOT/$toplevel_module.lnk" or die "ERROR: cannot cd to $SRC_ROOT/$toplevel_module!";
117 "$perl $SRC_ROOT/$build --all:$from_module --show 2>&1 |") or die "ERROR: cannot build --show!\n";
120 if( /Building project/ )
122 my @module = split( /\s+/, $_ );
123 print " which is ", $module[2], "\n" if $verbose;
124 push(@modules,$module[2]);
129 die "ERROR: no modules to check!\n" if !@modules;
131 $tempdir = tempdir
( TMPDIR
=> 1, CLEANUP
=> 1);
133 # generate list of files with PATCH flag
134 print "Generating list of files which have the PATCH flag...\n" if $verbose;
136 my $path_to_setup_file = $SRC_ROOT."/".$scp_module."/".$INPATH."/bin/osl/".$setup_file;
137 my $alternate_path_to_setup_file = $SRC_ROOT."/".$scp_module.".lnk/".$INPATH."/bin/osl/".$setup_file;
144 open(SETUP
, "<".$path_to_setup_file) or
145 open(SETUP
, "<".$alternate_path_to_setup_file) or die "ERROR: cannot open $path_to_setup_file!\n";
148 if( /^File\s+/ && !$in_file_block )
154 elsif( /^End/ && $file_name ne '' && $in_file_block )
156 $file_name =~ s/["']//g;
157 $pack_files{$file_name} = $patch_flag;
161 print( " File $file_name included in patch\n") if $verbose;
165 print( " File $file_name NOT included in patch\n") if $verbose;
170 elsif( /^\s+Styles\s*=\s*.*PATCH/ && $in_file_block )
174 elsif( ($res) = /^\s+Name\s*=\s*(.*);/ )
180 # generate list of delivered files
181 print "Generating list of delivered libs...\n" if $verbose;
183 # first, deliver all modules to tempdir
184 foreach my $module (@modules)
186 print " dummy-delivering $module...\n" if $verbose;
187 chdir "$SRC_ROOT/$module" or
188 chdir "$SRC_ROOT/$module.lnk" or die "ERROR: cannot cd to $SRC_ROOT/$module!";
189 `$perl $SRC_ROOT/$deliver $tempdir`;
192 # now, check all files in delivered dirs for containedness in PATCH
194 print "Checking against delivered files...\n" if $verbose;
195 find
(\
&wanted
, $tempdir );
204 if( !exists $pack_files{$fname} )
206 print " File $fname is not packed.\n" if $verbose;
208 elsif( $pack_files{$fname} == 0 )
210 if( !$hardcoded_exceptions{ $fname } )
212 # file not in patch set, and not in exception list
213 print " File $fname is packed, but NOT included in patch set and part of delivered output\n" if $verbose;
214 print "$fname\n" if !$verbose;
218 print " File $fname is NOT included in patch set, but member of hardcoded exception list\n" if $verbose;
221 elsif( $pack_files{$fname} == 1 )
223 print " File $fname packed and patched.\n" if $verbose;
233 oochkpatch.pl - Verify patch flags against module libraries
237 oochkpatch.pl [options] [module-name ...]
240 --help|-h brief help message
241 --man|-m full documentation
242 --verbose|-v tell what's happening
243 --from=module check all modules from
252 Print a brief help message and exits.
256 Prints the manual page and exits.
260 Verbosely tell what's currently happening
262 =item B<--from=module>
264 Assumes OOo was built incompatibly from given module
265 upwards, and check against all libs from all upwards modules.
266 Further modules can be given at the command line, which are merged
267 with the ones generated from this option
273 B<This program> will compare all libs delivered from the specified modules
274 against the set of files marked with the B<patch> flag in scp2. Useful to check
275 if the patch set is complete. Please note that this program needs to be run in
276 a solar shell, i.e. the OOo build environment needs to be set up in the shell.
278 There's kind of a heuristic involved, to determine exactly which files
279 to check against includedness in the patch set (since e.g. all headers
280 are delivered, but clearly need not be checked against patch
281 flags). It works by first collecting all files that are mentioned in
282 the pack master file, and then checking all files delivered from the
283 specified modules against that pack list: if the file is not packed,
284 or if it's packed and has the patch flag set, all is well. Otherwise,
285 the file in question potentially misses the patch flag (because one of
286 the modified modules contains it).
290 To determine the set of libs not yet carrying the patch flag for a CWS
291 containing sfx2, svx, and vcl, which is incompatible from sfx2
292 upwards, use something like this:
294 oochkpatch.pl --from=sfx2 `cwsquery modules`
296 This puts every module upwards and including sfx2 in the check list,
297 plus vcl. Note that with this approach, you'll usually get a larger
298 set of files for the patch than necessary - but at least you get all
299 files that might have changed theoretically.