|
1 # |
|
2 # Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: A tool that install widgets and dtd files. |
|
15 # Tool is mainly meant to be used via dtd.mk makefile template, |
|
16 # but can be run as such also. |
|
17 # |
|
18 |
|
19 use strict; |
|
20 use FindBin; # for FindBin::Bin |
|
21 my $PerlLibPath; # fully qualified pathname of the directory containing our Perl modules |
|
22 |
|
23 BEGIN { |
|
24 # check user has a version of perl that will cope |
|
25 require 5.005_03; |
|
26 # establish the path to the Perl libraries: currently the same directory as this script |
|
27 $PerlLibPath = $FindBin::Bin; # X:/epoc32/tools |
|
28 # do not convert slashes for linux |
|
29 if ($^O eq "MSWin32") { |
|
30 $PerlLibPath =~ s/\//\\/g; # X:\epoc32\tools |
|
31 $PerlLibPath .= "\\"; |
|
32 } |
|
33 } |
|
34 |
|
35 use lib $PerlLibPath; |
|
36 |
|
37 use Cwd; |
|
38 use Getopt::Long; |
|
39 use Convert_file; # for .dtd to .loc file conversion |
|
40 use File::Copy; |
|
41 use File::Find; # for finding |
|
42 use File::Path; # mkpath |
|
43 use File::Basename; # fileparse |
|
44 |
|
45 if ( $#ARGV < 1) |
|
46 { |
|
47 print <<USAGE; |
|
48 Usage: dtd_installer.pl -n dtd_name [-t type][-l dtd_location] [-s sub_folder_name] [-o output_location] [-a action_type] [-f force_create] [-d debug] |
|
49 -n: widget or dtd (switch_loc) file name |
|
50 -t: optional, default type is dtd and other possibility is widget |
|
51 -l: optional, input path location, |
|
52 default for widget type is \\epoc32\\data\\z\\resource\\homescreen |
|
53 default for dtd is \\epoc32\\include\\domain\\<layer>\\loc |
|
54 -s: optional, for widgets only, default are xuikon and hsps |
|
55 -o: optional, default is \\epoc32\\release\\winscw\\udeb\\z\\private\\200159c0\\install |
|
56 -a: optional, default is build other possible are what and clean |
|
57 -f: optional, for widgets only, themeinstaller is always run for xuikon, even switch loc file don\'t exist |
|
58 -d: optional, for debugging purposes (e.g. temporary folders aren't deleted) |
|
59 |
|
60 Example how to run for dtd files only: |
|
61 dtd_installer.pl -n matrixmenudata -o \\epoc32\\data\\z\\private\\200113DD\\content |
|
62 Example how to run for one widget: |
|
63 dtd_installer.pl -n view -t type widget |
|
64 Example how to run for all widgets: |
|
65 dtd_installer.pl -n all_widgets -t type widget -d yes |
|
66 |
|
67 USAGE |
|
68 exit -1; |
|
69 } |
|
70 |
|
71 my ($dtd_name, $dtd_type, $dtd_location, $sub_folder_name, $output_location, $action_type, $force_create, $debug, $what_output_file); |
|
72 my (@all_dirs, @find_files, @files_to_convert); |
|
73 my @sub_folders=("xuikon","hsps"); |
|
74 |
|
75 my $EPOCROOT = $ENV{EPOCROOT}; |
|
76 $EPOCROOT =~ s#[/\\]*$##; |
|
77 |
|
78 my $PATHSEP='/'; |
|
79 if ($^O eq "MSWin32" ) { |
|
80 $PATHSEP='\\'; |
|
81 } |
|
82 |
|
83 my @layers=( |
|
84 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}domain${PATHSEP}osextensions${PATHSEP}loc", |
|
85 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}domain${PATHSEP}middleware${PATHSEP}loc", |
|
86 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}domain${PATHSEP}applications${PATHSEP}loc", |
|
87 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}platform${PATHSEP}loc", |
|
88 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}platform${PATHSEP}mw${PATHSEP}loc", |
|
89 $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}include${PATHSEP}platform${PATHSEP}app${PATHSEP}loc"); |
|
90 |
|
91 my $themeinstaller_tool = $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}tools${PATHSEP}themeinstaller${PATHSEP}themeinstaller"; |
|
92 if ($^O eq "MSWin32" ) { |
|
93 $themeinstaller_tool = $themeinstaller_tool . ".bat"; |
|
94 } |
|
95 |
|
96 my $themeinstaller_property_file = $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}tools${PATHSEP}themeinstaller${PATHSEP}data${PATHSEP}widgetinstaller.prop"; |
|
97 |
|
98 # Set this to 1 if you need to debug the script |
|
99 # $debug = 1; |
|
100 |
|
101 GetOptions( |
|
102 'n=s' => \$dtd_name, |
|
103 't=s' => \$dtd_type, |
|
104 'l=s' => \$dtd_location, |
|
105 's=s' => \$sub_folder_name, |
|
106 'o=s' => \$output_location, |
|
107 'a=s' => \$action_type, |
|
108 'd=s' => \$debug, |
|
109 'f=s' => \$force_create ); |
|
110 |
|
111 check_options(); |
|
112 |
|
113 if (($action_type eq "what") && (-e $what_output_file)) { |
|
114 open( WHAT, $what_output_file) or die $!; |
|
115 while( <WHAT> ){ |
|
116 print ; |
|
117 } |
|
118 close WHAT; |
|
119 exit; |
|
120 } elsif (($action_type eq "clean") && (-e $what_output_file)) { |
|
121 unlink $what_output_file; |
|
122 } |
|
123 |
|
124 if ($dtd_type eq "widget") { |
|
125 if ((lc $dtd_name) eq "all_widgets") { |
|
126 # read all widget names from given directory |
|
127 opendir(SDIR, $dtd_location) or die("ERROR: dtd_installer.pl, can not open $dtd_location\n"); |
|
128 @all_dirs = grep !/^\.\.?$/, readdir SDIR; |
|
129 closedir(SDIR); |
|
130 if (!@all_dirs) { |
|
131 warn"ERROR: dtd_installer.pl, couldn't find any widgets:\n"; |
|
132 die; |
|
133 } |
|
134 foreach my $temp_dtd_name (@all_dirs) { |
|
135 $dtd_name = $temp_dtd_name; |
|
136 my $dir = "${dtd_location}\\${dtd_name}"; |
|
137 if (-d $dir) { # Calling process_widget sub routine for every directory |
|
138 process_widget(); |
|
139 } |
|
140 } |
|
141 } else { # Only one widget processed |
|
142 process_widget(); |
|
143 } |
|
144 } else { |
|
145 # Run only .loc to .dtd conversion for non widgets |
|
146 process_dtd($output_location, $dtd_name); |
|
147 } |
|
148 |
|
149 sub process_widget |
|
150 { |
|
151 |
|
152 foreach my $sub_f (@sub_folders) { |
|
153 my @lang_dirs; |
|
154 if ($debug) { print "Current subfolder:\n $sub_f\n"; } |
|
155 ${sub_folder_name} = $sub_f; |
|
156 if ($debug) { print "Processing widget:\n${dtd_location}\\${dtd_name}\n"; } |
|
157 |
|
158 my $current_time = time; |
|
159 my $full_dtd_input_path = "${dtd_location}\\${dtd_name}\\${sub_folder_name}"; |
|
160 my $full_dtd_output_path = "${output_location}\\${dtd_name}\\${sub_folder_name}"; |
|
161 my $temp_path = "${dtd_location}\\${dtd_name}\\temp"; |
|
162 my $temp_loc_path = "${dtd_location}\\${dtd_name}\\${sub_folder_name}\\temp"; |
|
163 my $temp_dtd_path = "${temp_path}\\$current_time"; |
|
164 my $temp_loc_files_path = "${temp_loc_path}\\$current_time"; |
|
165 my $no_success = 1; |
|
166 my $count = 0; |
|
167 |
|
168 while ($no_success) { # make sure that temporary directory isn't already in the use |
|
169 undef $no_success; |
|
170 $current_time = time; |
|
171 $temp_dtd_path = "${temp_path}\\$current_time"; |
|
172 mkpath $temp_dtd_path or $no_success=1; |
|
173 sleep 1; |
|
174 $count++; |
|
175 if ($count > 100 ) { warn: "ERROR: dtd_installer.pl, couldn't create temp directory $temp_dtd_path !!!\nDtd_installer\.pl script stopped\n"; die;} |
|
176 } |
|
177 $count = 0; |
|
178 $no_success = 1; |
|
179 while ($no_success) { # make sure that temporary directory isn't already in the use |
|
180 undef $no_success; |
|
181 $current_time = time; |
|
182 $temp_loc_files_path = "${temp_loc_path}\\$current_time"; |
|
183 mkpath $temp_loc_files_path or $no_success=1; |
|
184 sleep 1; |
|
185 $count++; |
|
186 if ($count > 100 ) { warn: "ERROR: dtd_installer.pl, couldn't create temp directory $temp_loc_files_path!!!\nDtd_installer\.pl script stopped\n"; die;} |
|
187 } |
|
188 |
|
189 if ($debug) { print "Full dtd input path:\n$full_dtd_input_path\n"; } |
|
190 if ($debug) { print "Full dtd output path:\n$full_dtd_output_path\n"; } |
|
191 opendir(SDIR, $full_dtd_input_path) or die("ERROR: dtd_installer.pl, can not open $full_dtd_input_path\n"); |
|
192 @lang_dirs = grep !/^\.\.?$/, readdir SDIR; |
|
193 closedir(SDIR); |
|
194 |
|
195 |
|
196 if (${sub_folder_name} eq "xuikon") { # Copy engineering english files always to 00 folder |
|
197 copy_files($full_dtd_input_path,"${temp_loc_files_path}\\00"); |
|
198 } else{ #hsps folder |
|
199 copy_files($full_dtd_input_path,"${full_dtd_output_path}\\00"); |
|
200 } |
|
201 |
|
202 |
|
203 foreach my $lang_id (@lang_dirs) { # generate localized .dtd files |
|
204 |
|
205 my $dtd_temp = "${full_dtd_input_path}\\${lang_id}"; |
|
206 if ((-f $dtd_temp) && ($lang_id =~ /.dtd/i) ) { # running loc to dtd for all .dtd files |
|
207 if ($debug) { print "Dtd file found:\n$dtd_temp\n"; } |
|
208 |
|
209 if (${sub_folder_name} eq "xuikon") { # generate xuikon .dtd files to temp path |
|
210 if ($debug) { print "Widget type DTD, xuikon subfolder\n"; } |
|
211 process_dtd($temp_loc_files_path, $lang_id); |
|
212 } else{ #hsps folder |
|
213 if ($debug) { print "Widget type DTD, hsps subfolder\n"; } |
|
214 process_dtd($full_dtd_output_path, $lang_id); |
|
215 } |
|
216 } elsif ((${sub_folder_name} eq "xuikon") && ($force_create ne "") && (-d $dtd_temp)) { |
|
217 copy_files($dtd_temp,"${temp_loc_files_path}\\${lang_id}"); |
|
218 } |
|
219 } |
|
220 |
|
221 if (${sub_folder_name} eq "xuikon") { # generate localized files |
|
222 if (!(-f $themeinstaller_tool)) { die("ERROR: dtd_installer.pl, can not find themeinstaller: $themeinstaller_tool\n"); } |
|
223 if (!(-f $themeinstaller_property_file)) { die("ERROR: dtd_installer.pl, can not find themeinstaller property file: $themeinstaller_property_file\n"); } |
|
224 |
|
225 if (-d $temp_loc_files_path) { |
|
226 opendir(SDIR, $temp_loc_files_path) or die("ERROR: dtd_installer.pl, can not open $temp_loc_files_path\n"); |
|
227 @lang_dirs = grep !/^\.\.?$/, readdir SDIR; |
|
228 closedir(SDIR); |
|
229 |
|
230 foreach my $lang_id (@lang_dirs) { |
|
231 my $lang_dir = "$temp_loc_files_path\\$lang_id"; |
|
232 if ($debug) { print"Language directory:\n$lang_dir\n"; } |
|
233 if (-d $lang_dir) { # Running themeinstaller for all language folders in temp path |
|
234 my $temp_dir = "$temp_dtd_path\\$lang_id"; |
|
235 copy_files($full_dtd_input_path, "$temp_dir"); |
|
236 my $lang_temp_dir = "$full_dtd_input_path\\$lang_id"; |
|
237 if (-d $lang_temp_dir) { |
|
238 copy_files("$lang_temp_dir", "$temp_dir"); |
|
239 } |
|
240 copy_files("$temp_loc_files_path\\$lang_id", "$temp_dir"); |
|
241 if (($action_type eq "build") || ($debug)) { |
|
242 print ("Calling themeinstaller: \n$themeinstaller_tool $temp_dtd_path\\${lang_id}\\${dtd_name}.dat $temp_dtd_path\\${lang_id} -prop:${themeinstaller_property_file}\n"); |
|
243 system ("$themeinstaller_tool","$temp_dtd_path\\${lang_id}\\${dtd_name}.dat","$temp_dtd_path\\${lang_id}", "-prop:${themeinstaller_property_file}"); |
|
244 } else { |
|
245 system ("$themeinstaller_tool","$temp_dtd_path\\${lang_id}\\${dtd_name}.dat","$temp_dtd_path\\${lang_id}", "-prop:${themeinstaller_property_file}", ">$temp_dtd_path\\${lang_id}\\themeinstaller.log", "2>&1" ); |
|
246 } |
|
247 copy_files("$temp_dir", "$full_dtd_output_path\\$lang_id", "recursive"); |
|
248 } |
|
249 } |
|
250 } |
|
251 } |
|
252 |
|
253 if ($debug) { |
|
254 print "Widget processed: ${dtd_name} \n"; |
|
255 } else { |
|
256 # Remove all temporary directories |
|
257 if (-d $temp_dtd_path) { rmtree ($temp_dtd_path); } |
|
258 if (-d $temp_loc_files_path) { rmtree ($temp_loc_files_path); } |
|
259 rmdir $temp_path; |
|
260 rmdir $temp_loc_path; |
|
261 } |
|
262 } |
|
263 } |
|
264 |
|
265 sub process_dtd { |
|
266 |
|
267 my $output_path = shift; |
|
268 my $switch_loc_name = shift; |
|
269 $switch_loc_name =~ s/.dtd//i;; # remove the .dtd extension |
|
270 my $input_path = $dtd_location; |
|
271 my ($found, $loc_file); |
|
272 if ($action_type eq "build") { print "Used switch loc file name:\n${switch_loc_name}\n"; } |
|
273 if ($debug) { print "Used input path:\n${input_path}\n"; } |
|
274 if ($debug) { print "Used output path:\n${output_path}\n"; } |
|
275 |
|
276 foreach (@layers) { |
|
277 $input_path = $_; |
|
278 if ($debug) { print("Used switch loc file path:\n${input_path}\n"); } |
|
279 my $loc_file = "${input_path}\\${switch_loc_name}.loc"; |
|
280 if (-e $loc_file) { |
|
281 convert_locs_to_dtds($loc_file, $input_path, $output_path); |
|
282 $found = "yes"; |
|
283 } |
|
284 } |
|
285 if ($found ne "yes") { |
|
286 warn "ERROR: dtd_installer.pl, no .loc file found:\n${switch_loc_name}.loc\n"; |
|
287 } |
|
288 } |
|
289 |
|
290 sub check_options { |
|
291 |
|
292 if ($dtd_name eq "") { |
|
293 warn: "ERROR: dtd_installer.pl, no widget name given!!!\nDtd_installer\.pl script stopped\n"; |
|
294 die; |
|
295 } |
|
296 |
|
297 if ($dtd_type eq "") { |
|
298 $dtd_type = "dtd"; |
|
299 } |
|
300 |
|
301 if ($dtd_location eq "") { |
|
302 if ($dtd_type eq "widget") { |
|
303 $dtd_location = "\\epoc32\\data\\z\\resource\\homescreen"; |
|
304 } |
|
305 } else { |
|
306 if ($dtd_type eq "dtd") { |
|
307 undef @layers; |
|
308 @layers[0]=${dtd_location}; |
|
309 } |
|
310 } |
|
311 |
|
312 if ($output_location eq "") { |
|
313 $output_location = "\\epoc32\\release\\winscw\\udeb\\z\\private\\200159c0\\install"; |
|
314 } |
|
315 |
|
316 if (${sub_folder_name} ne ""){ |
|
317 undef @sub_folders; |
|
318 @sub_folders[0]=${sub_folder_name}; |
|
319 } |
|
320 |
|
321 if ($action_type eq "") { |
|
322 $action_type = "build"; |
|
323 } |
|
324 |
|
325 $dtd_location =~ s/\//\\/g; #Change / marks to \ |
|
326 $output_location =~ s/\//\\/g; #Change / marks to \ |
|
327 $what_output_file = $output_location; |
|
328 $what_output_file =~ s/\\/_/g; #Change \ marks to _ |
|
329 $what_output_file =~ s/:/_/g; #Change : marks to _ |
|
330 if ($ENV{SBS_BUILD_DIR}) { |
|
331 $what_output_file = $ENV{SBS_BUILD_DIR} . "${PATHSEP}dtd_installer${PATHSEP}" . $what_output_file . $dtd_name . ".txt"; |
|
332 if ( !-d $ENV{SBS_BUILD_DIR} . "${PATHSEP}dtd_installer") { mkdir($ENV{SBS_BUILD_DIR} . "${PATHSEP}dtd_installer"); } |
|
333 } |
|
334 else { |
|
335 $what_output_file = $EPOCROOT . "${PATHSEP}epoc32${PATHSEP}build${PATHSEP}dtd_installer${PATHSEP}" . $what_output_file . $dtd_name . ".txt"; |
|
336 if ( !-d "/epoc32/build/dtd_installer") { mkdir("/epoc32/build/dtd_installer"); } |
|
337 } |
|
338 |
|
339 if ($debug) { print "Output what file: $what_output_file\n"; } |
|
340 } |
|
341 |
|
342 # This subroutine moves files to/from temporary themeinstaller location. |
|
343 sub copy_files { |
|
344 my $in_path = shift; |
|
345 my $out_path = shift; |
|
346 my $recursive = shift; |
|
347 if ($debug) { print "Copying from: $in_path\n"; } |
|
348 if ($debug) { print "To: $out_path\n"; } |
|
349 |
|
350 if ($recursive) { |
|
351 find( \&getFiles, $in_path ); |
|
352 } else { |
|
353 opendir(SDIR, $in_path) or die("ERROR: dtd_installer.pl, can not open $in_path\n"); |
|
354 @find_files = grep !/^\.\.?$/, readdir SDIR; |
|
355 closedir(SDIR); |
|
356 } |
|
357 |
|
358 foreach my $file (@find_files) { |
|
359 my $in_file = "${in_path}\\${file}"; |
|
360 my $out_file= "${out_path}\\${file}"; |
|
361 if ($recursive) { |
|
362 $in_file = $file; |
|
363 $file =~ /.*\\(.*)\\.*\\.*\\.*\\(.*)\\(.*)/i; |
|
364 my $temp=$1; # lang code |
|
365 my $temp2=$3; # file name |
|
366 if ((lc $2) eq "sources") { |
|
367 $out_file = "${out_path}\\$3"; |
|
368 } else { |
|
369 if (length($temp) > 5) { #skip extra files |
|
370 next; |
|
371 } |
|
372 while (length($temp) < 4){ $temp = "0".$temp; } |
|
373 $temp2 =~ s/\d{4}/$temp/g; # change .odt filename for correct lang |
|
374 $out_file = "${out_path}\\$temp2"; |
|
375 } |
|
376 } |
|
377 if ($debug) { print "Copying file from: $in_file\n"; } |
|
378 if ($debug) { print "To: $out_file\n"; } |
|
379 if (-f $in_file){ |
|
380 if ($action_type eq "build") { |
|
381 if ((!($out_file =~ /\\temp\\/i))) {write_what_file("$out_file")}; |
|
382 xcopy($in_file,$out_file); |
|
383 } elsif ($action_type eq "clean") { |
|
384 if (!($out_file =~ /\\temp\\/i)) { |
|
385 unlink $out_file; |
|
386 my $temp_dir_path = $out_file; |
|
387 $temp_dir_path =~ /(.*)\\.*/; |
|
388 $temp_dir_path = $1; |
|
389 rmdir $temp_dir_path; # Try to remove empty language directories |
|
390 } else { |
|
391 xcopy($in_file,$out_file); |
|
392 } |
|
393 } elsif ($action_type eq "what") { |
|
394 if (!($out_file =~ /\\temp\\/i)) { |
|
395 write_what_file("$out_file"); |
|
396 print("$out_file\n"); |
|
397 } else { |
|
398 xcopy($in_file,$out_file); |
|
399 } |
|
400 } else { |
|
401 warn ("ERROR: dtd_installer.pl, unknown action type"); |
|
402 } |
|
403 } else { |
|
404 if ($debug) { print "Not file found: $in_file\n"; } |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 # This subroutine converts LOC files to DTD files. Files that are |
|
410 # listed in the switch_loc file are converted to DTD files. |
|
411 |
|
412 sub convert_locs_to_dtds { |
|
413 my $switch_loc_file = shift; |
|
414 my $in_path = shift; |
|
415 my $out_path = shift; |
|
416 |
|
417 open(my $switch_loc_file_handle, "$switch_loc_file") |
|
418 or die "Can't open `$switch_loc_file' for reading: $!"; |
|
419 |
|
420 # Read localised .loc file names from used input switch loc file |
|
421 while (my $line = <$switch_loc_file_handle>) { |
|
422 chomp($line); |
|
423 if (($line =~ "include") && (!($line =~ /\<sc\//i)) && (!($line =~ /\<00\//i)) ){ # Read all lines that contains include, except sc and 00 |
|
424 $line=~ /.*\<(.*)\>.*/; |
|
425 $line=$1; |
|
426 $line =~ s/\//\\/g; #Change / marks to \ |
|
427 if ($debug) { print"Adding localised file to conversion list:\n$line\n"; } |
|
428 push @files_to_convert, $line; |
|
429 } |
|
430 } |
|
431 |
|
432 close $switch_loc_file_handle; |
|
433 |
|
434 # Process all the .loc files. |
|
435 foreach (@files_to_convert) { |
|
436 my $loc_file = "$in_path\\$_"; |
|
437 my $out_file = "$out_path\\$_"; |
|
438 $out_file =~ s/_\d{2,5}(.{4})$/$1/i; # remove the language code from the file name. |
|
439 if ($debug) { print"Trying to convert file:\n$loc_file\n"; } |
|
440 if ($debug) { print"To out file:\n$out_file\n"; } |
|
441 if (-f $loc_file) { |
|
442 if (($action_type eq "build") || ((${dtd_type} eq "widget") && (${sub_folder_name} eq "xuikon")) ) { |
|
443 #old if ((!($out_file =~ /\\temp\\/i))) {write_what_file("$out_file")}; |
|
444 xcopy($loc_file,$out_file); |
|
445 Convert_file::convert_file($out_file); |
|
446 if ((!($out_file =~ /\\temp\\/i))) { |
|
447 my $convert_out_file = $out_file; |
|
448 $convert_out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd |
|
449 write_what_file("$convert_out_file"); |
|
450 } |
|
451 if (!($debug)) { unlink $out_file; } # Delete the copied .loc file |
|
452 $out_file =~ s/\.loc/\.log/; # replace .loc with .log |
|
453 if (!($debug)) { unlink $out_file; } # Delete the conversion .log file |
|
454 } elsif ($action_type eq "clean") { |
|
455 $out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd |
|
456 unlink $out_file; # delete the output file |
|
457 my $temp_dir_path = $out_file; |
|
458 $temp_dir_path =~ /(.*)\\.*/; |
|
459 $temp_dir_path = $1; |
|
460 rmdir $temp_dir_path; # Try to remove empty language directories |
|
461 } elsif (($action_type eq "what") && (!($out_file =~ /\\temp\\/i))) { |
|
462 $out_file =~ s/\.loc/\.dtd/; # replace .loc with .dtd |
|
463 print("$out_file\n"); |
|
464 write_what_file("$out_file"); |
|
465 } |
|
466 } else { |
|
467 warn "ERROR: dtd_installer.pl, no .loc file found: $loc_file\n"; |
|
468 } |
|
469 } |
|
470 } |
|
471 |
|
472 # This subroutine is for file copying |
|
473 sub xcopy |
|
474 { |
|
475 my $source = shift; |
|
476 my $dist = shift; |
|
477 |
|
478 # if distination file exist then clear read flag |
|
479 if (-f $dist) |
|
480 { |
|
481 chmod ($dist , 0755); |
|
482 } |
|
483 else |
|
484 { |
|
485 my($n, $d, $ext) = fileparse($dist, '\..*'); |
|
486 # check weather distination directory exist or not. If directory doesn't exist then create it. |
|
487 -d $d || mkpath($d, 0, 0x755); |
|
488 } |
|
489 |
|
490 # copy source to distination |
|
491 copy($source,$dist); |
|
492 } |
|
493 |
|
494 # read files from given path to filelist |
|
495 sub getFiles { |
|
496 my $file_name = $File::Find::name; |
|
497 $file_name =~ s/\//\\/g; #Change / marks to \ |
|
498 chomp $file_name; |
|
499 next if ( -d $file_name ); # Skip directories |
|
500 next if ((!($file_name =~ /o0000/i)) && (!($file_name =~ /\\sources\\/i))); # Skip other then resource and source files |
|
501 push @find_files, $file_name; |
|
502 } |
|
503 |
|
504 sub write_what_file { |
|
505 my $out = shift; |
|
506 open( WHAT, ">>$what_output_file") or die $!; |
|
507 print WHAT "$out\n"; |
|
508 close WHAT; |
|
509 |
|
510 } |