summaryrefslogtreecommitdiff
path: root/bin/ooinstall
blob: d0427bae3ea6083fc6f496c5eefdef7f2ebe8d0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/perl -w 

# 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

%setup_vars = ();
%configure_vars = ();

sub suck_setup($)
{
    my $file = shift;
    if (-f $file) {
	print "Reading setup from $file\n";
	open ($Vars, ". $file ; set|") || die "Can't find $file: $!";
	while (<$Vars>) {
	    /([^=]*)=(.*)/ || next;
	    $setup_vars{$1} = $2;
	}
	close ($Vars);
	return 1;
    }
    return 0;
}

( -f "/proc/meminfo" ) || die "The installer cannot work without javaldx running, which requires /proc to be mounted";

suck_setup ("./setup") || suck_setup ("bin/setup") || die "can't find bin/setup";

print "Sucking env from build setup\n";
my $fname = `ls $setup_vars{'OOBUILDDIR'}/*.[sS]et.sh`;
open ($Vars, $fname) || die "Can't open $fname: $!";
while (<$Vars>) {
    /^alias/ && next;
    /([^=]*)=\S*"(.*)"\S*/ || next;
    if (!defined $configure_vars{$1}) {
	$configure_vars{$1} = $2;
#	print "Configure var '$1' -> '$2'\n";
    }
}
close ($Vars);

print "Performing environment substitutions ...\n";
my @substitutions = ( 'SOLARENVINC', 'SOLARENV', 'SRC_ROOT', 'UPD', 'INPATH',
		      'OUTPATH', 'SOLARVER', 'JAVA_HOME' );
# perform substitutions
for my $subst (@substitutions) {
    for my $key (keys %configure_vars) {
#	$configure_vars{$key} =~ m/\$$subst/ && print "Match $subst in $key\n";
	$configure_vars{$key} =~ s/\$$subst/$configure_vars{$subst}/g;
    }
}    

# Workaround for system Mozilla
if ( $configure_vars{'SYSTEM_MOZILLA'} eq 'YES' ) {
    $configure_vars{'LD_LIBRARY_PATH'} = "$configure_vars{'MOZ_LIB'}:$configure_vars{'LD_LIBRARY_PATH'}";
}

# Workaround for the Python
$configure_vars{'PYTHONPATH'} = "$setup_vars{'OOBUILDDIR'}/instsetoo_native/$configure_vars{'INPATH'}/bin:$configure_vars{'SOLARVER'}/$configure_vars{'UPD'}/$configure_vars{'INPATH'}/lib";

my $path = '';
my $do_link = 0;

for $arg (@ARGV) {
    if ($arg eq '-l') {
	$do_link = 1;

    } elsif ($arg eq '-h' || $arg eq '--help') {
	$help = 1;
    } else {
	$path = $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;
}

print "Setting up environment\n";
for $a (keys %configure_vars) {
    $ENV{$a} = $configure_vars{$a};
}

$BUILD=8990;
$ENV{OUT} = "../$configure_vars{'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;

$langs=$setup_vars{OOO_LANGS_LIST};
$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='';
if ( defined $setup_vars{OODESTDIR} &&
     $setup_vars{OODESTDIR} ne "" ) {
    $destdir = "-destdir \"$setup_vars{OODESTDIR}\"";
}

$strip='';
if ( defined $setup_vars{OOO_STRIP} &&
     $setup_vars{OOO_STRIP} eq "no" ) {
    $strip = "-dontstrip";
}

print "Running installer\n";
system ("cd $setup_vars{OOBUILDDIR}/instsetoo_native/util ; " .
	"perl -w $configure_vars{SOLARENV}/bin/make_installer.pl " .
	"-f openoffice.lst -l $langs -p OpenOffice " .
	"-packagelist ../inc_openoffice/unix/packagelist.txt " .
	"-addpackagelist ../inc_openoffice/unix/packagelist_language.txt " .
	"-buildid $BUILD $destdir $strip " .
	"-simple $path") && die "Failed to install: $!";

print "Installer finished\n";

if ($do_link) {
    `$configure_vars{SOLARENV}/bin/linkoo $path $configure_vars{SRC_ROOT}`;
}

print "Installing extra dictionaries...";
system ("cd $setup_vars{TOOLSDIR}/bin ; " .
        "sh ./install-dictionaries $path/share/dict/ooo") && die "Failed to install dictionaries: $!";

if ($setup_vars{OPENCLIPART_VER} || $setup_vars{OPENCLIPART_DIR}) {
    print "Building extra galleries...";
    system ("cd $setup_vars{TOOLSDIR}/bin ; " .
        "   sh ./build-galleries $path") && die "Failed to build extra galleries: $!";
}