2010-10-23 12:03:58 -05:00
#!/usr/bin/env perl
# This script has three uses:
# 1. From the command line to install straight into a given directory:
# bin/ooinstall /opt/Foo
# 2. From the command line to link into a given directory:
# bin/ooinstall -l /opt/FooLinked
# 3. When packaging (called from package-ooo), to install to DESTDIR
use File::Find;
2010-11-05 08:58:42 -05:00
use File::Path qw(mkpath);
2010-10-23 12:03:58 -05:00
use Cwd;
$path = '';
$do_link = 0;
sub wanted {
my $path_to_unopkg="$path/program";
if ( $^O =~ /darwin/i )
{
$path_to_unopkg="$path/OpenOffice.org.app/Contents/MacOS";
}
-f $_
&& /.*\.oxt$/
&& system ( "LD_LIBRARY_PATH='' $path_to_unopkg/unopkg add -v --shared $File::Find::name" )
&& die "Cannot install $_ extension!";
}
2010-11-09 02:57:42 -06:00
( $^O =~ /openbsd/i ) || ( $^O =~ /darwin/i ) || ( -f "/proc/meminfo" ) || die "The installer cannot work without javaldx running, which requires /proc to be mounted";
2010-10-23 12:03:58 -05:00
# Workaround for system Mozilla
if ( $ENV{'SYSTEM_MOZILLA'} eq 'YES' ) {
$ENV{'LD_LIBRARY_PATH'} = "$ENV{'MOZ_LIB'}:$ENV{'LD_LIBRARY_PATH'}";
}
# Workaround for the Python
$ENV{'PYTHONPATH'} = "$ENV{'SRC_ROOT'}/instsetoo_native/$ENV{'INPATH'}/bin:$ENV{'SOLARVERSION'}/$ENV{'INPATH'}/lib:$ENV{'SOLARVERSION'}/$ENV{'INPATH'}/lib/python/lib-dynload";
for $arg (@ARGV) {
if ($arg eq '-l') {
$do_link = 1;
} elsif ($arg eq '-h' || $arg eq '--help') {
$help = 1;
} else {
2010-11-05 08:58:42 -05:00
# Cwd::realpath does not work if the path does not exist
mkpath($arg) unless -d $arg;
2010-10-23 12:03:58 -05:00
$path = Cwd::realpath( $arg );
}
}
$help = 1 if $path eq '';
if ($help) {
print "ooinstall [-l] <prefix to install to>\n";
print " -l - performs a linkoo on the installed source\n";
exit 1;
}
my $BUILD=undef;
my $LAST_MINOR=undef;
open MINORMK, "$ENV{'SOLARENV'}/inc/minor.mk";
while (<MINORMK>) {
my $t = "\$" . $_;
if(/^BUILD/ || /^LAST_MINOR/) {
eval $t;
}
}
close MINORMK;
$ENV{LAST_MINOR} = $LAST_MINOR;
$ENV{OUT} = "../$ENV{'INPATH'}";
$ENV{LOCAL_OUT} = $ENV{OUT};
$ENV{LOCAL_COMMON_OUT} = $ENV{OUT};
# FIXME: the following variable helps to install localizations even if some
# files are not localized (like Japanese, Chinese wordbook), it makes
# the installer to use the English localization of the file instead.
$ENV{DEFAULT_TO_ENGLISH_FOR_PACKING} = 1;
2010-11-09 21:58:40 -06:00
$langs=$ENV{WITH_LANG};
2010-10-23 12:03:58 -05:00
$langs='en-US' if $langs eq '';
$langs =~ s/\s+/,/g;
# FIXME: hack... we get a useless , at the end which makes it being e.g. zu#
# which breaks the build...
$langs =~ s/,'/'/;
$destdir='';
2010-11-09 21:58:40 -06:00
if ( defined $ENV{OODESTDIR} &&
$ENV{OODESTDIR} ne "" ) {
$destdir = "-destdir \"$ENV{OODESTDIR}\"";
2010-10-23 12:03:58 -05:00
}
$strip='';
2010-11-09 21:58:40 -06:00
if ( defined $ENV{DISABLE_STRIP} &&
$ENV{DISABLE_STRIP} eq "TRUE" ) {
2010-10-23 12:03:58 -05:00
$strip = "-dontstrip";
}
print "Running OOo installer\n";
system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
2010-10-28 05:45:40 -05:00
"perl -w $ENV{SOLARENV}/bin/make_installer.pl " .
2010-10-23 12:03:58 -05:00
"-f openoffice.lst -l $langs -p LibreOffice " .
"-buildid $BUILD $destdir $strip " .
"-simple $path") && die "Failed to install: $!";
if ($ENV{BUILD_TYPE} =~ m/ODK/) {
print "Running SDK installer\n";
system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
"perl -w $ENV{SOLARENV}/bin/make_installer.pl " .
"-f openoffice.lst -l en-US -p LibreOffice_SDK " .
"-buildid $BUILD $destdir $strip " .
"-simple $path") && die "Failed to install: $!";
}
print "Installer finished\n";
if ($do_link) {
`$ENV{SOLARENV}/bin/linkoo $path $ENV{SRC_ROOT}`;
}