2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer
::parameter
;
22 use installer
::exiter
;
24 use installer
::globals
;
25 use installer
::logger
;
26 use installer
::remover
;
27 use installer
::systemactions
;
28 use File
::Temp qw
/ :mktemp /;
30 ############################################
31 # Parameter Operations
32 ############################################
37 --------------------------------------------------------------------------------
38 The following parameter are needed:
39 -f: Path to the product list (required)
40 -s: Path to the setup script (optional, if defined in product list)
41 -i: Install path of the product (/opt/openofficeorg20) (optional)
42 -p: Product from product list to be created (required)
43 -l: Language of the product (comma and hash) (optional, defined in productlist)
44 -b: Build, e.g. srx645 (optional)
45 -m: Minor, e.g. m10 (optional)
46 -simple: Path to do a simple install to
47 -u: Path, in which zipfiles are unpacked (optional)
48 -msitemplate: Source of the msi file templates (Windows compiler only)
49 -msilanguage: Source of the msi file templates (Windows compiler only)
50 -buildid: Current BuildID (optional)
52 -format: Package format
53 -debian: Create Debian packages for Linux
54 -dontunzip: do not unzip all files with flag ARCHIVE
55 -dontcallepm : do not call epm to create install sets (opt., non-Windows only)
56 -ispatchedepm : Usage of a patched (non-standard) epm (opt., non-Windows only)
57 -copyproject : is set for projects that are only used for copying (optional)
58 -languagepack : do create a languagepack, no product pack (optional)
59 -helppack : do create a helppack, no product pack (optional)
60 -strip: Stripping files (Unix only)
61 -log : Logging all available information (optional)
65 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US
66 -u /export/unpack -buildid 8712
67 -msitemplate /export/msi_files
68 -msilanguage /export/msi_languages
70 Examples for Non-Windows:
72 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US -format rpm
73 -u /export/unpack -buildid 8712 -ispatchedepm
74 --------------------------------------------------------------------------------
79 #########################################
80 # Writing all parameter into logfile
81 #########################################
87 installer
::logger
::globallog
("Command line arguments:");
89 for ( my $i = 0; $i <= $#ARGV; $i++ )
91 $include = $ARGV[$i] . "\n";
92 push(@installer::globals
::globallogfileinfo
, $include);
95 # also saving global settings:
97 $include = "Separator: $installer::globals::separator\n";
98 push(@installer::globals
::globallogfileinfo
, $include);
102 #####################################
104 #####################################
108 while ( $#ARGV >= 0 )
110 my $param = shift(@ARGV);
112 if ($param eq "-f") { $installer::globals
::ziplistname
= shift(@ARGV); }
113 elsif ($param eq "-s") { $installer::globals
::setupscriptname
= shift(@ARGV); }
114 elsif ($param eq "-p") { $installer::globals
::product
= shift(@ARGV); }
115 elsif ($param eq "-l") { $installer::globals
::languagelist
= shift(@ARGV); }
116 elsif ($param eq "-b") { $installer::globals
::build
= shift(@ARGV); }
117 elsif ($param eq "-m") { $installer::globals
::minor
= shift(@ARGV); }
118 elsif ($param eq "-dontunzip") { $installer::globals
::dounzip
= 0; }
119 elsif ($param eq "-pro") { $installer::globals
::pro
= 1; }
120 elsif ($param eq "-format") { $installer::globals
::packageformat
= shift(@ARGV); }
121 elsif ($param eq "-quiet") { $installer::globals
::quiet
= 1; }
122 elsif ($param eq "-verbose") { $installer::globals
::quiet
= 0; }
123 elsif ($param eq "-u") { $installer::globals
::unpackpath
= shift(@ARGV); }
124 elsif ($param eq "-i") { $installer::globals
::rootpath
= shift(@ARGV); }
125 elsif ($param eq "-dontcallepm") { $installer::globals
::call_epm
= 0; }
126 elsif ($param eq "-msitemplate") { $installer::globals
::idttemplatepath
= shift(@ARGV); }
127 elsif ($param eq "-msilanguage") { $installer::globals
::idtlanguagepath
= shift(@ARGV); }
128 elsif ($param eq "-buildid") { $installer::globals
::buildid
= shift(@ARGV); }
129 elsif ($param eq "-copyproject") { $installer::globals
::is_copy_only_project
= 1; }
130 elsif ($param eq "-languagepack") { $installer::globals
::languagepack
= 1; }
131 elsif ($param eq "-helppack") { $installer::globals
::helppack
= 1;}
132 elsif ($param eq "-debian") { $installer::globals
::debian
= 1; }
133 elsif ($param eq "-strip") { $installer::globals
::strip
= 1; }
134 elsif ($param eq "-destdir") # new parameter for simple installer
136 $installer::globals
::rootpath
ne "" && die "must set destdir before -i or -simple";
138 my $path = shift(@ARGV);
140 $installer::globals
::destdir
= Cwd
::realpath
($path);
142 elsif ($param eq "-simple") # new parameter for simple installer
144 $installer::globals
::simple
= 1;
145 $installer::globals
::call_epm
= 0;
146 $installer::globals
::makedownload
= 0;
147 my $path = shift(@ARGV);
148 $path =~ s/^\Q$installer::globals::destdir\E//;
149 $installer::globals
::rootpath
= $path;
153 installer
::logger
::print_error
( "unknown parameter: $param" );
159 # Usage of simple installer (not for Windows):
160 # $PERL -w $SRCDIR/solenv/bin/make_installer.pl \
161 # -f openoffice.lst -l en-US -p OpenOffice \
162 # -buildid $BUILD -rpm \
163 # -destdir /tmp/nurk -simple $INSTALL_PATH
166 ############################################
167 # Controlling the fundamental parameter
168 # (required for every process)
169 ############################################
171 sub control_fundamental_parameter
173 if ($installer::globals
::product
eq "")
175 installer
::logger
::print_error
( "Product name not set!" );
181 ##########################################################
182 # The path parameters can be relative or absolute.
183 # This function creates absolute paths.
184 ##########################################################
186 sub make_path_absolute
190 if ( $installer::globals
::isunix
)
192 if (!($$pathref =~ /^\s*\//)) # this is a relative unix path
194 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
198 if ( $installer::globals
::iswin
)
200 if ( $^O
=~ /cygwin/i )
202 if ( $$pathref !~ /^\s*\// && $$pathref !~ /^\s
*\w\
:/ ) # not an absolute POSIX or DOS path
204 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
209 # Avoid the $(LANG) problem.
210 if ($p =~ /(\A.*)(\$\(.*\Z)/) {
215 chomp( $p = qx{cygpath
-w
"$p"} );
217 # Use windows paths, but with '/'s.
218 $$pathref =~ s/\\/\//g
;
222 if (!($$pathref =~ /^\s*\w\:/)) # this is a relative windows path (no dos drive)
224 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
226 $$pathref =~ s/\//\\/g
;
230 $$pathref =~ s/[\/\\]\s*$//; # removing ending slashes
233 ##################################################
234 # Setting some global parameters
235 # This has to be expanded with furher platforms
236 ##################################################
238 sub setglobalvariables
240 # Setting the installertype directory corresponding to the environment variable PKGFORMAT
241 # The global variable $installer::globals::packageformat can only contain one package format.
242 # If PKGFORMAT cotains more than one format (for example "rpm deb") this is splitted in the
243 # makefile calling the perl program.
244 $installer::globals
::installertypedir
= $installer::globals
::packageformat
;
246 if ( $installer::globals
::os
eq 'WNT' )
248 if ( $installer::globals
::cpuname
eq 'INTEL')
250 $installer::globals
::iswindowsbuild
= 1;
251 $installer::globals
::iswin64build
= 0;
255 $installer::globals
::iswindowsbuild
= 1;
256 $installer::globals
::iswin64build
= 1;
260 if ( $installer::globals
::os
eq 'SOLARIS')
262 $installer::globals
::issolarisbuild
= 1;
263 if ( $installer::globals
::packageformat
eq "pkg" )
265 $installer::globals
::issolarispkgbuild
= 1;
266 $installer::globals
::epmoutpath
= "packages";
268 if ( $installer::globals
::cpuname
eq 'INTEL')
270 $installer::globals
::issolarisx86build
= 1;
274 $installer::globals
::issolarissparcbuild
= 1;
278 if ( $installer::globals
::platformid
eq 'macosx_x86_64')
280 $installer::globals
::ismacbuild
= 1;
282 if ( $installer::globals
::packageformat
eq "dmg" )
284 $installer::globals
::ismacdmgbuild
= 1;
288 if ( $installer::globals
::os
eq 'OPENBSD')
290 $installer::globals
::epmoutpath
= "openbsd";
293 if ( $installer::globals
::os
eq 'FREEBSD')
295 $installer::globals
::isfreebsdbuild
= 1;
297 if ( $installer::globals
::packageformat
eq "bsd" )
299 $installer::globals
::epmoutpath
= "freebsd";
300 $installer::globals
::isfreebsdpkgbuild
= 1;
304 if ($installer::globals
::os
eq 'AIX')
306 if ( $installer::globals
::packageformat
eq "rpm" )
308 $installer::globals
::isrpmbuild
= 1;
309 $installer::globals
::epmoutpath
= "RPMS";
311 if ( $installer::globals
::rpm
eq "" ) { installer
::exiter
::exit_program
("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
314 if ($installer::globals
::os
eq 'LINUX')
316 $installer::globals
::islinuxbuild
= 1;
317 if ( $installer::globals
::packageformat
eq "rpm" )
319 $installer::globals
::isrpmbuild
= 1;
320 $installer::globals
::epmoutpath
= "RPMS";
322 if ( $installer::globals
::rpm
eq "" ) { installer
::exiter
::exit_program
("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
325 # Creating Debian packages ?
326 if (( $installer::globals
::packageformat
eq "deb" ) || ( $installer::globals
::debian
))
328 $installer::globals
::debian
= 1;
329 $installer::globals
::packageformat
= "deb";
330 my $message = "Creating Debian packages";
331 installer
::logger
::print_message
( $message );
332 push(@installer::globals
::globallogfileinfo
, $message);
333 $installer::globals
::isrpmbuild
= 0;
334 $installer::globals
::isdebbuild
= 1;
335 $installer::globals
::epmoutpath
= "DEBS";
339 # Defaulting to native package format for epm
341 # no languages defined as parameter
342 if ($installer::globals
::languagelist
eq "") { $installer::globals
::languages_defined_in_productlist
= 1; }
344 # setting and creating the unpackpath
346 if ($installer::globals
::unpackpath
eq "") # unpackpath not set
348 $installer::globals
::unpackpath
= cwd
();
351 if ($installer::globals
::workpath
eq "") # workpath not set
353 $installer::globals
::workpath
= cwd
();
356 if ( $installer::globals
::localunpackdir
ne "" ) { $installer::globals
::unpackpath
= $installer::globals
::localunpackdir
; }
358 if (!($installer::globals
::unpackpath
eq ""))
360 make_path_absolute
(\
$installer::globals
::unpackpath
);
363 $installer::globals
::unpackpath
=~ s/\Q$installer::globals::separator\E\s*$//;
365 if (! -d
$installer::globals
::unpackpath
) # create unpackpath
367 installer
::systemactions
::create_directory
($installer::globals
::unpackpath
);
370 # setting and creating the temppath
372 if ( $ENV{'TMPDIR'} )
374 $installer::globals
::temppath
= $ENV{'TMPDIR'};
375 $installer::globals
::temppath
=~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes and backslashes
376 $installer::globals
::temppath
.= $installer::globals
::separator
. 'ooopackagingXXXXXX';
377 $installer::globals
::temppath
= mkdtemp
($installer::globals
::temppath
);
379 my $dirsave = $installer::globals
::temppath
;
381 if ( $installer::globals
::platformid
eq 'maosx_x86_64')
383 chmod 0777, $installer::globals
::temppath
;
386 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. "i";
387 $installer::globals
::temppath
= installer
::systemactions
::create_pid_directory
($installer::globals
::temppath
);
388 push(@installer::globals
::removedirs
, $installer::globals
::temppath
);
390 if ( ! -d
$installer::globals
::temppath
) { installer
::exiter
::exit_program
("ERROR: Failed to create directory $installer::globals::temppath ! Possible reason: Wrong privileges in directory $dirsave .", "setglobalvariables"); }
392 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. $installer::globals
::platformid
;
393 installer
::systemactions
::create_directory
($installer::globals
::temppath
);
394 if ( $^O
=~ /cygwin/i )
396 $installer::globals
::cyg_temppath
= $installer::globals
::temppath
;
397 $installer::globals
::cyg_temppath
=~ s/\\/\\\\/g;
398 chomp( $installer::globals
::cyg_temppath
= qx{cygpath
-w
"$installer::globals::cyg_temppath"} );
400 $installer::globals
::temppathdefined
= 1;
404 $installer::globals
::temppathdefined
= 0;
407 # only one cab file, if Windows msp patches shall be prepared
408 if ( $installer::globals
::prepare_winpatch
) { $installer::globals
::number_of_cabfiles
= 1; }
412 ############################################
413 # Controlling the parameter that are
414 # required for special processes
415 ############################################
417 sub control_required_parameter
419 if (!($installer::globals
::is_copy_only_project
))
421 ##############################################################################################
422 # idt template path. Only required for Windows build
423 # for the creation of the msi database.
424 ##############################################################################################
426 if (($installer::globals
::idttemplatepath
eq "") && ($installer::globals
::iswindowsbuild
))
428 installer
::logger
::print_error
( "idt template path not set (-msitemplate)!" );
433 ##############################################################################################
434 # idt language path. Only required for Windows build
435 # for the creation of the msi database.
436 ##############################################################################################
438 if (($installer::globals
::idtlanguagepath
eq "") && ($installer::globals
::iswindowsbuild
))
440 installer
::logger
::print_error
( "idt language path not set (-msilanguage)!" );
445 # Analyzing the idt template path
447 if (!($installer::globals
::idttemplatepath
eq "")) # idttemplatepath set, relative or absolute?
449 make_path_absolute
(\
$installer::globals
::idttemplatepath
);
452 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idttemplatepath
);
454 # Analyzing the idt language path
456 if (!($installer::globals
::idtlanguagepath
eq "")) # idtlanguagepath set, relative or absolute?
458 make_path_absolute
(\
$installer::globals
::idtlanguagepath
);
461 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idtlanguagepath
);
463 # In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
464 # and the UpgradeCode for the product are defined.
465 # The name "codes.txt" can be overwritten in Product definition with CODEFILENAME (msiglobal.pm)
467 if (( $installer::globals
::iswindowsbuild
) && ( $installer::globals
::packageformat
ne "archive" ) && ( $installer::globals
::packageformat
ne "installed" ))
469 $installer::globals
::codefilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::codefilename
;
470 installer
::files
::check_file
($installer::globals
::codefilename
);
471 $installer::globals
::componentfilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::componentfilename
;
472 installer
::files
::check_file
($installer::globals
::componentfilename
);
477 #######################################
478 # Testing existence of files
479 # also for copy-only projects
480 #######################################
482 if ($installer::globals
::ziplistname
eq "")
484 installer
::logger
::print_error
( "ERROR: Zip list file has to be defined (Parameter -f) !" );
490 installer
::files
::check_file
($installer::globals
::ziplistname
);
493 if ($installer::globals
::setupscriptname
eq "") { $installer::globals
::setupscript_defined_in_productlist
= 1; }
494 else { installer
::files
::check_file
($installer::globals
::setupscriptname
); } # if the setupscript file is defined, it has to exist
498 ################################################
499 # Writing parameter to shell and into logfile
500 ################################################
508 push(@output, "\n########################################################\n");
509 push(@output, "Product list file: $installer::globals::ziplistname\n");
510 if (!($installer::globals
::setupscript_defined_in_productlist
))
512 push(@output, "Setup script: $installer::globals::setupscriptname\n");
516 push(@output, "Taking setup script from workdir\n");
518 push(@output, "Unpackpath: $installer::globals::unpackpath\n");
519 push(@output, "PLATFORMID: $installer::globals::platformid\n");
520 push(@output, "OS: $installer::globals::os\n");
521 push(@output, "CPUNAME: $installer::globals::cpuname\n");
522 push(@output, "COM: $installer::globals::com\n");
523 push(@output, "Product: $installer::globals::product\n");
524 push(@output, "BuildID: $installer::globals::buildid\n");
525 push(@output, "Build: $installer::globals::build\n");
526 if ( $installer::globals
::minor
) { push(@output, "Minor: $installer::globals::minor\n"); }
527 else { push(@output, "No minor set\n"); }
528 if ( $installer::globals
::pro
) { push(@output, "Product version\n"); }
529 else { push(@output, "Non-Product version\n"); }
530 if ( $installer::globals
::rootpath
eq "" ) { push(@output, "Using default installpath\n"); }
531 else { push(@output, "Installpath: $installer::globals::rootpath\n"); }
532 push(@output, "Package format: $installer::globals::packageformat\n");
533 if (!($installer::globals
::idttemplatepath
eq "")) { push(@output, "msi templatepath: $installer::globals::idttemplatepath\n"); }
534 if ((!($installer::globals
::idttemplatepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi template path will be ignored for non Windows builds!\n"); }
535 if (!($installer::globals
::idtlanguagepath
eq "")) { push(@output, "msi languagepath: $installer::globals::idtlanguagepath\n"); }
536 if ((!($installer::globals
::idtlanguagepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi language path will be ignored for non Windows builds!\n"); }
537 if ((!($installer::globals
::iswindowsbuild
)) && ( $installer::globals
::call_epm
)) { push(@output, "Calling epm\n"); }
538 if ((!($installer::globals
::iswindowsbuild
)) && (!($installer::globals
::call_epm
))) { push(@output, "Not calling epm\n"); }
539 if ( $installer::globals
::strip
) { push(@output, "Stripping files\n"); }
540 else { push(@output, "No file stripping\n"); }
541 if ( $installer::globals
::debian
) { push(@output, "Linux: Creating Debian packages\n"); }
542 if ( $installer::globals
::dounzip
) { push(@output, "Unzip ARCHIVE files\n"); }
543 else { push(@output, "Not unzipping ARCHIVE files\n"); }
544 if (!($installer::globals
::languages_defined_in_productlist
))
546 push(@output, "Languages:\n");
547 foreach $element (@installer::globals
::languageproducts
) { push(@output, "\t$element\n"); }
551 push(@output, "Languages defined in $installer::globals::ziplistname\n");
553 if ( $installer::globals
::is_copy_only_project
) { push(@output, "This is a copy only project!\n"); }
554 if ( $installer::globals
::languagepack
) { push(@output, "Creating language pack!\n"); }
555 if ( $installer::globals
::helppack
) { push(@output, "Creating help pack!\n"); }
556 push(@output, "########################################################\n");
558 # output into shell and into logfile
560 for ( my $i = 0; $i <= $#output; $i++ )
562 installer
::logger
::print_message
( $output[$i] );
563 push(@installer::globals
::globallogfileinfo
, $output[$i]);