packimages.pl (7e90fac2) packimages.pl (7d4f049e)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
4#**************************************************************
5#
6# Licensed to the Apache Software Foundation (ASF) under one
7# or more contributor license agreements. See the NOTICE file
8# distributed with this work for additional information

--- 84 unchanged lines hidden (view full) ---

93 my $opt_help;
94 my $p = Getopt::Long::Parser->new();
95 my @custom_path_list;
96 my $custom_path_extended;
97 my $success =$p->getoptions(
98 '-h' => \$opt_help,
99 '-o=s' => \$out_file,
100 '-g=s' => \$global_path,
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
4#**************************************************************
5#
6# Licensed to the Apache Software Foundation (ASF) under one
7# or more contributor license agreements. See the NOTICE file
8# distributed with this work for additional information

--- 84 unchanged lines hidden (view full) ---

93 my $opt_help;
94 my $p = Getopt::Long::Parser->new();
95 my @custom_path_list;
96 my $custom_path_extended;
97 my $success =$p->getoptions(
98 '-h' => \$opt_help,
99 '-o=s' => \$out_file,
100 '-g=s' => \$global_path,
101 '-s=s' => \$sort_file,
101 '-s=s' => \$sort_file,
102 '-m=s' => \$module_path,
103 '-c=s' => \@custom_path_list,
104 '-e=s' => \$custom_path_extended,
105 '-l=s' => \@imagelist_path,
106 '-v' => \$verbose,
107 '-vv' => \$extra_verbose
108 );
109 push @custom_path_list, $custom_path_extended if ($custom_path_extended);
110 if ( $opt_help || !$success || !$out_file || !$global_path
111 || !$module_path || !@custom_path_list || !@imagelist_path )
112 {
113 usage();
114 exit(1);
115 }
102 '-m=s' => \$module_path,
103 '-c=s' => \@custom_path_list,
104 '-e=s' => \$custom_path_extended,
105 '-l=s' => \@imagelist_path,
106 '-v' => \$verbose,
107 '-vv' => \$extra_verbose
108 );
109 push @custom_path_list, $custom_path_extended if ($custom_path_extended);
110 if ( $opt_help || !$success || !$out_file || !$global_path
111 || !$module_path || !@custom_path_list || !@imagelist_path )
112 {
113 usage();
114 exit(1);
115 }
116
117 # if extra-verbose, set also verbose
118 if ($extra_verbose) { $verbose = 1; }
119
116 #define intermediate output file
117 $tmp_out_file="$out_file"."$$".$ENV{INPATH};
118 # Sanity checks.
119
120 # Check if out_file can be written.
121 my $out_dir = dirname($out_file);
122
123 # Check paths.

--- 89 unchanged lines hidden (view full) ---

