update dev300-m58
[ooovba.git] / solenv / bin / installoffice.pl
blob8e4f1f0ea50d38719943d90f258831a4564be57d
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
5 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 #
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: installoffice.pl,v $
14 # $Revision: 1.2.24.1 $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
32 #***********************************************************************/
34 use strict;
35 use File::Find;
36 use File::Path;
37 my $script = $0;
39 ( our $script_name = $script ) =~ s/^.*\b(\w+)\.pl$/$1/;
40 ( our $script_path = $script ) =~ s/$script_name.*//;
42 # Prototypes
43 sub installOffice();
45 our $debug = 0; # run without executing commands
47 our $is_command_infos = 1; # print command details before exec
48 our $show_NoMessage = 0;
49 our $show_Message = 1;
51 # special handling for cwschackapi
52 our $cwsCheckApi = 0;
54 # remove existant office installation
55 our $cleanup = 0;
57 # should the office be startable without user interaction
58 our $autorun = 0;
60 # should impress open documents without autopilot
61 our $autoimpress = 0;
63 # force openOffice.org installation if StarOffice is available
64 our $is_ooo = 0;
66 parseArgs();
68 our $is_admin_installation = 1;
70 our $gui = $ENV{GUI};
71 our $temp_path = $ENV{TEMP};
72 if (!defined($temp_path)) {
73 $temp_path = $ENV{TMP};
76 our $vcsid = $ENV{VCSID};
77 our $sversion_saved = 0;
78 our $FileURLPrefix = "file:///";
79 our $userinstalldir = "UserInstallation";
80 our $cygwin = "cygwin";
81 our $prefered_lang = "en-US";
82 our $global_instset_mask = "";
83 #$smoketest_install = $ENV{SMOKETESTINSTALLSET};
85 if (!defined($gui)) {
86 print "The workstamp is missing. Please use setsolar\n";
87 exit(1);
90 our $OfficeDestinationPath;
91 our $is_do_deinstall;
92 our $CygwinLineends;
93 our $WinLineends;
94 our $PS ;
95 our $NewPathSeparator ;
96 our $shell ;
97 our $shellSetEnvVar;
98 our $shellCommandSep;
99 our $cdCommand;
100 our $PERL ;
101 our $REMOVE_DIR ;
102 our $REMOVE_FILE ;
103 our $LIST_DIR ;
104 our $COPY_FILE ;
105 our $COPY_DIR ;
106 our $MK_DIR ;
107 our $RENAME_FILE ;
108 our $nul ;
109 our $RESPFILE;
110 our $SVERSION_INI ;
111 our $SOFFICEBIN ;
112 our $UNOPKGBIN;
113 our $bootstrapini ;
114 our $bootstrapiniTemp ;
115 our $packpackage ;
116 our $user;
118 if ($gui eq "WNT") {
119 $gui = $cygwin;
122 if ($gui eq "WNT") {
123 $user = $ENV{USERNAME};
124 $PS = '\\';
125 $NewPathSeparator = ';';
126 $shell = "$ENV{COMSPEC} -c ";
127 $shellSetEnvVar = "set ";
128 $shellCommandSep = "& ";
129 $cdCommand="cd /d ";
130 $PERL = "$shell $ENV{PERL}";
131 $REMOVE_DIR = "$shell del /qsxyz";
132 $REMOVE_FILE = "$shell del /q";
133 $LIST_DIR = "$shell ls";
134 $COPY_FILE = "$shell copy";
135 $COPY_DIR = "$shell copy /s";
136 $MK_DIR = "md";
137 $RENAME_FILE = "ren";
138 $nul = '> NUL';
139 $RESPFILE="response_fat_wnt";
140 $SVERSION_INI = $ENV{USERPROFILE} . $PS . "Anwendungsdaten" . $PS . "sversion.ini";
141 $SOFFICEBIN = "soffice.exe";
142 $bootstrapini = "bootstrap.ini";
143 $UNOPKGBIN="unopkg.exe";
144 $bootstrapiniTemp = $bootstrapini . "_";
145 $packpackage = "msi";
146 if (!defined($temp_path)) {
147 print "temp value is missing. Please set temp-variable\n";
148 exit(1);
151 elsif ($gui eq "UNX") {
152 $user = $ENV{USER};
153 $is_do_deinstall = 0;
154 $PS = '/';
155 $shell = "/bin/sh -c ";
156 $shellSetEnvVar = "export ";
157 $shellCommandSep = ";";
158 $cdCommand="cd ";
159 $NewPathSeparator = ':';
160 $shell = "";
161 $PERL = "$ENV{PERL}";
162 $REMOVE_DIR = "rm -rf";
163 $REMOVE_FILE = "rm -f";
164 $LIST_DIR = "ls";
165 $COPY_FILE = "cp -f";
166 $COPY_DIR = "cp -rf";
167 $MK_DIR = "mkdir";
168 $RENAME_FILE = "mv";
169 $nul = '> /dev/null';
170 $RESPFILE="response_fat_unx";
171 $SVERSION_INI = $ENV{HOME} . $PS . ".sversionrc";
172 $SOFFICEBIN = "soffice";
173 $bootstrapini = "bootstraprc";
174 $UNOPKGBIN="unopkg";
175 $bootstrapiniTemp = $bootstrapini . "_";
176 $packpackage = $ENV{PKGFORMAT};
177 if (!defined($temp_path)) {
178 $temp_path="/tmp";
179 if (! -e $temp_path){
180 print "temp value is missing. Please set temp-variable\n";
181 exit(1);
185 elsif ($gui eq $cygwin) {
187 $PS = '/';
188 $NewPathSeparator = ':';
189 $shell = "/bin/sh -c ";
190 $shellSetEnvVar = "export ";
191 $shellCommandSep = ";";
192 $cdCommand = "cd ";
193 $PERL = "$ENV{PERL}";
194 $REMOVE_DIR = "rm -rf";
195 $REMOVE_FILE = "rm -f";
196 $LIST_DIR = "ls";
197 $COPY_FILE = "cp -f";
198 $COPY_DIR = "cp -rf";
199 $MK_DIR = "mkdir";
200 $RENAME_FILE = "mv";
201 $nul = '> /dev/null';
202 $RESPFILE="response_fat_wnt";
203 $SVERSION_INI = $ENV{USERPROFILE} . $PS . "Anwendungsdaten" . $PS . "sversion.ini";
204 $SOFFICEBIN = "soffice";
205 $bootstrapini = "bootstrap.ini";
206 $bootstrapiniTemp = $bootstrapini . "_";
207 $CygwinLineends = $/;
208 $WinLineends = "\r\n";
209 &SetWinLineends();
210 $packpackage = "msi";
211 if (!defined($temp_path)) {
212 $temp_path="/tmp";
213 if (! -e $temp_path){
214 print "temp value is missing. Please set temp-variable\n";
215 exit(1);
219 else {
220 print_error ("not supported system\n",1);
223 my %PRODUCT1 = (Name => "StarOffice", instset => "instset_native");
224 my %PRODUCT2 = (Name => "OpenOffice", instset => "instsetoo_native");
225 our @PRODUCT = (\%PRODUCT1, \%PRODUCT2);
227 our $SHIP = defined $ENV{SHIPDRIVE} ? $ENV{SHIPDRIVE} . $PS : "shipdrive_not_set";
229 if (defined($ENV{CWS_WORK_STAMP})){
230 print " found CWS\n";
232 elsif (isLocalEnv()){
233 print " local environment\n";
235 elsif (defined $ENV{SHIPDRIVE}) {
236 print " master version\n";
238 elsif (defined $ENV{SOLARSRC}) {
239 print " OpenOffice master version\n";
241 else {
242 print "Could not determine environment. Exit\n";
243 exit 1
247 our @error_messages = ( '',
248 'lock flag for pkgadd still exist. Installation not possible!',
249 'Error during installation!',
250 'Error: patching configuration failed!',
251 'Error: starting office failed or office crashed!',
252 'Error during testing',
253 'can not copy extension',
254 'Error in setup log',
255 'installationsset is not complete',
256 'can not copy all basic scripts',
257 'can not patch bottstrapini',
258 'msiexec failed. Maybe you have got an installed version',
259 'deinstallation is incomplete'
263 my $success = 0;
264 $success = installOffice();
266 if ($success != 0){
267 exit(1);
269 exit(0);
271 sub installOffice(){
273 # <DISABLED>
274 # my ($officeVersion, $instsetPath)= getInstset();
275 # print "OFFICEVERSION:$officeVersion INSTSETPATH:$instsetPath\n" if $debug;
276 # my $sourcePath=$instsetPath.$PS.$officeVersion;
277 # </DISABLED>
279 # currently this installer does not install an office, it do pack a runnable office.
280 # Therefore we do not need to search for an instSet
281 my $sourcePath="dummy";
282 my $officeVersion="dummy";
284 my $destinationPath = getDestinationPath($officeVersion);
285 print "destinationPath: $destinationPath\n" if $debug;
287 removeOffice($destinationPath);
288 mkdirs($destinationPath);
290 my $installCommand = getInstallCommand($sourcePath, $destinationPath, $officeVersion);
291 print "installCommand: $installCommand\n" if $debug;
293 my $success=0;
294 $success = system($installCommand);
295 print "installoofice.pl::installoffice::success $success\n" if ($debug);
297 if ($autorun) {
298 makeAutoRun($destinationPath);
301 if ($autoimpress) {
302 makeAutoImpress($destinationPath);
305 return $success;
308 sub makeAutoImpress(){
309 my $destinationPath = shift;
311 if (patchXCU ($destinationPath, $script_path.$script_name."_impress.oxt") != 0) {
312 print_error("could not register ".$script_path.$script_name."_impress.oxt", "1");
314 return 0;
318 sub makeAutoRun(){
320 my $destinationPath = shift;
322 patchBootstraprc($destinationPath);
324 if (patchXCU ($destinationPath, $script_path.$script_name.".oxt") != 0) {
325 print_error("could not register ".$script_path.$script_name.".oxt", "1");
327 return 0;
331 sub patchBootstraprc(){
332 my $destinationPath = shift;
333 my $bootstraprc="";
335 find sub { $bootstraprc=$File::Find::name if -e _ && /$bootstrapini$/ }, $destinationPath;
337 print_error("could not find $bootstrapini", "1") if ( ! -e $bootstraprc );
339 open(BSRC, "<$bootstraprc") or errorFromOpen(" for reading " .$bootstraprc);
340 my @content = <BSRC>;
341 close(BSRC);
342 my @newContent;
343 foreach(@content) {
344 if ( /UserInstallation=./ ) {
345 push(@newContent, "UserInstallation=\$ORIGIN/../UserInstallation\n");
347 else {
348 push(@newContent,$_);
352 chmod(0755,$bootstraprc);
354 open OUTFILE, ">$bootstraprc" or return errorFromOpen (" for writing " . $bootstraprc);
355 print OUTFILE @newContent;
356 close OUTFILE;
360 sub patchXCU(){
361 my $destinationPath = shift;
362 my $oxt = shift;
363 my $unopkg="";
365 find sub { $unopkg=$File::Find::name if -e _ && /$UNOPKGBIN$/ }, $destinationPath;
367 print_error("could not find $UNOPKGBIN", "1") if ( !-e $unopkg );
368 print "unopkg: '$unopkg'\n" if $debug;
370 if ($gui eq "WNT") {
371 $unopkg = "\"$unopkg\"";
374 my $unopkgCommand = "$unopkg add $oxt";
375 print "register oxt file ...\n" if $debug;
376 print "call $unopkgCommand\n" if $debug;
377 my $success=0;
378 $success = system($unopkgCommand);
380 return $success;
383 sub writeFile(){
384 my $fileName = shift;
385 my @content = @_;
387 open OUTFILE, ">$fileName" or return errorFromOpen (" for writing " . $fileName);
389 my $lf;
390 if ($packpackage eq "msi"){
391 $lf = "\r\n";
392 } else {
393 $lf = "\n";
396 my $line;
397 foreach $line(@content) {
398 print "LINE: $line\n" if $debug;
399 print OUTFILE $line.$lf;
401 close(OUTFILE);
402 return 0;
405 sub mkdirs(){
406 my $directory = shift;
407 my $splitter=$PS;
408 if ( $PS eq "\\" ){
409 $splitter="\\\\";
411 my @aFolder=split($splitter,$directory);
413 my $dir;
414 my $folder;
415 foreach $folder(@aFolder){
416 if ( (! defined($dir)) && ($PS eq "\\")){
417 $dir=$folder;
418 } else {
419 $dir=$dir.$PS.$folder;
421 if (! -e $dir ){
422 print "try to create $dir\n" if $debug;
423 mkdir($dir);
428 sub removeOffice(){
430 my $destPath=shift;
432 if ($cleanup){
433 print "remove old office installation...\n";
435 print "remove $destPath...\n" if $debug;
436 rmtree($destPath);
441 sub getInstallCommand() {
442 my $command;
443 $command = getDmakeInstalledCommand(@_);
444 # if ($packpackage eq "msi"){
445 # $command = getWindowsInallCommand(@_);
446 # } else {
447 # $command = getUnixInstallCommand(@_);
449 return $command;
452 sub getDmakeInstalledCommand(){
453 my ($sourcePath, $destPath, $officeVersion) = @_;
454 my $RootDir=$ENV{SRC_ROOT};
456 my $ProductName;
457 my $instset;
459 # check if instset_native could be found
460 foreach my $pointer (@PRODUCT) {
461 $instset = $pointer->{'instset'};
462 $ProductName = $pointer->{'Name'};
463 my $instsetDir = "$RootDir$PS$instset";
464 print "instsetDir: $instsetDir \n" if $debug;
466 last if ($is_ooo && $ProductName eq "OpenOffice");
467 last if ( ! $is_ooo && -e "$instsetDir");
469 print "Product: $ProductName\n" if $debug;;
471 my $dmakeTarget=lc($ProductName)."_en-US";
473 my $utilFolder = getInstsetUtilFolder($instset, $destPath, $RootDir);
474 my $dmakeCommand = " $cdCommand \"$utilFolder\" $shellCommandSep dmake $dmakeTarget PKGFORMAT=installed -vt";
475 my $envset;
476 if ($gui eq "WNT") {
477 $envset="set LOCALINSTALLDIR=$destPath & set LOCALUNPACKDIR=$destPath &";
478 }else {
479 $envset="LOCALINSTALLDIR=$destPath ; LOCALUNPACKDIR=$destPath ; export LOCALINSTALLDIR ; export LOCALUNPACKDIR ; ";
481 #my $command=$envset.$dmakeCommand;
482 my $command=$dmakeCommand;
483 return $command;
486 sub getInstsetUtilFolder(){
487 my $instset = shift;
488 my $destPath = shift;
489 my $RootDir = shift;
491 my $instsetFolder = $RootDir.$PS.$instset;
492 my $utilFolder="";
494 if( open(DATEI, ">$instsetFolder".$PS."touch"))
496 close(DATEI);
497 unlink($instsetFolder.$PS."touch");
498 print "$instsetFolder is writable \n" if $debug;
499 $utilFolder = $RootDir.$PS.$instset.$PS."util";
501 else
503 print "$instsetFolder is NOT writable \n" if $debug;
504 print "copy $instset to $destPath$PS..\n" if $debug;
505 my $prjPath=$destPath.$PS."..";
507 my $command = "$ENV{COPYPRJ} -x $instset $prjPath";
508 print $command if $debug;
509 system($command);
510 $utilFolder=$prjPath.$PS.$ENV{WORK_STAMP}.$PS.$instset.$PS."util";
512 print "utilFolder: $utilFolder\n" if $debug;
513 return $utilFolder;
516 # sub getInstsetFomInstsetNative(){
517 # my (@DirArray, $TestDir1, $TestDir2);
518 # my $instset;
519 # my $ProductName;
520 # my $instDir="";
521 # my $lang;
522 # my $RootDir=$ENV{SRC_ROOT};
523 # my $StandDir = $ENV{SOLARSRC} . $PS;
524 # #$RootDir=~s/\w+$//;
526 # foreach my $pointer (@PRODUCT) {
527 # $instset = $pointer->{'instset'};
528 # $ProductName = $pointer->{'Name'};
529 # @DirArray=();
530 # $TestDir1 = "$RootDir$PS$instset$PS$ENV{INPATH}$PS$ProductName$PS$packpackage$PS" . "install$PS";
531 # $TestDir2 = "$StandDir$instset$PS$ENV{INPATH}$PS$ProductName$PS$packpackage$PS" . "install$PS";
532 # print "TestDir1: $TestDir1 \n";
533 # print "TestDir2: $TestDir2 \n";
534 # if (-e "$TestDir1") {
535 # $instDir= $TestDir1;
537 # elsif (-e "$TestDir2") {
538 # $instDir="$TestDir2";
539 # }
540 # if ($instDir eq "") {
541 # next;
544 # getSubDirs ("$instDir", \@DirArray);
545 # $lang = findSubDir (\@DirArray);
546 # print "Lang-Sel: $lang\n" if $is_command_infos;
548 # if (($instDir ne "") and (-e $instDir)) {
549 # return ($lang, $instDir, $ProductName, $instset);
552 # print_error ("no installationset found\n",2);
556 sub getWindowsInallCommand(){
557 my ($sourcePath, $destPath) = @_;
558 my $mask = "\\.msi\$";
559 #my $DirArray;
560 my @DirArray = ();
561 getSubFiles ("$sourcePath", \@DirArray, $mask);
562 if ($#DirArray == -1) {
563 print_error ("Installationset in $sourcePath is incomplete", 2);
565 if ($#DirArray >= 1) {
566 print_error ("Installationset in $sourcePath hat too many msi-files", 2);
567 print "found the following msi-files: @DirArray\n" if $debug;
569 my $command = "msiexec.exe /a $sourcePath$PS$DirArray[0] -qn ALLUSERS=2 INSTALLLOCATION=$destPath";
571 return $command;
574 sub getUnixInstallCommand() {
575 my ($sourcePath, $destPath, $officeVersion) = @_;
577 my $userland="unknown";
579 if (defined($ENV{CWS_WORK_STAMP})){
580 print " found CWS\n";
581 $userland=$ENV{SOLARVERSION}.$PS.$ENV{INPATH}.$PS."bin".$ENV{UPDMINOREXT}.$PS."userscripts".$PS."install";
583 elsif (isLocalEnv()){
584 print " local environment\n";
586 elsif (defined $ENV{SHIPDRIVE}) {
587 print " master version\n";
588 $userland=$ENV{SHIPDRIVE}.$PS.$ENV{INPATH}.$PS."UserScripts".$PS.$ENV{PKGFORMAT}.$PS.$officeVersion.$PS."install";
590 elsif (defined $ENV{SOLARSRC}) {
591 print " OpenOffice master version\n";
592 print " command to install Office not implementet yet\n";
593 exit(1);
595 else {
596 print "Could not determine environment. Exit\n";
597 exit(1);
599 return "$userland $sourcePath $destPath";
604 sub getDestinationPath {
605 # if (defined $ENV{SOLARROOT}){
606 # # seems to be a Sun environment
607 # if (! -e $OfficeDestinationPath){
611 my $officeVersion = shift;
612 my $officename;
614 if (defined($ENV{LOCALINSTALLDIR})){
615 $OfficeDestinationPath=$ENV{LOCALINSTALLDIR};
616 if(index($OfficeDestinationPath," ") >= 0) {
617 my $msg="You environemt variable '\$LOCALINSTALLDIR=$OfficeDestinationPath' contains white spaces.";
618 $msg = $msg." This is not allowed!";
619 print_error($msg, "1");
622 if (!defined($OfficeDestinationPath)){
623 $officename = $officeVersion;
624 if (defined($ENV{CWS_WORK_STAMP})){
625 $officename=$ENV{CWS_WORK_STAMP};
627 $OfficeDestinationPath=$temp_path.$PS.$user.$PS."office".$PS.$officename;
630 return $OfficeDestinationPath;
633 # sub getInstset {
635 # my ($INSTSET, $NEWINSTSET, $ProductName);
637 # if (defined ($ENV{EPM}) && ($ENV{EPM} eq 'NO') && ($gui eq "UNX")) { # we do the install ourselves ...
638 # return ();
641 # print "get Instset\n" if $debug;
642 # $NEWINSTSET = "";
644 # if (!isLocalEnv() and !defined($ENV{CWS_WORK_STAMP}) and (-e $SHIP) and ($gui ne $cygwin)) {
645 # ($NEWINSTSET, $INSTSET) = getSetFromServer();
647 # else {
648 # ($NEWINSTSET, $INSTSET, $ProductName) = getInstsetFomInstsetNative();
650 # return ($NEWINSTSET, $INSTSET);
653 # sub getSetFromServer {
654 # my ($DirName, $SetupFullPath);
655 # my $workspace = $ENV{WORK_STAMP};
656 # my $platform = $ENV{INPATH};
657 # my $latestset;
658 # my (@DirArray, $mask, $buildid, $milestone);
660 # foreach my $pointer (@PRODUCT) {
661 # my $ProductName = $pointer->{'Name'};
663 # print "##PRODUCT: $ProductName\n";
664 # my $SetupFullPath = "$SHIP$ENV{INPATH}$PS$ProductName$PS$packpackage$PS";
665 # if ( ! ( $workspace && $platform ) ) {
666 # print_error ( "Error: environment not set correctly.", 1);
668 # # get latest broadcastet milestone and pack number
669 # ($milestone, $buildid) = get_milestoneAndBuildID( $workspace, $platform );
671 # if (defined $ENV{CWS_WORK_STAMP}) {
672 # # /unxlngi6.pro/StarOffice/rpm/ SRC680_m245_native_packed-2_en-US.9267/
673 # $mask = "^$workspace" . "_" . $milestone . "_native_packed-(\\d+)_en-US\\.$buildid";
674 # } else {
675 # # cws03/os110/OOH680/src.m4/instset_native/unxlngi6.pro/StarOffice/rpm install/en-US/RPMS
676 # $mask = "^$workspace" . "_" . $milestone . "_native_packed-(\\d+)_en-US\\.$buildid";
678 # print "MASK: $mask\n";
679 # $global_instset_mask = $mask;
680 # getSubFiles ($SetupFullPath, \@DirArray, $mask);
681 # @DirArray = sort InstsetSort @DirArray;
683 # if ($#DirArray > -1) {
684 # $latestset = $DirArray [$#DirArray];
685 # $DirName = $latestset;
687 # else {
688 # print_error ("Cannot find install set $SetupFullPath for $workspace $milestone", 2);
691 # print "Latest install sets: $latestset\n" if $debug;
693 # print "$DirName\t $SetupFullPath\n" if $debug;
694 # # compare with file system
695 # # at the moment just the existence is checked. For security reasons it might be
696 # # better to additionally check whether there are newer sets (this must not happen,
697 # # but who knows ...)
698 # if ( -d $SetupFullPath ) {
699 # # if found => return and don't continue searching
700 # # this is usefull to set a priority to find installsets in @PRODUCT
701 # # first comes, first wins
702 # return ($DirName, $SetupFullPath);
706 # # compare with file system
707 # # at the moment just the existence is checked. For security reasons it might be
708 # # better to additionally check whether there are newer sets (this must not happen,
709 # # but who knows ...)
710 # if ( -d $SetupFullPath ) {
711 # return ($DirName, $SetupFullPath);
712 # } else {
713 # print_error ("Cannot find install set $SetupFullPath for $workspace $milestone", 2);
717 # sub get_milestoneAndBuildID {
718 # my ( $ws, $pf ) = @_;
719 # my ($milestone, $buildid, $upd, $path, $updext, $line);
721 # if ( $ws =~ /^\D+(\d+)$/) {
722 # $upd = $1;
725 # if (defined ($ENV{UPDMINOREXT})) {
726 # $updext = $ENV{UPDMINOREXT};
728 # else {
729 # $updext = "";
732 # $path = "$ENV{SOLARVER}$PS$pf$PS" . "inc$updext$PS$upd" . "minor.mk";
733 # print "$path\n" if $debug;
734 # local *MINORMK;
736 # if ( !open(MINORMK,$path) ) {
737 # print "FATAL: can't open $path\n";
738 # return (0,0);
739 # }
741 # if (!eof(MINORMK)) {
742 # while ($line = <MINORMK>) {
743 # chomp($line);
744 # if ( $line =~ /LAST_MINOR=(\w+)/ ) {
745 # $milestone = $1;
747 # elsif ( $line =~ /BUILD=(\d+)/ ) {
748 # $buildid = $1;
752 # close(MINORMK);
754 # if (!defined($milestone)) {
755 # print_error ("Milestone ist not defined!", 2);
757 # if (!defined($buildid)) {
758 # print_error ("Build-ID ist not defined!", 2);
761 # return ($milestone, $buildid);
764 sub print_error
766 my $message = shift;
767 my $error_code = shift;
769 print STDERR "ERROR: $message\n";
770 doExit($error_code);
773 sub getSubFiles {
774 my ($startDir, $DirArray_ref, $mask) = @_;
775 my ($dir);
776 local *DIR;
777 opendir(DIR,"$startDir");
778 while($dir = readdir(DIR)) {
779 if (($dir =~ /\.$/) or ($dir !~ /$mask/)) {
780 next;
782 push (@{$DirArray_ref}, "$dir");
784 closedir(DIR);
788 sub InstsetSort {
789 my ($a1, $b1);
790 if ($a =~ /$global_instset_mask/) {
791 $a1 = $1;
793 if ($b =~ /$global_instset_mask/) {
794 $b1 = $1;
796 $a1 <=> $b1;
799 sub isLocalEnv {
800 my $returnvalue = 0;
801 if (defined ($ENV{SOL_TMP}) && defined ($ENV{SOLARVERSION})) {
802 my $mask = $ENV{SOL_TMP};
803 $mask =~ s/\\/\\\\/;
804 print "Mask: $mask\n" if $debug;
805 if ($ENV{SOLARVERSION}=~ /$mask/) {
806 $returnvalue = 1;
809 return $returnvalue;
812 sub getSubDirs {
813 my ($startDir, $DirArray_ref) = @_;
814 my ($dir);
815 opendir(DIR,"$startDir");
816 while($dir = readdir(DIR)) {
817 if (($dir !~ /\.$/) and ( -d "$startDir$dir") ) {
818 push (@{$DirArray_ref}, "$dir");
821 closedir(DIR);
825 sub findSubDir {
826 my ($DirArray_ref) = @_;
827 my (@sortedArray, $dir, $instdir);
828 @sortedArray = sort langsort @{$DirArray_ref};
829 print "Langs: @sortedArray\n" if $is_command_infos;
830 foreach $dir (@sortedArray) {
831 if ($dir =~ /log$/) {
832 next;
834 $instdir = "$dir";
835 return $instdir;
837 return "";
840 sub langsort {
841 if ($a eq $prefered_lang) {
842 return -1;
844 elsif ($b eq $prefered_lang) {
845 return 1;
847 else {
848 $a cmp $b;
852 sub doExit
854 my $error_code = shift;
855 # if ($sversion_saved) {
856 # restore_sversion ($SVERSION_INI);
858 # if ($is_remove_on_error) {
859 # if ($is_do_deinstall) {
860 # deinstallInstallation ($installpath);
862 # removeInstallation($installpath);
864 # else {
865 # print_notRemoved ($installpath);
867 if ( $error_code ) {
868 print STDERR "\nFAILURE: $script_name aborted.\n";
870 exit($error_code);
875 sub parseArgs
877 for (my $i=0; $i<=$#ARGV; $i++) {
878 if ( $ARGV[$i] =~ /^-cwscheckapi$/ ) {
879 my $value = $ARGV[++$i];
880 if ($value =~ /^true$/ || ($value =~ /^1$/) ) {
881 $cwsCheckApi = 1;
882 $cleanup = 1;
883 $autorun = 1;
888 if ( $ARGV[$i] =~ /^-dest$/ ) {
889 $OfficeDestinationPath = $ARGV[++$i];
892 if ( $ARGV[$i] =~ /^-cleanup$/ ) {
893 my $value = $ARGV[++$i];
894 if ($value =~ /^true$/ || ($value =~ /^1$/ )) { $cleanup = 1 };
897 if ( $ARGV[$i] =~ /^-autorun$/ ) {
898 my $value = $ARGV[++$i];
899 if ($value =~ /^true$/ || ($value =~ /^1$/ )) { $autorun = 1 };
902 if ( $ARGV[$i] =~ /^-autoimpress$/ ) {
903 my $value = $ARGV[++$i];
904 if ($value =~ /^true$/ || ($value =~ /^1$/ )) { $autoimpress = 1 };
907 if ( $ARGV[$i] =~ /^-debug$/ ) {
908 my $value = $ARGV[++$i];
909 if ($value =~ /^true$/ || ($value =~ /^1$/ )) { $debug = 1 };
912 if ( $ARGV[$i] =~ /^-ooo$/ ) {
913 my $value = $ARGV[++$i];
914 if ($value =~ /^true$/ || ($value =~ /^1$/ )) { $is_ooo = 1 };
920 sub getSubDirsFullPath {
921 my ($startDir, $DirArray_ref) = @_;
922 my ($dir);
923 opendir(DIR,"$startDir");
924 while($dir = readdir(DIR)) {
925 if (($dir !~ /\.$/) and ( -d "$startDir$dir") ) {
926 push (@{$DirArray_ref}, "$startDir$dir");
929 closedir(DIR);
932 sub errorFromOpen {
933 my ($file) = @_;
934 print_error( "can not open $file", "1");