| 1 |
#!/usr/bin/env perl |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 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/. |
| 8 |
# |
| 9 |
|
| 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 |
| 16 |
|
| 17 |
use File::Find; |
| 18 |
use File::Path qw(mkpath); |
| 19 |
use Cwd; |
| 20 |
|
| 21 |
$path = ''; |
| 22 |
$strip = ''; |
| 23 |
$is_windows = 0; |
| 24 |
my $tmp_dir; |
| 25 |
|
| 26 |
# FIXME: really we should hunt and parse / source the config_host.mk magic I guess. |
| 27 |
die "You need your environment setup right, eg. run make cmd cmd='ooinstall /path/to/install'" if (!defined $ENV{SRC_ROOT}); |
| 28 |
|
| 29 |
if ($ENV{OS} eq 'WNT') { |
| 30 |
$is_windows = 1; |
| 31 |
} |
| 32 |
|
| 33 |
if (defined($ENV{TMPDIR})) { |
| 34 |
$tmp_dir = $ENV{TMPDIR}; |
| 35 |
} |
| 36 |
if (!-d $tmp_dir) {die "Set TMPDIR!\n";} |
| 37 |
|
| 38 |
for $arg (@ARGV) { |
| 39 |
if ($arg eq '-s' || $arg eq '--strip') { |
| 40 |
$strip = "-strip"; |
| 41 |
} elsif ($arg eq '-h' || $arg eq '--help') { |
| 42 |
$help = 1; |
| 43 |
} else { |
| 44 |
# Cwd::realpath does not work if the path does not exist |
| 45 |
mkpath($ENV{DESTDIR} . $arg) unless -d $ENV{DESTDIR} . $arg; |
| 46 |
$path = Cwd::realpath($ENV{DESTDIR} . $arg); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
$help = 1 if $path eq ''; |
| 51 |
|
| 52 |
if ($help) { |
| 53 |
print "ooinstall [-s] <prefix to install to>\n"; |
| 54 |
print " -s/--strip - strip the installed binaries\n"; |
| 55 |
exit 1; |
| 56 |
} |
| 57 |
|
| 58 |
my $BUILD=$ENV{LIBO_VERSION_PATCH}; |
| 59 |
$ENV{OUT} = "../FIXME"; |
| 60 |
$ENV{LOCAL_OUT} = $ENV{OUT}; |
| 61 |
$ENV{LOCAL_COMMON_OUT} = $ENV{OUT}; |
| 62 |
|
| 63 |
my @larr; |
| 64 |
$langs=$ENV{WITH_LANG_LIST}; |
| 65 |
@larr = grep { $_ ne '' } split(/ /, $langs); |
| 66 |
$langs = join (",", @larr); |
| 67 |
|
| 68 |
$destdir=''; |
| 69 |
if (defined $ENV{DESTDIR} && |
| 70 |
$ENV{DESTDIR} ne "" ) { |
| 71 |
$destdir = "-destdir \"$ENV{DESTDIR}\""; |
| 72 |
} |
| 73 |
|
| 74 |
$msi=''; |
| 75 |
if ($is_windows) { |
| 76 |
$msi = "-msitemplate $ENV{SRC_ROOT}/workdir/CustomTarget/instsetoo_native/install/msi_templates " . |
| 77 |
"-msilanguage $ENV{SRC_ROOT}/workdir/CustomTarget/instsetoo_native/install/win_ulffiles"; |
| 78 |
} |
| 79 |
|
| 80 |
# FIXME: a better solution would be to fix installer to deal with broken symlinks |
| 81 |
# make distro-pack-install shuffle with the SDK installation to make it LSB compliant |
| 82 |
# it creates symlinks from the original path to /usr/share; they are not valid with $DESTDIR |
| 83 |
# and potential second ooinstall call fails with strange error messages if the old tree is still there |
| 84 |
if ($destdir && "$ENV{DESTDIR}" ne "/" && -d "$ENV{DESTDIR}") { |
| 85 |
print "Cleaning destdir...\n"; |
| 86 |
system ("rm -rf \"$ENV{DESTDIR}\"") && die "Failed to clean up destdir: $!"; |
| 87 |
} |
| 88 |
|
| 89 |
print "Running LibreOffice installer\n"; |
| 90 |
|
| 91 |
my $PRODUCTNAME_no_spaces = $ENV{PRODUCTNAME}; |
| 92 |
$PRODUCTNAME_no_spaces =~ s/ //g; |
| 93 |
|
| 94 |
system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " . |
| 95 |
"perl " . |
| 96 |
(scalar keys(%DB::sub) ? "-d " : "") . |
| 97 |
"-w $ENV{SRCDIR}/solenv/bin/make_installer.pl " . |
| 98 |
"-f $ENV{BUILDDIR}/instsetoo_native/util/openoffice.lst -l $langs -p $PRODUCTNAME_no_spaces " . |
| 99 |
"-u $tmp_dir " . |
| 100 |
"-buildid $BUILD $destdir $strip $msi " . |
| 101 |
"-simple $path") && die "Failed to install: $!"; |
| 102 |
|
| 103 |
if ($ENV{BUILD_TYPE} =~ m/ODK/) { |
| 104 |
print "Running SDK installer\n"; |
| 105 |
system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " . |
| 106 |
"perl -w $ENV{SRCDIR}/solenv/bin/make_installer.pl " . |
| 107 |
"-f $ENV{BUILDDIR}/instsetoo_native/util/openoffice.lst -l en-US -p LibreOffice_SDK " . |
| 108 |
"-u $tmp_dir " . |
| 109 |
"-buildid $BUILD $destdir $strip $msi " . |
| 110 |
"-simple $path") && die "Failed to install: $!"; |
| 111 |
} |
| 112 |
print "Installer finished\n"; |
| 113 |
|
| 114 |
# Local Variables: |
| 115 |
# cperl-indent-level: 4 |
| 116 |
# indent-tabs-mode: nil |
| 117 |
# End: |
| 118 |
# vim:set shiftwidth=4 softtabstop=4 expandtab: |