213 return ($global_hash_ref, $module_hash_ref, $custom_hash_ref);
214}
215
216sub find_custom
217{
218 my $custom_hash_ref = shift;
219 my $keep_back;
220 for my $path (@custom_path) {
120 #define intermediate output file
121 $tmp_out_file="$out_file"."$$".$ENV{INPATH};
122 # Sanity checks.
123
124 # Check if out_file can be written.
125 my $out_dir = dirname($out_file);
126
127 # Check paths.

--- 89 unchanged lines hidden (view full) ---

217 return ($global_hash_ref, $module_hash_ref, $custom_hash_ref);
218}
219
220sub find_custom
221{
222 my $custom_hash_ref = shift;
223 my $keep_back;
224 for my $path (@custom_path) {
221 find({ wanted => \&wanted, no_chdir => 0 }, $path);
222 foreach ( @custom_list ) {
223 if ( /^\Q$path\E\/(.*)$/ ) {
224 $keep_back=$1;
225 if (!defined $custom_hash_ref->{$keep_back}) {
226 $custom_hash_ref->{$keep_back} = $path;
227 }
228 }
229 }
225 find({ wanted => \&wanted, no_chdir => 0 }, $path);
226 foreach ( @custom_list ) {
227 if ( /^\Q$path\E\/(.*)$/ ) {
228 $keep_back=$1;
229 if (!defined $custom_hash_ref->{$keep_back}) {
230 $custom_hash_ref->{$keep_back} = $path;
231 }
232 }
233 }
230 }
231}
232
233sub wanted
234{
235 my $file = $_;
234 }
235}
236
237sub wanted
238{
239 my $file = $_;
236
240
237 if ( $file =~ /.*\.png$/ && -f $file ) {
238 push @custom_list, $File::Find::name;
239 }
240}
241
242sub create_zip_list
243{
244 my $global_hash_ref = shift;

--- 34 unchanged lines hidden (view full) ---

279
280 return \%zip_hash
281}
282
283sub is_file_newer
284{
285 my $test_hash_ref = shift;
286 my $reference_stamp = 0;
241 if ( $file =~ /.*\.png$/ && -f $file ) {
242 push @custom_list, $File::Find::name;
243 }
244}
245
246sub create_zip_list
247{
248 my $global_hash_ref = shift;

--- 34 unchanged lines hidden (view full) ---

283
284 return \%zip_hash
285}
286
287sub is_file_newer
288{
289 my $test_hash_ref = shift;
290 my $reference_stamp = 0;
287
291
288 print_message("checking timestamps ...") if $verbose;
289 if ( -e $out_file ) {
290 $reference_stamp = (stat($out_file))[9];
291 print_message("found $out_file with $reference_stamp ...") if $verbose;
292 }
293 return 1 if $reference_stamp == 0;
292 print_message("checking timestamps ...") if $verbose;
293 if ( -e $out_file ) {
294 $reference_stamp = (stat($out_file))[9];
295 print_message("found $out_file with $reference_stamp ...") if $verbose;
296 }
297 return 1 if $reference_stamp == 0;
294
298
295 foreach ( sort keys %{$test_hash_ref} ) {
296 my $path = $test_hash_ref->{$_};
297 $path .= "/" if "$path" ne "";
298 $path .= "$_";
299 print_message("checking '$path' ...") if $extra_verbose;
300 my $mtime = (stat($path))[9];
301 return 1 if $reference_stamp < $mtime;
302 }
303 return 0;
304}
305
306sub optimize_zip_layout($)
307{
308 my $zip_hash_ref = shift;
309
310 if (!defined $sort_file) {
299 foreach ( sort keys %{$test_hash_ref} ) {
300 my $path = $test_hash_ref->{$_};
301 $path .= "/" if "$path" ne "";
302 $path .= "$_";
303 print_message("checking '$path' ...") if $extra_verbose;
304 my $mtime = (stat($path))[9];
305 return 1 if $reference_stamp < $mtime;
306 }
307 return 0;
308}
309
310sub optimize_zip_layout($)
311{
312 my $zip_hash_ref = shift;
313
314 if (!defined $sort_file) {
311 print_message("no sort file - sorting alphabetically ...") if $verbose;
312 return sort keys %{$zip_hash_ref};
315 print_message("no sort file - sorting alphabetically ...") if $verbose;
316 return sort keys %{$zip_hash_ref};
313 }
314 print_message("sorting from $sort_file ...") if $verbose;
315
316 my $orderh;
317 my %included;
318 my @sorted;
319 open ($orderh, $sort_file) || die "Can't open $sort_file: $!";
320 while (<$orderh>) {
317 }
318 print_message("sorting from $sort_file ...") if $verbose;
319
320 my $orderh;
321 my %included;
322 my @sorted;
323 open ($orderh, $sort_file) || die "Can't open $sort_file: $!";
324 while (<$orderh>) {
321 /^\#.*/ && next; # comments
322 s/[\r\n]*$//;
323 /^\s*$/ && next;
324 my $file = $_;
325 if (!defined $zip_hash_ref->{$file}) {
326 print "unknown file '$file'\n" if ($extra_verbose);
327 } else {
328 push @sorted, $file;
329 $included{$file} = 1;
330 }
325 /^\#.*/ && next; # comments
326 s/[\r\n]*$//;
327 /^\s*$/ && next;
328 my $file = $_;
329 if (!defined $zip_hash_ref->{$file}) {
330 print "unknown file '$file'\n" if ($extra_verbose);
331 } else {
332 push @sorted, $file;
333 $included{$file} = 1;
334 }
331 }
332 close ($orderh);
333
334 for my $img (sort keys %{$zip_hash_ref}) {
335 }
336 close ($orderh);
337
338 for my $img (sort keys %{$zip_hash_ref}) {
335 push @sorted, $img if (!$included{$img});
339 push @sorted, $img if (!$included{$img});
336 }
337
338 print_message("done sort ...") if $verbose;
339
340 return @sorted;
341}
342
343sub create_zip_archive

--- 90 unchanged lines hidden ---
340 }
341
342 print_message("done sort ...") if $verbose;
343
344 return @sorted;
345}
346
347sub create_zip_archive

--- 90 unchanged lines hidden ---