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 -c: Compiler, e.g. wntmsci8, unxlngi5, unxsols4, ... (optional)
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 -log : Logging all available information (optional)
66 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US
67 -u /export/unpack -buildid 8712
68 -msitemplate /export/msi_files
69 -msilanguage /export/msi_languages
71 Examples for Non-Windows:
73 perl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US -format rpm
74 -u /export/unpack -buildid 8712 -ispatchedepm
75 --------------------------------------------------------------------------------
80 #########################################
81 # Writing all parameter into logfile
82 #########################################
88 installer
::logger
::globallog
("Command line arguments:");
90 for ( my $i = 0; $i <= $#ARGV; $i++ )
92 $include = $ARGV[$i] . "\n";
93 push(@installer::globals
::globallogfileinfo
, $include);
96 # also saving global settings:
98 $include = "Separator: $installer::globals::separator\n";
99 push(@installer::globals
::globallogfileinfo
, $include);
103 #####################################
105 #####################################
109 while ( $#ARGV >= 0 )
111 my $param = shift(@ARGV);
113 if ($param eq "-f") { $installer::globals
::ziplistname
= shift(@ARGV); }
114 elsif ($param eq "-s") { $installer::globals
::setupscriptname
= shift(@ARGV); }
115 elsif ($param eq "-p") { $installer::globals
::product
= shift(@ARGV); }
116 elsif ($param eq "-l") { $installer::globals
::languagelist
= shift(@ARGV); }
117 elsif ($param eq "-b") { $installer::globals
::build
= shift(@ARGV); }
118 elsif ($param eq "-m") { $installer::globals
::minor
= shift(@ARGV); }
119 elsif ($param eq "-dontunzip") { $installer::globals
::dounzip
= 0; }
120 elsif ($param eq "-c") { $installer::globals
::compiler
= shift(@ARGV); }
121 elsif ($param eq "-pro") { $installer::globals
::pro
= 1; }
122 elsif ($param eq "-format") { $installer::globals
::packageformat
= shift(@ARGV); }
123 elsif ($param eq "-quiet") { $installer::globals
::quiet
= 1; }
124 elsif ($param eq "-verbose") { $installer::globals
::quiet
= 0; }
125 elsif ($param eq "-u") { $installer::globals
::unpackpath
= shift(@ARGV); }
126 elsif ($param eq "-i") { $installer::globals
::rootpath
= shift(@ARGV); }
127 elsif ($param eq "-dontcallepm") { $installer::globals
::call_epm
= 0; }
128 elsif ($param eq "-msitemplate") { $installer::globals
::idttemplatepath
= shift(@ARGV); }
129 elsif ($param eq "-msilanguage") { $installer::globals
::idtlanguagepath
= shift(@ARGV); }
130 elsif ($param eq "-buildid") { $installer::globals
::buildid
= shift(@ARGV); }
131 elsif ($param eq "-copyproject") { $installer::globals
::is_copy_only_project
= 1; }
132 elsif ($param eq "-languagepack") { $installer::globals
::languagepack
= 1; }
133 elsif ($param eq "-helppack") { $installer::globals
::helppack
= 1;}
134 elsif ($param eq "-debian") { $installer::globals
::debian
= 1; }
135 elsif ($param eq "-strip") { $installer::globals
::strip
= 1; }
136 elsif ($param eq "-destdir") # new parameter for simple installer
138 $installer::globals
::rootpath
ne "" && die "must set destdir before -i or -simple";
140 my $path = shift(@ARGV);
142 $installer::globals
::destdir
= Cwd
::realpath
($path);
144 elsif ($param eq "-simple") # new parameter for simple installer
146 $installer::globals
::simple
= 1;
147 $installer::globals
::call_epm
= 0;
148 $installer::globals
::makedownload
= 0;
149 my $path = shift(@ARGV);
150 $path =~ s/^\Q$installer::globals::destdir\E//;
151 $installer::globals
::rootpath
= $path;
155 installer
::logger
::print_error
( "unknown parameter: $param" );
161 # Usage of simple installer (not for Windows):
162 # $PERL -w $SRCDIR/solenv/bin/make_installer.pl \
163 # -f openoffice.lst -l en-US -p OpenOffice \
164 # -buildid $BUILD -rpm \
165 # -destdir /tmp/nurk -simple $INSTALL_PATH
168 ############################################
169 # Controlling the fundamental parameter
170 # (required for every process)
171 ############################################
173 sub control_fundamental_parameter
175 if ($installer::globals
::product
eq "")
177 installer
::logger
::print_error
( "Product name not set!" );
183 ##########################################################
184 # The path parameters can be relative or absolute.
185 # This function creates absolute paths.
186 ##########################################################
188 sub make_path_absolute
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 ##################################################
236 # Setting some global parameters
237 # This has to be expanded with furher platforms
238 ##################################################
240 sub setglobalvariables
242 # Setting the installertype directory corresponding to the environment variable PKGFORMAT
243 # The global variable $installer::globals::packageformat can only contain one package format.
244 # If PKGFORMAT cotains more than one format (for example "rpm deb") this is splitted in the
245 # makefile calling the perl program.
246 $installer::globals
::installertypedir
= $installer::globals
::packageformat
;
248 if ( $installer::globals
::compiler
=~ /wnt(msc|gcc)i/ )
250 $installer::globals
::iswindowsbuild
= 1;
251 $installer::globals
::iswin64build
= 0;
254 if ( $installer::globals
::compiler
=~ /wnt(msc|gcc)x/ )
256 $installer::globals
::iswindowsbuild
= 1;
257 $installer::globals
::iswin64build
= 1;
260 if ( $installer::globals
::compiler
=~ /unxso[lg][siux]/ )
262 $installer::globals
::issolarisbuild
= 1;
263 if ( $installer::globals
::packageformat
eq "pkg" )
265 $installer::globals
::issolarispkgbuild
= 1;
266 $installer::globals
::epmoutpath
= "packages";
270 if ( $installer::globals
::compiler
=~ /unxmacx/ )
272 $installer::globals
::ismacbuild
= 1;
274 if ( $installer::globals
::packageformat
eq "dmg" )
276 $installer::globals
::ismacdmgbuild
= 1;
280 if ( $installer::globals
::compiler
=~ /unxobsd/ )
282 $installer::globals
::epmoutpath
= "openbsd";
285 if ( $installer::globals
::compiler
=~ /unxfbsd/ )
287 $installer::globals
::isfreebsdbuild
= 1;
289 if ( $installer::globals
::packageformat
eq "bsd" )
291 $installer::globals
::epmoutpath
= "freebsd";
292 $installer::globals
::isfreebsdpkgbuild
= 1;
296 if ( $installer::globals
::compiler
=~ /unxso[lg]s/ ) { $installer::globals
::issolarissparcbuild
= 1; }
298 if ( $installer::globals
::compiler
=~ /unxso[lg]i/ ) { $installer::globals
::issolarisx86build
= 1; }
300 if ($ENV{OS
} eq 'AIX')
302 if ( $installer::globals
::packageformat
eq "rpm" )
304 $installer::globals
::isrpmbuild
= 1;
305 $installer::globals
::epmoutpath
= "RPMS";
307 if ( $installer::globals
::rpm
eq "" ) { installer
::exiter
::exit_program
("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
310 if ($ENV{OS
} eq 'LINUX')
312 $installer::globals
::islinuxbuild
= 1;
313 if ( $installer::globals
::packageformat
eq "rpm" )
315 $installer::globals
::isrpmbuild
= 1;
316 $installer::globals
::epmoutpath
= "RPMS";
318 if ( $installer::globals
::rpm
eq "" ) { installer
::exiter
::exit_program
("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
321 # Creating Debian packages ?
322 if (( $installer::globals
::packageformat
eq "deb" ) || ( $installer::globals
::debian
))
324 $installer::globals
::debian
= 1;
325 $installer::globals
::packageformat
= "deb";
326 my $message = "Creating Debian packages";
327 installer
::logger
::print_message
( $message );
328 push(@installer::globals
::globallogfileinfo
, $message);
329 $installer::globals
::isrpmbuild
= 0;
330 $installer::globals
::isdebbuild
= 1;
331 $installer::globals
::epmoutpath
= "DEBS";
335 # Defaulting to native package format for epm
337 if ( ! $installer::globals
::packageformat
) { $installer::globals
::packageformat
= "native"; }
339 # no languages defined as parameter
340 if ($installer::globals
::languagelist
eq "") { $installer::globals
::languages_defined_in_productlist
= 1; }
342 # setting and creating the unpackpath
344 if ($installer::globals
::unpackpath
eq "") # unpackpath not set
346 $installer::globals
::unpackpath
= cwd
();
349 if ($installer::globals
::workpath
eq "") # workpath not set
351 $installer::globals
::workpath
= cwd
();
354 if ( $installer::globals
::localunpackdir
ne "" ) { $installer::globals
::unpackpath
= $installer::globals
::localunpackdir
; }
356 if (!($installer::globals
::unpackpath
eq ""))
358 make_path_absolute
(\
$installer::globals
::unpackpath
);
361 $installer::globals
::unpackpath
=~ s/\Q$installer::globals::separator\E\s*$//;
363 if (! -d
$installer::globals
::unpackpath
) # create unpackpath
365 installer
::systemactions
::create_directory
($installer::globals
::unpackpath
);
368 # setting and creating the temppath
370 if ( $ENV{'TMPDIR'} )
372 $installer::globals
::temppath
= $ENV{'TMPDIR'};
373 $installer::globals
::temppath
=~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes and backslashes
374 $installer::globals
::temppath
.= $installer::globals
::separator
. 'ooopackagingXXXXXX';
375 $installer::globals
::temppath
= mkdtemp
($installer::globals
::temppath
);
377 my $dirsave = $installer::globals
::temppath
;
379 if ( $installer::globals
::compiler
=~ /^unxmac/ )
381 chmod 0777, $installer::globals
::temppath
;
384 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. "i";
385 $installer::globals
::temppath
= installer
::systemactions
::create_pid_directory
($installer::globals
::temppath
);
386 push(@installer::globals
::removedirs
, $installer::globals
::temppath
);
388 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"); }
390 $installer::globals
::temppath
= $installer::globals
::temppath
. $installer::globals
::separator
. $installer::globals
::compiler
;
391 installer
::systemactions
::create_directory
($installer::globals
::temppath
);
392 if ( $^O
=~ /cygwin/i )
394 $installer::globals
::cyg_temppath
= $installer::globals
::temppath
;
395 $installer::globals
::cyg_temppath
=~ s/\\/\\\\/g;
396 chomp( $installer::globals
::cyg_temppath
= qx{cygpath
-w
"$installer::globals::cyg_temppath"} );
398 $installer::globals
::temppathdefined
= 1;
402 $installer::globals
::temppathdefined
= 0;
405 # only one cab file, if Windows msp patches shall be prepared
406 if ( $installer::globals
::prepare_winpatch
) { $installer::globals
::number_of_cabfiles
= 1; }
410 ############################################
411 # Controlling the parameter that are
412 # required for special processes
413 ############################################
415 sub control_required_parameter
417 if (!($installer::globals
::is_copy_only_project
))
419 ##############################################################################################
420 # idt template path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
421 # for the creation of the msi database.
422 ##############################################################################################
424 if (($installer::globals
::idttemplatepath
eq "") && ($installer::globals
::iswindowsbuild
))
426 installer
::logger
::print_error
( "idt template path not set (-msitemplate)!" );
431 ##############################################################################################
432 # idt language path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
433 # for the creation of the msi database.
434 ##############################################################################################
436 if (($installer::globals
::idtlanguagepath
eq "") && ($installer::globals
::iswindowsbuild
))
438 installer
::logger
::print_error
( "idt language path not set (-msilanguage)!" );
443 # Analyzing the idt template path
445 if (!($installer::globals
::idttemplatepath
eq "")) # idttemplatepath set, relative or absolute?
447 make_path_absolute
(\
$installer::globals
::idttemplatepath
);
450 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idttemplatepath
);
452 # Analyzing the idt language path
454 if (!($installer::globals
::idtlanguagepath
eq "")) # idtlanguagepath set, relative or absolute?
456 make_path_absolute
(\
$installer::globals
::idtlanguagepath
);
459 installer
::remover
::remove_ending_pathseparator
(\
$installer::globals
::idtlanguagepath
);
461 # In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
462 # and the UpgradeCode for the product are defined.
463 # The name "codes.txt" can be overwritten in Product definition with CODEFILENAME (msiglobal.pm)
465 if (( $installer::globals
::iswindowsbuild
) && ( $installer::globals
::packageformat
ne "archive" ) && ( $installer::globals
::packageformat
ne "installed" ))
467 $installer::globals
::codefilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::codefilename
;
468 installer
::files
::check_file
($installer::globals
::codefilename
);
469 $installer::globals
::componentfilename
= $installer::globals
::idttemplatepath
. $installer::globals
::separator
. $installer::globals
::componentfilename
;
470 installer
::files
::check_file
($installer::globals
::componentfilename
);
475 #######################################
476 # Testing existence of files
477 # also for copy-only projects
478 #######################################
480 if ($installer::globals
::ziplistname
eq "")
482 installer
::logger
::print_error
( "ERROR: Zip list file has to be defined (Parameter -f) !" );
488 installer
::files
::check_file
($installer::globals
::ziplistname
);
491 if ($installer::globals
::setupscriptname
eq "") { $installer::globals
::setupscript_defined_in_productlist
= 1; }
492 else { installer
::files
::check_file
($installer::globals
::setupscriptname
); } # if the setupscript file is defined, it has to exist
496 ################################################
497 # Writing parameter to shell and into logfile
498 ################################################
506 push(@output, "\n########################################################\n");
507 push(@output, "Product list file: $installer::globals::ziplistname\n");
508 if (!($installer::globals
::setupscript_defined_in_productlist
))
510 push(@output, "Setup script: $installer::globals::setupscriptname\n");
514 push(@output, "Taking setup script from workdir\n");
516 push(@output, "Unpackpath: $installer::globals::unpackpath\n");
517 push(@output, "Compiler: $installer::globals::compiler\n");
518 push(@output, "Product: $installer::globals::product\n");
519 push(@output, "BuildID: $installer::globals::buildid\n");
520 push(@output, "Build: $installer::globals::build\n");
521 if ( $installer::globals
::minor
) { push(@output, "Minor: $installer::globals::minor\n"); }
522 else { push(@output, "No minor set\n"); }
523 if ( $installer::globals
::pro
) { push(@output, "Product version\n"); }
524 else { push(@output, "Non-Product version\n"); }
525 if ( $installer::globals
::rootpath
eq "" ) { push(@output, "Using default installpath\n"); }
526 else { push(@output, "Installpath: $installer::globals::rootpath\n"); }
527 push(@output, "Package format: $installer::globals::packageformat\n");
528 if (!($installer::globals
::idttemplatepath
eq "")) { push(@output, "msi templatepath: $installer::globals::idttemplatepath\n"); }
529 if ((!($installer::globals
::idttemplatepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi template path will be ignored for non Windows builds!\n"); }
530 if (!($installer::globals
::idtlanguagepath
eq "")) { push(@output, "msi languagepath: $installer::globals::idtlanguagepath\n"); }
531 if ((!($installer::globals
::idtlanguagepath
eq "")) && (!($installer::globals
::iswindowsbuild
))) { push(@output, "msi language path will be ignored for non Windows builds!\n"); }
532 if ((!($installer::globals
::iswindowsbuild
)) && ( $installer::globals
::call_epm
)) { push(@output, "Calling epm\n"); }
533 if ((!($installer::globals
::iswindowsbuild
)) && (!($installer::globals
::call_epm
))) { push(@output, "Not calling epm\n"); }
534 if ( $installer::globals
::strip
) { push(@output, "Stripping files\n"); }
535 else { push(@output, "No file stripping\n"); }
536 if ( $installer::globals
::debian
) { push(@output, "Linux: Creating Debian packages\n"); }
537 if ( $installer::globals
::dounzip
) { push(@output, "Unzip ARCHIVE files\n"); }
538 else { push(@output, "Not unzipping ARCHIVE files\n"); }
539 if (!($installer::globals
::languages_defined_in_productlist
))
541 push(@output, "Languages:\n");
542 foreach $element (@installer::globals
::languageproducts
) { push(@output, "\t$element\n"); }
546 push(@output, "Languages defined in $installer::globals::ziplistname\n");
548 if ( $installer::globals
::is_copy_only_project
) { push(@output, "This is a copy only project!\n"); }
549 if ( $installer::globals
::languagepack
) { push(@output, "Creating language pack!\n"); }
550 if ( $installer::globals
::helppack
) { push(@output, "Creating help pack!\n"); }
551 push(@output, "########################################################\n");
553 # output into shell and into logfile
555 for ( my $i = 0; $i <= $#output; $i++ )
557 installer
::logger
::print_message
( $output[$i] );
558 push(@installer::globals
::globallogfileinfo
, $output[$i]);