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
;
25 use installer
::exiter
;
27 use installer
::globals
;
28 use installer
::logger
;
29 use installer
::remover
;
30 use installer
::systemactions
;
31 use File
::Temp qw
/ :mktemp /;
33 ############################################
34 # Parameter Operations
35 ############################################
40 --------------------------------------------------------------------------------
41 The following parameter are needed:
42 -f: Path to the product list (required)
43 -s: Path to the setup script (optional, if defined in product list)
44 -i: Install path of the product (/opt/openofficeorg20) (optional)
45 -p: Product from product list to be created (required)
46 -l: Language of the product (comma and hash) (optional, defined in productlist)
47 -simple: Path to do a simple install to
48 -u: Path, in which zipfiles are unpacked (optional)
49 -msitemplate: Source of the msi file templates (Windows compiler only)
50 -msilanguage: Source of the msi file templates (Windows compiler only)
51 -buildid: Current BuildID (optional)
53 -format: Package format
54 -debian: Create Debian packages for Linux
55 -dontunzip: do not unzip all files with flag ARCHIVE
56 -dontcallepm : do not call epm to create install sets (opt., non-Windows only)
57 -ispatchedepm : Usage of a patched (non-standard) epm (opt., non-Windows only)
58 -copyproject : is set for projects that are only used for copying (optional)
59 -languagepack : do create a languagepack, no product pack (optional)
60 -helppack : do create a helppack, no product pack (optional)
61 -strip: Stripping files (Unix only)
62 -packer: Path and parameters for tarball packaging tool (default: gzip (Unix only))
63 -log : Logging all available information (optional)
67 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US
68 -u /export/unpack -buildid 8712
69 -msitemplate /export/msi_files
70 -msilanguage /export/msi_languages
72 Examples for Non-Windows:
74 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US -format rpm
75 -u /export/unpack -buildid 8712 -ispatchedepm
76 --------------------------------------------------------------------------------
81 #########################################
82 # Writing all parameter into logfile
83 #########################################
89 installer
::logger
::globallog
("Command line arguments:");
91 for ( my $i = 0; $i <= $#ARGV; $i++ )
93 $include = $ARGV[$i] . "\n";
94 push(@installer::globals
::globallogfileinfo
, $include);
97 # also saving global settings:
99 $include = "Separator: $installer::globals::separator\n";
100 push(@installer::globals
::globallogfileinfo
, $include);
104 #####################################
106 #####################################
110 while ( $#ARGV >= 0 )
112 my $param = shift(@ARGV);
114 if ($param eq "-f") { $installer::globals
::ziplistname
= shift(@ARGV); }
115 elsif ($param eq "-s") { $installer::globals
::setupscriptname
= shift(@ARGV); }
116 elsif ($param eq "-p") { $installer::globals
::product
= shift(@ARGV); }
117 elsif ($param eq "-l") { $installer::globals
::languagelist
= 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 "-packer") { $installer::globals
::packertool
= shift(@ARGV); }
135 elsif ($param eq "-destdir") # new parameter for simple installer
137 $installer::globals
::rootpath
ne "" && die "must set destdir before -i or -simple";
139 my $path = shift(@ARGV);
141 $installer::globals
::destdir
= Cwd
::realpath
($path);
143 elsif ($param eq "-simple") # new parameter for simple installer
145 $installer::globals
::simple
= 1;
146 $installer::globals
::call_epm
= 0;
147 $installer::globals
::makedownload
= 0;
148 my $path = shift(@ARGV);
149 $path =~ s/^\Q$installer::globals::destdir\E//;
150 $installer::globals
::rootpath
= $path;
154 installer
::logger
::print_error
( "unknown parameter: $param" );
160 # Usage of simple installer (not for Windows):
161 # $PERL -w $SRCDIR/solenv/bin/make_installer.pl \
162 # -f openoffice.lst -l en-US -p OpenOffice \
163 # -buildid $BUILD -rpm \
164 # -destdir /tmp/nurk -simple $INSTALL_PATH
167 ############################################
168 # Controlling the fundamental parameter
169 # (required for every process)
170 ############################################
172 sub control_fundamental_parameter
174 if ($installer::globals
::product
eq "")
176 installer
::logger
::print_error
( "Product name not set!" );
182 ##########################################################
183 # The path parameters can be relative or absolute.
184 # This function creates absolute paths.
185 ##########################################################
187 sub make_path_absolute
190 return if ( $^O
=~ /MSWin/i ); # no need to do anything here
192 if ( $installer::globals
::isunix
)
194 if (!($$pathref =~ /^\s*\//)) # this is a relative unix path
196 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
200 if ( $installer::globals
::iswin
)
202 if ( $^O
=~ /cygwin/i )
204 if ( $$pathref !~ /^\s*\// && $$pathref !~ /^\s
*\w\
:/ ) # not an absolute POSIX or DOS path
206 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
211 # Avoid the $(LANG) problem.
212 if ($p =~ /(\A.*)(\$\(.*\Z)/) {
217 chomp( $p = qx{cygpath
-w
"$p"} );
219 # Use windows paths, but with '/'s.
220 $$pathref =~ s/\\/\//g
;
224 if (!($$pathref =~ /^\s*\w\:/)) # this is a relative windows path (no dos drive)
226 $$pathref = cwd
() . $installer::globals
::separator
. $$pathref;
228 $$pathref =~ s/\//\\/g
;
232 $$pathref =~ s/[\/\\]\s*$//; # removing ending slashes
235 # Setting some global parameters
236 # This has to be expanded with further platforms
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 contains more than one format (for example "rpm deb") this is split in the
243 # makefile calling the perl program.
244 $installer::globals
::installertypedir
= $installer::globals
::packageformat
;
246 if ( $installer::globals
::os
eq 'WNT' )
248 $installer::globals
::iswindowsbuild
= 1;
251 if ( $installer::globals
::os
eq 'SOLARIS')
253 $installer::globals
::issolarisbuild
= 1;
254 if ( $installer::globals
::packageformat
eq "pkg" )
256 $installer::globals
::issolarispkgbuild
= 1;
257 $installer::globals
::epmoutpath
= "packages";
259 if ( $installer::globals
::cpuname
eq 'INTEL')
261 $installer::globals
::issolarisx86build
= 1;
265 $installer::globals
::issolarissparcbuild
= 1;
269 if ( $installer::globals
::os
eq 'MACOSX' )
271 $installer::globals
::ismacbuild
= 1;
273 if ( $installer::globals
::packageformat
eq "dmg" )
275 $installer::globals
::ismacdmgbuild
= 1;
279 if ( $installer::globals
::os
eq 'OPENBSD')
281 $installer::globals
::epmoutpath
= "openbsd";
284 if ( $installer::globals
::os
eq 'FREEBSD')
286 $installer::globals
::isfreebsdbuild
= 1;
288 if ( $installer::globals
::packageformat
eq "bsd" )
290 $installer::globals
::epmoutpath
= "freebsd";
291 $installer::globals
::isfreebsdpkgbuild
= 1;
295 if ($installer::globals
::os
eq 'LINUX')
297 $installer::globals
::islinuxbuild
= 1;
298 if ( $installer::globals
::packageformat
eq "rpm" )
300 $installer::globals
::isrpmbuild
= 1;
301 $installer::globals
::epmoutpath
= "RPMS";
303 if ( $installer::globals
::rpm
eq "" ) { installer
::exiter
::exit_program
("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
306 # Creating Debian packages ?
307 if (( $installer::globals
::packageformat
eq "deb" ) || ( $installer::globals
::debian
))
309 $installer::globals
::debian
= 1;
310 $installer::globals
::packageformat
= "deb";
311 my $message = "Creating Debian packages";
312 installer
::logger
::print_message
( $message );
313 push(@installer::globals
::globallogfileinfo
, $message);
314 $installer::globals
::isrpmbuild
= 0;
315 $installer::globals
::isdebbuild
= 1;
316 $installer::globals
::epmoutpath
= "DEBS";
320 # Defaulting to native package format for epm
322 # no languages defined as parameter
323 if ($installer::globals
::languagelist
eq "") { $installer::globals
::languages_defined_in_productlist
= 1; }
325 # setting and creating the unpackpath
327 if ($installer::globals
::unpackpath
eq "") # unpackpath not set
329 $installer::globals
::unpackpath
= cwd
();
332 if ($installer::globals
::workpath
eq "") # workpath not set
334 $installer::globals
::workpath
= cwd
();
337 if ( $installer::globals
::localunpackdir
ne "" ) { $installer::globals
::unpackpath
= $installer::globals
::localunpackdir
; }
339 if (!($installer::globals
::unpackpath
eq ""))
341 make_path_absolute
(\
$installer::globals
::unpackpath
);
344 $installer::globals
::unpackpath
=~ s/\Q$installer::globals::separator\E\s*$//;
346 if (! -d
$installer::globals
::unpackpath
) # create unpackpath
348 installer
::systemactions
::create_directory
($installer::globals
::unpackpath
);
351 # setting and creating the temppath
353 if ( $ENV{'TMPDIR'} )
355 $installer::globals
::temppath
= $ENV{'TMPDIR'};
356 $installer::globals
::temppath
=~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes and backslashes
357 $installer::globals
::temppath
.= $installer::globals
::separator
. 'ooopackagingXXXXXX';
358 $installer::globals
::temppath
= mkdtemp
($installer::globals
::temppath
);
360 my $dirsave = $installer::globals
::temppath
;
362 if ( $installer::globals
::platformid
eq 'maosx_x86_64')
364 chmod 0777, $installer::globals
::temppath
;
367 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. "i";
368 $installer::globals
::temppath
= installer
::systemactions
::create_pid_directory
($installer::globals
::temppath
);
369 push(@installer::globals
::removedirs
, $installer::globals
::temppath
);
371 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"); }
373 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. $installer::globals
::platformid
;
374 installer
::systemactions
::create_directory
($installer::globals
::temppath
);
375 if ( $^O
=~ /cygwin/i )
377 $installer::globals
::cyg_temppath
= $installer::globals
::temppath
;
378 $installer::globals
::cyg_temppath
=~ s/\\/\\\\/g;
379 chomp( $installer::globals
::cyg_temppath
= qx{cygpath
-w
"$installer::globals::cyg_temppath"} );
381 $installer::globals
::temppathdefined
= 1;
385 $installer::globals
::temppathdefined
= 0;
388 # only one cab file, if Windows msp patches shall be prepared
389 if ( $installer::globals
::prepare_winpatch
) { $installer::globals
::number_of_cabfiles
= 1; }
393 ############################################
394 # Controlling the parameter that are
395 # required for special processes
396 ############################################
398 sub control_required_parameter
400 if (!($installer::globals
::is_copy_only_project
))
402 ##############################################################################################
403 # idt template path. Only required for Windows build
404 # for the creation of the msi database.
405 ##############################################################################################
407 if (($installer::globals
::idttemplatepath
eq "") && ($installer::globals
::iswindowsbuild
))
409 installer
::logger
::print_error
( "idt template path not set (-msitemplate)!" );
414 ##############################################################################################
415 # idt language path. Only required for Windows build
416 # for the creation of the msi database.
417 ##############################################################################################
419 if (($installer::globals
::idtlanguagepath
eq "") && ($installer::globals
::iswindowsbuild
))
421 installer
::logger
::print_error
( "idt language path not set (-msilanguage)!" );
426 # Analyzing the idt template path
428 if (!($installer::globals
::idttemplatepath
eq "")) # idttemplatepath set, relative or absolute?
430 make_path_absolute
(\
$installer::globals
::idttemplatepath
);
433 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idttemplatepath
);
435 # Analyzing the idt language path
437 if (!($installer::globals
::idtlanguagepath
eq "")) # idtlanguagepath set, relative or absolute?
439 make_path_absolute
(\
$installer::globals
::idtlanguagepath
);
442 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idtlanguagepath
);
444 # In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
445 # and the UpgradeCode for the product are defined.
446 # The name "codes.txt" can be overwritten in Product definition with CODEFILENAME (msiglobal.pm)
448 if (( $installer::globals
::iswindowsbuild
) && ( $installer::globals
::packageformat
ne "archive" ) && ( $installer::globals
::packageformat
ne "installed" ))
450 $installer::globals
::codefilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::codefilename
;
451 installer
::files
::check_file
($installer::globals
::codefilename
);
452 $installer::globals
::componentfilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::componentfilename
;
453 installer
::files
::check_file
($installer::globals
::componentfilename
);
458 #######################################
459 # Testing existence of files
460 # also for copy-only projects
461 #######################################
463 if ($installer::globals
::ziplistname
eq "")
465 installer
::logger
::print_error
( "ERROR: Zip list file has to be defined (Parameter -f) !" );
471 installer
::files
::check_file
($installer::globals
::ziplistname
);
474 if ($installer::globals
::setupscriptname
eq "") { $installer::globals
::setupscript_defined_in_productlist
= 1; }
475 else { installer
::files
::check_file
($installer::globals
::setupscriptname
); } # if the setupscript file is defined, it has to exist
479 ################################################
480 # Writing parameter to shell and into logfile
481 ################################################
489 push(@output, "\n########################################################\n");
490 push(@output, "Product list file: $installer::globals::ziplistname\n");
491 if (!($installer::globals
::setupscript_defined_in_productlist
))
493 push(@output, "Setup script: $installer::globals::setupscriptname\n");
497 push(@output, "Taking setup script from workdir\n");
499 push(@output, "Unpackpath: $installer::globals::unpackpath\n");
500 push(@output, "PLATFORMID: $installer::globals::platformid\n");
501 push(@output, "OS: $installer::globals::os\n");
502 push(@output, "CPUNAME: $installer::globals::cpuname\n");
503 push(@output, "COM: $installer::globals::com\n");
504 push(@output, "Product: $installer::globals::product\n");
505 push(@output, "BuildID: $installer::globals::buildid\n");
506 push(@output, "Build: $installer::globals::build\n");
507 if ( $installer::globals
::pro
) { push(@output, "Product version\n"); }
508 else { push(@output, "Non-Product version\n"); }
509 if ( $installer::globals
::rootpath
eq "" ) { push(@output, "Using default installpath\n"); }
510 else { push(@output, "Installpath: $installer::globals::rootpath\n"); }
511 push(@output, "Package format: $installer::globals::packageformat\n");
512 if (!($installer::globals
::idttemplatepath
eq "")) { push(@output, "msi templatepath: $installer::globals::idttemplatepath\n"); }
513 if ((!($installer::globals
::idttemplatepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi template path will be ignored for non Windows builds!\n"); }
514 if (!($installer::globals
::idtlanguagepath
eq "")) { push(@output, "msi languagepath: $installer::globals::idtlanguagepath\n"); }
515 if ((!($installer::globals
::idtlanguagepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi language path will be ignored for non Windows builds!\n"); }
516 if ((!($installer::globals
::iswindowsbuild
)) && ( $installer::globals
::call_epm
)) { push(@output, "Calling epm\n"); }
517 if ((!($installer::globals
::iswindowsbuild
)) && (!($installer::globals
::call_epm
))) { push(@output, "Not calling epm\n"); }
518 if ( $installer::globals
::strip
) { push(@output, "Stripping files\n"); }
519 else { push(@output, "No file stripping\n"); }
520 if ( $installer::globals
::debian
) { push(@output, "Linux: Creating Debian packages\n"); }
521 if ( $installer::globals
::dounzip
) { push(@output, "Unzip ARCHIVE files\n"); }
522 else { push(@output, "Not unzipping ARCHIVE files\n"); }
523 if (!($installer::globals
::languages_defined_in_productlist
))
525 push(@output, "Languages:\n");
526 foreach $element (@installer::globals
::languageproducts
) { push(@output, "\t$element\n"); }
530 push(@output, "Languages defined in $installer::globals::ziplistname\n");
532 if ( $installer::globals
::is_copy_only_project
) { push(@output, "This is a copy only project!\n"); }
533 if ( $installer::globals
::languagepack
) { push(@output, "Creating language pack!\n"); }
534 if ( $installer::globals
::helppack
) { push(@output, "Creating help pack!\n"); }
535 push(@output, "########################################################\n");
537 # output into shell and into logfile
539 for ( my $i = 0; $i <= $#output; $i++ )
541 installer
::logger
::print_message
( $output[$i] );
542 push(@installer::globals
::globallogfileinfo
, $output[$i]);