Bump for 3.6-28
[LibreOffice.git] / solenv / bin / ooinstall
blobbb4d07725bbb0cd951e73e2f20b8ee1aba567a94
1 #!/usr/bin/env perl
3 # This script has three uses:
4 # 1. From the command line to install straight into a given directory:
5 # bin/ooinstall /opt/Foo
6 # 2. From the command line to link into a given directory:
7 # bin/ooinstall -l /opt/FooLinked
8 # 3. When packaging (called from package-ooo), to install to DESTDIR
10 use File::Find;
11 use File::Path qw(mkpath);
12 use Cwd;
14 $path = '';
15 $strip = '';
16 $do_link = 0;
17 $is_windows = 0;
18 my $tmp_dir;
20 # FIXME: really we should hunt and parse / source the config_host.mk magic I guess.
21 die "You need your environment setup right, eg. run make cmd cmd='ooinstall /path/to/install'" if (!defined $ENV{SRC_ROOT});
23 if ($ENV{GUI} eq 'WNT') {
24 $is_windows = 1;
27 if( defined($ENV{TMPDIR}) ) {
28 $tmp_dir = $ENV{TMPDIR};
29 } elsif( defined($ENV{TMP}) ) {
30 $tmp_dir = $ENV{TMP};
31 } else {
32 $tmp_dir = '/tmp';
34 if (!-d $tmp_dir) {die "Set TMP or TMPDIR!\n";}
36 # Workaround for system Mozilla
37 if ( $ENV{'SYSTEM_MOZILLA'} eq 'YES' ) {
38 $ENV{'LD_LIBRARY_PATH'} = "$ENV{'MOZ_LIB'}:$ENV{'LD_LIBRARY_PATH'}";
41 # Workaround for the Python
42 $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";
44 for $arg (@ARGV) {
45 if ($arg eq '-l' || $arg eq '--link') {
46 $do_link = 1;
47 } elsif ($arg eq '-s' || $arg eq '--strip') {
48 $strip = "-strip";
49 } elsif ($arg eq '-h' || $arg eq '--help') {
50 $help = 1;
51 } else {
52 # Cwd::realpath does not work if the path does not exist
53 mkpath($ENV{DESTDIR} . $arg) unless -d $ENV{DESTDIR} . $arg;
54 $path = Cwd::realpath( $ENV{DESTDIR} . $arg );
58 $help = 1 if $path eq '';
60 if ($help) {
61 print "ooinstall [-l] [-s] <prefix to install to>\n";
62 print " -l/--link - performs a linkoo on the installed source\n";
63 print " -s/--strip - strip the installed binaries\n";
64 exit 1;
67 my $BUILD=undef;
68 my $LAST_MINOR=undef;
69 open MINORMK, "$ENV{'SOLARENV'}/inc/minor.mk";
70 while (<MINORMK>) {
71 my $t = "\$" . $_;
72 if(/^BUILD/ || /^LAST_MINOR/) {
73 eval $t;
76 close MINORMK;
77 $ENV{LAST_MINOR} = $LAST_MINOR;
78 $ENV{OUT} = "../$ENV{'INPATH'}";
79 $ENV{LOCAL_OUT} = $ENV{OUT};
80 $ENV{LOCAL_COMMON_OUT} = $ENV{OUT};
81 # FIXME: the following variable helps to install localizations even if some
82 # files are not localized (like Japanese, Chinese wordbook), it makes
83 # the installer to use the English localization of the file instead.
84 $ENV{DEFAULT_TO_ENGLISH_FOR_PACKING} = 1;
86 my @larr;
87 $langs=$ENV{WITH_LANG};
88 $langs='en-US' if $langs eq '';
89 if ($langs eq 'ALL') {
90 opendir(DIR,$ENV{L10N_MODULE} . "/source");
91 @larr = readdir(DIR);
92 @larr = grep { $_ ne '.' } @larr;
93 @larr = grep { $_ ne '..' } @larr;
94 @larr = (@larr,"en-US","qtz");
95 closedir(DIR);
97 else {
98 @larr = grep { $_ ne '' } split(/ /, $langs);
100 $langs = join (",", @larr);
102 $destdir='';
103 if ( defined $ENV{DESTDIR} &&
104 $ENV{DESTDIR} ne "" ) {
105 $destdir = "-destdir \"$ENV{DESTDIR}\"";
108 $msi='';
109 if ($is_windows) {
110 $msi = "-msitemplate $ENV{SRC_ROOT}/instsetoo_native/$ENV{INPATH}/misc/openoffice/msi_templates " .
111 "-msilanguage $ENV{SRC_ROOT}/instsetoo_native/$ENV{INPATH}/misc/win_ulffiles";
114 # FIXME: a better solution would be to fix installer to deal with broken symlinks
115 # make distro-pack-install shufle with the SDK installation to make it LSB compliant
116 # it creates symlinks from the orignal path to /usr/share; they are not valid with $DESTDIR
117 # and potential second ooinstall call fails with strange error messages if the old tree is still there
118 if ($destdir && "$ENV{DESTDIR}" ne "/" && -d "$ENV{DESTDIR}") {
119 print "Cleaning destdir...\n";
120 system ("rm -rf \"$ENV{DESTDIR}\"") && die "Failed to clean up destdir: $!";
123 print "Running LibreOffice installer\n";
124 system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
125 "perl -w $ENV{SOLARENV}/bin/make_installer.pl " .
126 "-f openoffice.lst -l $langs -p LibreOffice " .
127 "-u $tmp_dir " .
128 "-buildid $BUILD $destdir $strip $msi " .
129 "-simple $path") && die "Failed to install: $!";
131 if ($ENV{BUILD_TYPE} =~ m/ODK/) {
132 print "Running SDK installer\n";
133 system ("cd $ENV{SRC_ROOT}/instsetoo_native/util ; " .
134 "perl -w $ENV{SOLARENV}/bin/make_installer.pl " .
135 "-f openoffice.lst -l en-US -p LibreOffice_SDK " .
136 "-u $tmp_dir " .
137 "-buildid $BUILD $destdir $strip $msi " .
138 "-simple $path") && die "Failed to install: $!";
140 print "Installer finished\n";
142 if ($do_link && !$is_windows) {
143 system("$ENV{SOLARENV}/bin/linkoo $path $ENV{SRC_ROOT}") &&
144 die "linkoo failed: $!";