scpzipfiles.pm (dca4887f) | scpzipfiles.pm (dba1a2e4) |
---|---|
1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package installer::scpzipfiles; 25 26use installer::files; 27use installer::globals; 28use installer::logger; 29use installer::pathanalyzer; 30use installer::systemactions; 31 | 1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package installer::scpzipfiles; 25 26use installer::files; 27use installer::globals; 28use installer::logger; 29use installer::pathanalyzer; 30use installer::systemactions; 31 |
32use strict; 33 |
|
32######################################################################################## 33# Replacing all zip list variables in setup script and files with flag scpzip_replace 34######################################################################################## 35 | 34######################################################################################## 35# Replacing all zip list variables in setup script and files with flag scpzip_replace 36######################################################################################## 37 |
36sub replace_all_ziplistvariables_in_file | 38sub replace_all_ziplistvariables_in_file ($$) |
37{ | 39{ |
38 my ( $fileref, $variableshashref ) = @_; | 40 my ($lines, $variables) = @_; |
39 | 41 |
40 for ( my $i = 0; $i <= $#{$fileref}; $i++ ) | 42 my $count = scalar @$lines; 43 for (my $lineno=0; $lineno<$count; ++$lineno) |
41 { | 44 { |
42 my $line = ${$fileref}[$i]; 43 44 if ( $line =~ /^.*\$\{\w+\}.*$/ ) # only occurence of ${abc} 45 { 46 my $key; 47 48 foreach $key (keys %{$variableshashref}) | 45 my $line = $lines->[$lineno]; 46 if ($line =~ /\$\{/) # early rejection of lines that don't need replacements 47 { 48 while (my ($key,$value) = each %$variables) |
49 { | 49 { |
50 my $value = $variableshashref->{$key}; 51 $key = '${' . $key . '}'; 52 $line =~ s/\Q$key\E/$value/g; 53 ${$fileref}[$i] = $line; | 50 my $pattern = '${' . $key . '}'; 51 my $replacement_count = ($line =~ s/\Q$pattern\E/$value/g); 52 if ($key eq "PRODUCTADDON" && $replacement_count>0) 53 { 54 $installer::logger::Lang->printf( 55 "replaced PRODUCTADDON %d times in line %d\n", 56 $replacement_count, 57 $lineno); 58 } |
54 } | 59 } |
60 $lines->[$lineno] = $line; |
|
55 } 56 } 57} 58 59######################################################################################## 60# Replacing all zip list variables in rtf files. In rtf files 61# the brackets are masked. 62######################################################################################## 63 64sub replace_all_ziplistvariables_in_rtffile ($$) 65{ | 61 } 62 } 63} 64 65######################################################################################## 66# Replacing all zip list variables in rtf files. In rtf files 67# the brackets are masked. 68######################################################################################## 69 70sub replace_all_ziplistvariables_in_rtffile ($$) 71{ |
66 my ($lines, $variablesref) = @_; | 72 my ($lines, $variables) = @_; |
67 68 my $line_count = scalar @$lines; 69 for (my $i=0; $i<=$line_count; ++$i) 70 { 71 my $line = $lines->[$i]; 72 73 if ($line =~ /\$\\\{/) # early rejection of lines without variable references 74 { --- 95 unchanged lines hidden --- | 73 74 my $line_count = scalar @$lines; 75 for (my $i=0; $i<=$line_count; ++$i) 76 { 77 my $line = $lines->[$i]; 78 79 if ($line =~ /\$\\\{/) # early rejection of lines without variable references 80 { --- 95 unchanged lines hidden --- |