bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / ooinstall
blob59335e809584b3ffbfc90b44ea708fd04f251692
1 #!/usr/bin/env perl
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This script has three uses:
11 # 1. From the command line to install straight into a given directory:
12 # bin/ooinstall /opt/Foo
13 # 2. From the command line to link into a given directory:
14 # bin/ooinstall -l /opt/FooLinked
15 # 3. When packaging (called from package-ooo), to install to DESTDIR
17 use File::Find;
18 use File::Path qw(mkpath);
19 use Cwd;
21 $path = '';
22 $strip = '';
23 $do_link = 0;
24 $is_windows = 0;
25 my $tmp_dir;
27 # FIXME: really we should hunt and parse / source the config_host.mk magic I guess.
28 die "You need your environment setup right, eg. run make cmd cmd='ooinstall /path/to/install'" if (!defined $ENV{SRC_ROOT});
30 if ($ENV{OS} eq 'WNT') {
31 $is_windows = 1;
34 if (defined($ENV{TMPDIR})) {
35 $tmp_dir = $ENV{TMPDIR};
37 if (!-d $tmp_dir) {die "Set TMPDIR!\n";}
39 # Workaround for system Mozilla
40 if ($ENV{'SYSTEM_MOZILLA'} eq 'YES') {
41 $ENV{'LD_LIBRARY_PATH'} = "$ENV{'MOZ_LIB'}:$ENV{'LD_LIBRARY_PATH'}";
44 # Workaround for the Python
45 $ENV{'PYTHONPATH'} = "$ENV{'SRC_ROOT'}/instsetoo_native/$ENV{'INPATH'}/bin:$ENV{'SOLARVERSION'}/$ENV{'INPATH'}/lib:$ENV{'SOLARVERSION'}/$ENV{'INPATH'}/lib/python:$ENV{'SOLARVERSION'}/$ENV{'INPATH'}/lib/python/lib-dynload";
47 for $arg (@ARGV) {
48 if ($arg eq '-l' || $arg eq '--link') {
49 $do_link = 1;
50 } elsif ($arg eq '-s' || $arg eq '--strip') {
51 $strip = "-strip";
52 } elsif ($arg eq '-h' || $arg eq '--help') {
53 $help = 1;
54 } else {
55 # Cwd::realpath does not work if the path does not exist
56 mkpath($ENV{DESTDIR} . $arg) unless -d $ENV{DESTDIR} . $arg;
57 $path = Cwd::realpath($ENV{DESTDIR} . $arg);
61 $help = 1 if $path eq '';
63 if ($help) {
64 print "ooinstall [-l] [-s] <prefix to install to>\n";
65 print " -l/--link - performs a linkoo on the installed source\n";
66 print " -s/--strip - strip the installed binaries\n";
67 exit 1;
70 my $BUILD=$ENV{LIBO_VERSION_PATCH};
71 $ENV{LAST_MINOR} = 'm0';
72 $ENV{OUT} = "../$ENV{'INPATH'}";
73 $ENV{LOCAL_OUT} = $ENV{OUT};
74 $ENV{LOCAL_COMMON_OUT} = $ENV{OUT};
76 my @larr;
77 $langs=$ENV{WITH_LANG_LIST};
78 @larr = grep { $_ ne '' } split(/ /, $langs);
79 $langs = join (",", @larr);
81 $destdir='';
82 if (defined $ENV{DESTDIR} &&
83 $ENV{DESTDIR} ne "" ) {
84 $destdir = "-destdir \"$ENV{DESTDIR}\"";
87 $msi='';
88 if ($is_windows) {
89 $msi = "-msitemplate $ENV{SRC_ROOT}/instsetoo_native/$ENV{INPATH}/misc/openoffice/msi_templates " .
90 "-msilanguage $ENV{SRC_ROOT}/instsetoo_native/$ENV{INPATH}/misc/win_ulffiles";
93 # FIXME: a better solution would be to fix installer to deal with broken symlinks
94 # make distro-pack-install shufle with the SDK installation to make it LSB compliant
95 # it creates symlinks from the orignal path to /usr/share; they are not valid with $DESTDIR
96 # and potential second ooinstall call fails with strange error messages if the old tree is still there
97 if ($destdir && "$ENV{DESTDIR}" ne "/" && -d "$ENV{DESTDIR}") {
98 print "Cleaning destdir...\n";
99 system ("rm -rf \"$ENV{DESTDIR}\"") && die "Failed to clean up destdir: $!";
102 print "Running LibreOffice installer\n";
104 system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
105 "perl " .
106 (scalar keys(%DB::sub) ? "-d " : "") .
107 "-w $ENV{SOLARENV}/bin/make_installer.pl " .
108 "-f $ENV{BUILDDIR}/instsetoo_native/util/openoffice.lst -l $langs -p LibreOffice " .
109 "-u $tmp_dir " .
110 "-buildid $BUILD $destdir $strip $msi " .
111 "-simple $path") && die "Failed to install: $!";
113 if ($ENV{BUILD_TYPE} =~ m/ODK/) {
114 print "Running SDK installer\n";
115 system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
116 "perl -w $ENV{SOLARENV}/bin/make_installer.pl " .
117 "-f $ENV{BUILDDIR}/instsetoo_native/util/openoffice.lst -l en-US -p LibreOffice_SDK " .
118 "-u $tmp_dir " .
119 "-buildid $BUILD $destdir $strip $msi " .
120 "-simple $path") && die "Failed to install: $!";
122 print "Installer finished\n";
124 if ($do_link && !$is_windows) {
125 system("$ENV{SOLARENV}/bin/linkoo $path $ENV{BUILDDIR}") &&
126 die "linkoo failed: $!";
129 # Local Variables:
130 # cperl-indent-level: 4
131 # indent-tabs-mode: nil
132 # End:
133 # vim:set shiftwidth=4 softtabstop=4 expandtab: