diff options
-rw-r--r-- | postprocess/packconfig/makefile.mk | 77 | ||||
-rwxr-xr-x | postprocess/packconfig/packconfig.pl | 289 | ||||
-rw-r--r-- | postprocess/prj/build.lst | 4 | ||||
-rw-r--r-- | postprocess/prj/d.lst | 2 |
4 files changed, 372 insertions, 0 deletions
diff --git a/postprocess/packconfig/makefile.mk b/postprocess/packconfig/makefile.mk new file mode 100644 index 000000000000..1d8e82238aed --- /dev/null +++ b/postprocess/packconfig/makefile.mk @@ -0,0 +1,77 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: hjs $ $Date: 2004-10-29 10:31:09 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=.. + + + +PRJNAME=postprocess +TARGET=uiconfig + +.INCLUDE : settings.mk + +.INCLUDE : target.mk + +ALLTAR : $(COMMONBIN)$/uiconfig.zip + +$(COMMONBIN)$/uiconfig.zip .PHONY: + +$(PERL) packconfig.pl -i $(SOLARXMLDIR)$/uiconfig -o $@ + diff --git a/postprocess/packconfig/packconfig.pl b/postprocess/packconfig/packconfig.pl new file mode 100755 index 000000000000..d60ad187fd04 --- /dev/null +++ b/postprocess/packconfig/packconfig.pl @@ -0,0 +1,289 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; +#************************************************************************* +# +# $RCSfile: packconfig.pl,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: hjs $ $Date: 2004-10-29 10:31:09 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +# +# packconfig.pl - pack xml configuration into archives +# + +use strict; +use Getopt::Long; +use File::Find; +use File::Basename; +use Archive::Zip qw(:ERROR_CODES :CONSTANTS); + +#### globals #### + +my $out_file; # path to output archive +my $tmp_out_file; # path to temporary output file +my $files_path; # path to look for desired files +my $verbose; # be verbose +my $extra_verbose; # be extra verbose +my $do_rebuild = 0; # is rebuilding zipfile required? + +#### script id ##### + +( my $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/; + +my $script_rev; +my $id_str = ' $Revision: 1.1 $ '; +$id_str =~ /Revision:\s+(\S+)\s+\$/ + ? ($script_rev = $1) : ($script_rev = "-"); + +print "$script_name -- version: $script_rev\n"; + +#### main ##### + +parse_options(); +my %files_hash; +my $file_ref = get_files(); + +$do_rebuild = is_file_newer(\%files_hash) if $do_rebuild == 0; + +if ( $do_rebuild == 1 ) { + create_zip_archive(\%files_hash); + replace_file($tmp_out_file, $out_file); + print_message("packing $out_file finished."); +} else { + print_message("$out_file up to date. nothing to do."); +} + +exit(0); + +#### subroutines #### + +sub parse_options +{ + my $opt_help; + my $p = Getopt::Long::Parser->new(); + my $success =$p->getoptions( + '-h' => \$opt_help, + '-o=s' => \$out_file, + '-i=s' => \$files_path, + '-v' => \$verbose, + '-vv' => \$extra_verbose + ); + + if ( $opt_help || !$success || !$out_file || !$files_path ) + { + usage(); + exit(1); + } + + #define intermediate output file + $tmp_out_file="$out_file"."$$".$ENV{INPATH}; + # Sanity checks. + + # Check if out_file can be written. + my $out_dir = dirname($out_file); + print_error("no such directory: '$out_dir'", 2) if ! -d $out_dir; + print_error("can't search directory: '$out_dir'", 2) if ! -x $out_dir; + print_error("directory is not writable: '$out_dir'", 2) if ! -w $out_dir; + + # Check paths. + foreach ($files_path) { + print_error("no such directory: '$_'", 2) if ! -d $_; + print_error("can't search directory: '$_'", 2) if ! -x $_; + } +} + +sub get_files +{ + local @main::file_list; + + find_files(\%files_hash); + + if ( !keys %files_hash ) { + print_error("can't find any image lists in '$files_path'", 3); + } + + return wantarray ? @main::file_list : \@main::file_list; +} + +sub find_files +{ + my $files_hash_ref = shift; + find({ wanted => \&wanted, no_chdir => 0 }, "$files_path"); + foreach ( @main::file_list ) { + /^\Q$files_path\E\/(.*)$/o; + $files_hash_ref->{$1}++; + } +} + +sub wanted +{ + my $file = $_; + + if ( $file =~ /.*\.xml$/ && -f $file ) { + push @main::file_list, $File::Find::name; + } +} + +sub is_file_newer +{ + my $test_hash_ref = shift; + my $reference_stamp = 0; + + print_message("checking timestamps ...") if $verbose; + if ( -e $out_file ) { + $reference_stamp = (stat($out_file))[9]; + print_message("found $out_file with $reference_stamp ...") if $verbose; + } + return 1 if $reference_stamp == 0; + + foreach ( sort keys %{$test_hash_ref} ) { + my $path = $files_path; + $path .= "/" if "$path" ne ""; + $path .= "$_"; + print_message("checking '$path' ...") if $extra_verbose; + my $mtime = (stat($path))[9]; + return 1 if $reference_stamp < $mtime; + } + return 0; +} + +sub create_zip_archive +{ + my $zip_hash_ref = shift; + + print_message("creating config archive ...") if $verbose; + my $zip = Archive::Zip->new(); + + foreach ( sort keys %{$zip_hash_ref} ) { + my $path = "$files_path/$_"; + print_message("zipping '$path' ...") if $extra_verbose; + if ( !$zip->addFile($path, $_) ) { + print_error("can't add file '$path' to config zip archive: $!", 5); + } + } + my $status = $zip->writeToFileNamed($tmp_out_file); + if ( $status != AZ_OK ) { + print_error("write image zip archive '$tmp_out_file' failed. Reason: $status", 6); + } + return; +} + +sub replace_file +{ + my $source_file = shift; + my $dest_file = shift; + my $result = 0; + + $result = unlink($dest_file) if -f $dest_file; + if ( $result != 1 && -f $dest_file ) { + unlink $source_file; + print_error("couldn't remove '$dest_file'",1); + } else { + if ( !rename($source_file, $dest_file)) { + unlink $source_file; + print_error("couldn't rename '$source_file'",1); + } + } + return; +} + +sub usage +{ + print STDERR "Usage: packimages.pl [-h] -o out_file -i file_path\n"; + print STDERR "Creates archive of images\n"; + print STDERR "Options:\n"; + print STDERR " -h print this help\n"; + print STDERR " -o out_file path to output archive\n"; + print STDERR " -i file_path path to directory containing the config files\n"; + print STDERR " -v verbose\n"; + print STDERR " -vv very verbose\n"; +} + +sub print_message +{ + my $message = shift; + + print "$script_name: "; + print "$message\n"; + return; +} + +sub print_warning +{ + my $message = shift; + + print STDERR "$script_name: "; + print STDERR "WARNING $message\n"; + return; +} + +sub print_error +{ + my $message = shift; + my $error_code = shift; + + print STDERR "$script_name: "; + print STDERR "ERROR: $message\n"; + + if ( $error_code ) { + print STDERR "\nFAILURE: $script_name aborted.\n"; + exit($error_code); + } + return; +} diff --git a/postprocess/prj/build.lst b/postprocess/prj/build.lst new file mode 100644 index 000000000000..1f2a3b4b0ccf --- /dev/null +++ b/postprocess/prj/build.lst @@ -0,0 +1,4 @@ +po postprocess : ecomp sdk_oo NULL +po postprocess usr1 - all po_mkout NULL +po postprocess\packconfig nmake - all po_packconfig NULL +po postprocess\rebase nmake - w po_rebase NULL diff --git a/postprocess/prj/d.lst b/postprocess/prj/d.lst new file mode 100644 index 000000000000..917d3550e970 --- /dev/null +++ b/postprocess/prj/d.lst @@ -0,0 +1,2 @@ +..\%COMMON_OUTDIR%\bin\uiconfig.zip %COMMON_DEST%\bin%_EXT%\uiconfig.zip + |