diff options
author | Sander Vesik <svesik@openoffice.org> | 2004-04-20 11:29:33 +0000 |
---|---|---|
committer | Sander Vesik <svesik@openoffice.org> | 2004-04-20 11:29:33 +0000 |
commit | b62ecdf921710ae053bf63347dc2f6911c736fa1 (patch) | |
tree | d21cdc98481f406931817dc8f4896e21074fee65 | |
parent | a587f675e9850ccc7bee472091fb1c7cf79f5b15 (diff) |
INTEGRATION: CWS newscpzip2 (1.1.2); FILE ADDED
2004/03/31 12:31:12 is 1.1.2.1: #i25325# new native packaging process
-rw-r--r-- | solenv/bin/modules/installer/remover.pm | 117 | ||||
-rw-r--r-- | solenv/bin/modules/installer/scppatchsoname.pm | 207 | ||||
-rw-r--r-- | solenv/bin/modules/installer/scpzipfiles.pm | 182 |
3 files changed, 506 insertions, 0 deletions
diff --git a/solenv/bin/modules/installer/remover.pm b/solenv/bin/modules/installer/remover.pm new file mode 100644 index 000000000000..81e35f58b498 --- /dev/null +++ b/solenv/bin/modules/installer/remover.pm @@ -0,0 +1,117 @@ +#************************************************************************* +# +# $RCSfile: remover.pm,v $ +# +# $Revision: 1.2 $ +# +# last change: $Author: svesik $ $Date: 2004-04-20 12:29:01 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +package installer::remover; + +use installer::globals; + +############################################ +# Remover +############################################ + +sub remove_leading_and_ending_whitespaces +{ + my ( $stringref ) = @_; + + $$stringref =~ s/^\s*//; + $$stringref =~ s/\s*$//; +} + +sub remove_leading_and_ending_quotationmarks +{ + my ( $stringref ) = @_; + + $$stringref =~ s/^\s*\"//; + $$stringref =~ s/\"\s*$//; +} + +sub remove_leading_and_ending_slashes +{ + my ( $stringref ) = @_; + + $$stringref =~ s/^\s*\///g; + $$stringref =~ s/\/\s*$//g; +} + +sub remove_ending_slashes +{ + my ( $stringref ) = @_; + + $$stringref =~ s/\/\s*$//g; +} + +sub remove_leading_and_ending_pathseparators +{ + my ( $stringref ) = @_; + + $$stringref =~ s/^\s*\Q$installer::globals::separator\E//; + $$stringref =~ s/\Q$installer::globals::separator\E\s*$//; +} + +sub remove_ending_pathseparator +{ + my ( $stringref ) = @_; + + $$stringref =~ s/\Q$installer::globals::separator\E\s*$//; +} + +1; diff --git a/solenv/bin/modules/installer/scppatchsoname.pm b/solenv/bin/modules/installer/scppatchsoname.pm new file mode 100644 index 000000000000..1959834283b0 --- /dev/null +++ b/solenv/bin/modules/installer/scppatchsoname.pm @@ -0,0 +1,207 @@ +#************************************************************************* +# +# $RCSfile: scppatchsoname.pm,v $ +# +# $Revision: 1.2 $ +# +# last change: $Author: svesik $ $Date: 2004-04-20 12:29:20 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +package installer::scppatchsoname; + +use installer::files; +use installer::globals; +use installer::logger; +use installer::setupscript; +use installer::systemactions; + +######################################################################################## +# The length of the new string must be identical with the length of the old string +######################################################################################## + +sub change_length_of_string +{ + my ($newstringref, $oldstring) = @_; + + while ( length($$newstringref) < length($oldstring) ) + { + $$newstringref = $$newstringref . chr(0); + } +} + +######################################################################################## +# Converting a string to a unicode string +######################################################################################## + +sub convert_to_unicode +{ + my ($string) = @_; + + my $unicodestring = ""; + + my $stringlength = length($string); + + for ( my $i = 0; $i < $stringlength; $i++ ) + { + $unicodestring = $unicodestring . substr($string, $i, 1); + $unicodestring = $unicodestring . chr(0); + } + + return $unicodestring; +} + +######################################################################################## +# Replacing the so name in all files with flag PATCH_SO_NAME +######################################################################################## + +sub replace_productname_in_file +{ + my ($sourcepath, $destpath, $variableshashref) = @_; + + my $onefile = installer::files::read_binary_file($sourcepath); + + my $onestring = "x" . chr(0); + my $replacestring = ""; + for ( my $i = 1; $i <= 80; $i++ ) { $replacestring .= $onestring; } + + my $productname = $variableshashref->{'PRODUCTNAME'}; + my $unicode_productname = convert_to_unicode($productname); + + change_length_of_string(\$unicode_productname, $replacestring); + + my $found = $onefile =~ s/$replacestring/$unicode_productname/s; + + installer::files::save_binary_file($onefile, $destpath); + + return $found; +} + +######################################################### +# Analyzing files with flag PATCH_SO_NAME +######################################################### + +sub resolving_patchsoname_flag +{ + my ($filesarrayref, $variableshashref, $item) = @_; + + my $diritem = lc($item); + + my $replacedirbase = installer::systemactions::create_directories("patchsoname_$diritem", ""); + + installer::logger::include_header_into_logfile("$item with flag PATCH_SO_NAME:"); + + for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) + { + my $onefile = ${$filesarrayref}[$i]; + my $styles = ""; + + if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } + + if ( $styles =~ /\bPATCH_SO_NAME\b/ ) + { + # Language specific subdirectory + + my $onelanguage = $onefile->{'specificlanguage'}; + + if ($onelanguage eq "") + { + $onelanguage = "00"; # files without language into directory "00" + } + + my $replacedir = $replacedirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; + installer::systemactions::create_directory($replacedir); # creating language specific directories + + # copy files and edit them with the variables defined in the zip.lst + + my $onefilename = $onefile->{'Name'}; + my $sourcepath = $onefile->{'sourcepath'}; + my $destinationpath = $replacedir . $onefilename; + my $movepath = $destinationpath . ".orig"; + + if (!(-f $destinationpath)) # do nothing if the file already exists + { + my $copysuccess = installer::systemactions::copy_one_file($sourcepath, $movepath); + + if ( $copysuccess ) + { + # Now the file can be patch (binary!) + + my $found = replace_productname_in_file($movepath, $destinationpath, $variableshashref); + + if ($found == 0) + { + my $infoline = "Did not patch the file $destinationpath\n"; + push( @installer::globals::logfileinfo, $infoline); + } + else + { + my $infoline = "Successfully patched $destinationpath, Count: $found\n"; + push( @installer::globals::logfileinfo, $infoline); + } + } + } + + # Writing the new sourcepath into the hashref, even if it was no copied + + $onefile->{'sourcepath'} = $destinationpath; + } + } + + my $infoline = "\n"; + push( @installer::globals::logfileinfo, $infoline); +} + +1; diff --git a/solenv/bin/modules/installer/scpzipfiles.pm b/solenv/bin/modules/installer/scpzipfiles.pm new file mode 100644 index 000000000000..3b637710a606 --- /dev/null +++ b/solenv/bin/modules/installer/scpzipfiles.pm @@ -0,0 +1,182 @@ +#************************************************************************* +# +# $RCSfile: scpzipfiles.pm,v $ +# +# $Revision: 1.2 $ +# +# last change: $Author: svesik $ $Date: 2004-04-20 12:29:33 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +package installer::scpzipfiles; + +use installer::files; +use installer::globals; +use installer::logger; +use installer::systemactions; + +######################################################################################## +# Replacing all zip list variables in setup script and files with flag scpzip_replace +######################################################################################## + +sub replace_all_ziplistvariables_in_file +{ + my ( $fileref, $variablesref ) = @_; + + for ( my $i = 0; $i <= $#{$fileref}; $i++ ) + { + my $line = ${$fileref}[$i]; + + if ( $line =~ /^.*\$\{\w+\}.*$/ ) # only occurence of ${abc} + { + for ( my $j = 0; $j <= $#{$variablesref}; $j++ ) + { + my $variableline = ${$variablesref}[$j]; + + my ($key, $value); + + if ( $variableline =~ /^\s*(\w+?)\s+(.*?)\s*$/ ) + { + $key = $1; + $value = $2; + $key = '${' . $key . '}'; + } + + $line =~ s/\Q$key\E/$value/g; + + ${$fileref}[$i] = $line; + } + } + } +} + +######################################################### +# Analyzing files with flag SCPZIP_REPLACE +# $item can be "File" or "ScpAction" +######################################################### + +sub resolving_scpzip_replace_flag +{ + my ($filesarrayref, $variablesref, $item) = @_; + + my $diritem = lc($item); + + my $replacedirbase = installer::systemactions::create_directories("replace_$diritem", ""); + + installer::logger::include_header_into_logfile("$item with flag SCPZIP:"); + + for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) + { + my $onefile = ${$filesarrayref}[$i]; + my $styles = ""; + + if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } + + if ( $styles =~ /\bSCPZIP_REPLACE\b/ ) + { + # Language specific subdirectory + + my $onelanguage = $onefile->{'specificlanguage'}; + + if ($onelanguage eq "") + { + $onelanguage = "00"; # files without language into directory "00" + } + + my $replacedir = $replacedirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; + installer::systemactions::create_directory($replacedir); # creating language specific directories + + if (!( $styles =~ /\bARCHIVE\b/ )) # The simple case + { + # copy files and edit them with the variables defined in the zip.lst + + my $onefilename = $onefile->{'Name'}; + my $sourcepath = $onefile->{'sourcepath'}; + my $destinationpath = $replacedir . $onefilename; + my $movepath = $destinationpath . ".orig"; + + if (!(-f $movepath)) # do nothing if the file already exists + { + my $copysuccess = installer::systemactions::copy_one_file($sourcepath, $movepath); + + if ( $copysuccess ) + { + # Now the file can be edited + # ToDo: How about binary patching? + + my $onefileref = installer::files::read_file($movepath); + replace_all_ziplistvariables_in_file($onefileref, $variablesref); + installer::files::save_file($destinationpath ,$onefileref); + } + } + + # Writing the new sourcepath into the hashref, even if it was no copied + + $onefile->{'sourcepath'} = $destinationpath; + } + else + { + # ToDo: How about SCPZIP_REPALCE and ARCHIVE? + # Requires that the zip file was unpacked in resolving_archive_flag + # and that $installer::globals::dounzip is set (Parameter -unzip). + } + } + } + + my $infoline = "\n"; + push( @installer::globals::logfileinfo, $infoline); +} + +1; |