diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-08-23 09:47:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-08-23 09:58:26 +0200 |
commit | 52755d6d2cf1c6addaf3c91b93bb86d66b730409 (patch) | |
tree | a4bcb7df4c38ddf3c683a8b051d45eb29fedb2f4 /solenv | |
parent | fcd990f208be4430157dca2d6093337f21cb079b (diff) |
Revert "installer: Use hashref for replace_all_ziplistvariables_in_rtffile"
This reverts commit 46a977081c6f1886f8fff8457c85e6d426dcc20f. It started to
replace occurrences of "${...}" unknown to the installer with empty strings,
instead of keeping them as-is. This caused the "${ORIGIN}" at the start of the
value for URE_BOOTSTRAP to disappear from the soffice ini-file (cf.
gid_Brand_Profileitem_Soffice_UreBootstrap in scp2/source/ooo/common_brand.scp),
making soffice fail to start completely.
Change-Id: Ia7a34179b78677a703fc487401e011073d14a176
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/modules/installer.pm | 2 | ||||
-rw-r--r-- | solenv/bin/modules/installer/scpzipfiles.pm | 50 | ||||
-rw-r--r-- | solenv/bin/modules/t/installer-scpzipfiles.t | 63 |
3 files changed, 43 insertions, 72 deletions
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm index 3820c7002c9a..ebfae1a1b1c1 100644 --- a/solenv/bin/modules/installer.pm +++ b/solenv/bin/modules/installer.pm @@ -1639,7 +1639,7 @@ sub main { { my $licensefilesource = installer::windows::idtglobal::get_rtflicensefilesource($onelanguage, $includepatharrayref_lang); my $licensefile = installer::files::read_file($licensefilesource); - installer::scpzipfiles::replace_all_ziplistvariables_in_rtffile($licensefile, $allvariableshashref); + installer::scpzipfiles::replace_all_ziplistvariables_in_rtffile($licensefile, $allvariablesarrayref, $onelanguage, $loggingdir); my $controltablename = $languageidtdir . $installer::globals::separator . "Control.idt"; my $controltable = installer::files::read_file($controltablename); installer::windows::idtglobal::add_licensefile_to_database($licensefile, $controltable); diff --git a/solenv/bin/modules/installer/scpzipfiles.pm b/solenv/bin/modules/installer/scpzipfiles.pm index 70283f2b8c35..cb0e6408e565 100644 --- a/solenv/bin/modules/installer/scpzipfiles.pm +++ b/solenv/bin/modules/installer/scpzipfiles.pm @@ -39,26 +39,60 @@ use installer::systemactions; sub replace_all_ziplistvariables_in_file { - my ( $fileref, $variablesref ) = @_; + my ( $fileref, $variableshashref ) = @_; - for my $line ( @{$fileref} ) + for ( my $i = 0; $i <= $#{$fileref}; $i++ ) { - $line =~ s/\$\{(\w+)\}/$variablesref->{$1}/eg; + my $line = ${$fileref}[$i]; + + if ( $line =~ /^.*\$\{\w+\}.*$/ ) # only occurrence of ${abc} + { + my $key; + + foreach $key (keys %{$variableshashref}) + { + my $value = $variableshashref->{$key}; + $key = '${' . $key . '}'; + $line =~ s/\Q$key\E/$value/g; + ${$fileref}[$i] = $line; + } + } } } ######################################################################################## -# Replacing all zip list variables in rtf files. +# Replacing all zip list variables in rtf files. In rtf files +# the brackets are masked. ######################################################################################## sub replace_all_ziplistvariables_in_rtffile { - my ( $fileref, $variablesref ) = @_; + my ( $fileref, $variablesref, $onelanguage, $loggingdir ) = @_; - for my $line ( @{$fileref} ) + for ( my $i = 0; $i <= $#{$fileref}; $i++ ) { - # In rtf files the braces are backslash-escaped. - $line =~ s/\$\\\{(\w+)\\\}/$variablesref->{$1}/eg; + my $line = ${$fileref}[$i]; + + if ( $line =~ /^.*\$\\\{\w+\\\}.*$/ ) # only occurrence 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; + } + } } } diff --git a/solenv/bin/modules/t/installer-scpzipfiles.t b/solenv/bin/modules/t/installer-scpzipfiles.t deleted file mode 100644 index e98bfd033bde..000000000000 --- a/solenv/bin/modules/t/installer-scpzipfiles.t +++ /dev/null @@ -1,63 +0,0 @@ -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# Major Contributor(s): -# [ Copyright (C) 2012 Tim Retout <tim@retout.co.uk> (initial developer) ] -# -# All Rights Reserved. -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. - -use strict; -use warnings; - -use lib '.'; - -use Test::More; - -use installer::scpzipfiles; - -my $vars = { foo => "bar" }; - -my %lines; -my $i = 0; -while (<DATA>) { - push @{ $lines{$i++ % 3} }, $_; -} - -my @file1 = @{ $lines{0} }; -my @file2 = @{ $lines{0} }; - -installer::scpzipfiles::replace_all_ziplistvariables_in_file(\@file1, $vars); -installer::scpzipfiles::replace_all_ziplistvariables_in_rtffile(\@file2, $vars); - -is_deeply(\@file1, $lines{1}, 'replace_all_ziplistvariables_in_file works'); -is_deeply(\@file2, $lines{2}, 'replace_all_ziplistvariables_in_rtffile works'); - -done_testing(); - -__DATA__ -This is a test -This is a test -This is a test -A test of ${foo} replacement ${foo}. -A test of bar replacement bar. -A test of ${foo} replacement ${foo}. -A test of RTF $\{foo\} replacement $\{foo\}. -A test of RTF $\{foo\} replacement $\{foo\}. -A test of RTF bar replacement bar. |