summaryrefslogtreecommitdiff
path: root/bin/package-ooo
blob: 42bdb544a6d95221fabe23037cf3dd8df5301bce (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#!/bin/sh

# Based on docs/setup.txt

#
# See setup for user tweakables.
#
. ./setup
. $OOBUILDDIR/*.[sS]et.sh
. ./setup

export LANG='';

# if a JDK from JPackage project (http://www.jpackage.org/) was used
# for build, we want to have rather the JRE in the default configuration.
# It's because a JRE is enough to use java support in OOo and it does
# not work if only a JRE from Jpackage project is installed but the JDK is
# configured.
test "$JAVA_HOME" = "/usr/lib/jvm/java" -a -d "/usr/lib/jvm/jre" && \
  export JAVA_HOME="/usr/lib/jvm/jre"

echo "Cleaning $OOINSTDIR";
rm -Rf $OOINSTDIR;

AUTORESPONSE=$OOBUILDDIR/autoresponse.conf

echo "Create auto-response file"
echo "[ENVIRONMENT]
INSTALLATIONMODE=INSTALL_NETWORK
INSTALLATIONTYPE=STANDARD
DESTINATIONPATH=$OOINSTDIR
OUTERPATH=
LOGFILE=
LANGUAGELIST=<LANGUAGE>

[JAVA]
JavaSupport=preinstalled_or_none" > $AUTORESPONSE

echo "Building $OOINSTDIR/ooo-wrapper$BINSUFFIX";
sed -e "s|@OOINSTBASE@|$OOINSTBASE|g
	s|@SYSCONFDIR@|$SYSCONFDIR|g
	s|@BINSUFFIX@|$BINSUFFIX|g
	s|@VERSION@|$VERSION|g
	s|@OOO_BUILDVERSION@|$OOO_BUILDVERSION|g
	s|@OOOINSTALLDIRNAME@|$OOOINSTALLDIRNAME|g
	s|@VENDORNAME@|$VENDORNAME|g" $TOOLSDIR/bin/ooo-wrapper.in \
		>| "$OOBUILDDIR/ooo-wrapper$BINSUFFIX" || exit 1;
mkdir -p $PREFIX/bin

create_simple_wrapper()
{
    cat <<EOT >$2
#!/bin/sh

exec "$1" "\$@"
EOT
    chmod 755 $2
}

# Skip the versioning and linking dance of the wrapper script for Red Hat
if test "z$VENDORNAME" = "zRedHat"; then
	cp -f $OOBUILDDIR/ooo-wrapper$BINSUFFIX $PREFIX/bin/ooffice
	chmod +x $PREFIX/bin/ooffice
	for app in calc draw impress html math writer; do
		ln -sf /usr/bin/ooffice $PREFIX/bin/oo${app}
	done
else
	mkdir -p $MANDIR/man1
	cp -f $OOBUILDDIR/ooo-wrapper$BINSUFFIX $PREFIX/bin
	chmod +x $PREFIX/bin/ooo-wrapper$BINSUFFIX
	for app in calc draw fromtemplate impress html math web writer ffice; do
		ln -sf ooo-wrapper${BINSUFFIX} $PREFIX/bin/oo${app}${BINSUFFIX}
		if test "z$VENDORNAME" = "zNovell" -o "z$VENDORNAME" = "zSUSE" -o "z$VENDORNAME" = "zPLD"; then
			echo ".so man1/openoffice$BINSUFFIX.1" >| $MANDIR/man1/oo${app}$BINSUFFIX.1;
		fi
	done

	mkdir -p $PREFIX/sbin || exit 1;
	create_simple_wrapper $OOINSTBASE/program/spadmin $PREFIX/sbin/oopadmin${BINSUFFIX} || exit 1;
	create_simple_wrapper $OOINSTBASE/program/jvmsetup $PREFIX/sbin/oojvmsetup${BINSUFFIX} || exit 1;
fi

if test "z$VENDORNAME" != "zRedHat"; then
	mkdir -p $MANDIR/man1
	echo "Generating man page ...";
	sed -e "s|@BINSUFFIX@|$BINSUFFIX|g" $TOOLSDIR/man/openoffice.1.in \
		>| "$OOBUILDDIR/openoffice$BINSUFFIX.1" || exit 1;
	cp -f $OOBUILDDIR/openoffice$BINSUFFIX.1 $MANDIR/man1
fi

echo "Building $OOINSTDIR/install-dict";
sed -e "s|@OOINSTBASE@|$OOINSTBASE|g" $TOOLSDIR/bin/install-dict.in >| "$OOBUILDDIR/install-dict" || exit 1;
mkdir -p $OOINSTDIR
cp -f $OOBUILDDIR/install-dict $OOINSTDIR
chmod +x $OOINSTDIR/install-dict

echo "Installing system files ...";
if test "z$VENDORNAME" = "zRedHat" ; then
	# Install .desktop files for Red Hat distributions
	mkdir -p $PREFIX/share/applications
	for i in openoffice-printeradmin openoffice-setup redhat-drawing \
			redhat-math redhat-presentations redhat-word-processor redhat-spreadsheet; do
		cp -f /usr/share/desktop-menu-patches/$i.desktop $PREFIX/share/applications/$i.desktop
		echo "StartupNotify=true" >> $PREFIX/share/applications/$i.desktop
	done

	# Icons are copied into the local install directory from the specfile...
	mkdir -p $PREFIX/share/pixmaps
	cp $TOOLSDIR/desktop/0*.png $PREFIX/share/pixmaps
	cp $TOOLSDIR/desktop/5*.png $PREFIX/share/pixmaps
	cp $TOOLSDIR/desktop/ooo_*.png $PREFIX/share/pixmaps
elif test "z$VENDORNAME" = "zNovell" -o "z$VENDORNAME" = "zSUSE" ; then
	mkdir -p $OODESTDIR/opt/gnome/share/applications
	cp $TOOLSDIR/desktop/*$BINSUFFIX.desktop $OODESTDIR/opt/gnome/share/applications
	for file in $OODESTDIR/opt/gnome/share/applications/*.desktop ; do
		echo "OnlyShowIn=GNOME;" >> $file
	done

	mkdir -p $OODESTDIR/opt/gnome/share/pixmaps
	cp $TOOLSDIR/desktop/ximian-openoffice-*.png $OODESTDIR/opt/gnome/share/pixmaps
else
	mkdir -p $PREFIX/share/gnome/ximian/applications
	cp $TOOLSDIR/desktop/*$BINSUFFIX.desktop $PREFIX/share/gnome/ximian/applications

	mkdir -p $PREFIX/share/pixmaps
	cp $TOOLSDIR/desktop/ximian-openoffice-*.png $PREFIX/share/pixmaps
fi

# Disable odk stuff for now
if test "disable" = "this"; then
    echo "Installing the ODK";
    ODK_SRC=$OOBUILDDIR/odk$UPD;
    ODK_INCLUDE=$OOINSTDIR/include
    echo " unzip"; 
    rm -Rf $ODK_SRC
    tar -C $OOBUILDDIR -xzf $OOBUILDDIR/solver/$UPD/$INPATH/bin/odk$UPD.tar.gz;
    echo " setup $OOINSTDIR"; 
    mkdir -p $ODK_INCLUDE
    mkdir -p $OOINSTDIR
    mkdir -p $OOINSTDIR/utils
    mkdir -p $OOINSTDIR/program
    mkdir -p $OOINSTDIR/idl
    mkdir -p $OOINSTDIR/xml
    mkdir -p $OOINSTDIR/share/doc/openoffice$BINSUFFIX
    mkdir -p $PREFIX/lib/pkgconfig
    echo " re-arrange files";
    cp -a $ODK_SRC/include/* $ODK_INCLUDE
    cp -a $ODK_SRC/linux/lib/* $OOINSTDIR/program
    cp -a $ODK_SRC/linux/bin/* $OOINSTDIR/utils
    cp -a $ODK_SRC/idl/* $OOINSTDIR/idl
    cp -a $ODK_SRC/docs/* $OOINSTDIR/share/doc/openoffice$BINSUFFIX
    cp -a $ODK_SRC/examples $OOINSTDIR/share/doc/openoffice$BINSUFFIX
    cp -a $ODK_SRC/xml/* $OOINSTDIR/xml
    echo " create pkgconfig file"; 
    echo "
libdir=$OOINSTBASE/program
includedir=$OOINSTBASE/include
idlinclude=$OOINSTBASE/idl
xmlinclude=$OOINSTBASE/xml
toolsdir=$OOINSTBASE/utils

Name: openoffice$BINSUFFIX
Description: The OpenOffice.org infrastructure
Version: $VERSION
Libs: -L\${libdir} -lprot_uno_uno
Cflags: -I\${includeddir}" > $PREFIX/lib/pkgconfig/openoffice$BINSUFFIX.pc
fi

INSTALLER_PATH="`tcsh -f -c "cd $OOBUILDDIR; source $OOBUILDDIR/*.Set; echo \"$OOBUILDDIR/instsetoo/\\$INPATH/01/normal\""`";
export DISPLAY=''; # clobber;
echo "Execute from $INSTALLER_PATH to $OOINSTDIR [$LANG]";
cd $INSTALLER_PATH || exit 1;

./setup -net -v -r:$AUTORESPONSE -nogui || exit 1;
echo "Done";

# strip binaries
if test "z$VENDORNAME" != "zRedHat" ; then
    echo "Stripping binaries";
    chmod 755 $OOINSTDIR/program/*.so
    strip $OOINSTDIR/program/*.so
fi

cd $BUILDDIR || exit 1;

# remove OODESTDIR from installed files
rm -f list.fixdir.txt || exit 1;
test -d $OOINSTDIR/share/cde/types && find $OOINSTDIR/share/cde/types -name "*.dt" >>list.fixdir.txt
test -f $OOINSTDIR/share/gnome/net/.directory && echo $OOINSTDIR/share/gnome/net/.directory >>list.fixdir.txt
test -d $OOINSTDIR/share/gnome && find $OOINSTDIR/share/gnome -name "*.desktop" >>list.fixdir.txt
test -d $OOINSTDIR/share/kde && find $OOINSTDIR/share/kde -name "*.desktop" >>list.fixdir.txt
test -f $OOINSTDIR/share/config/javarc && echo $OOINSTDIR/share/config/javarc >>list.fixdir.txt
test -f $OOINSTDIR/program/setup.log && echo $OOINSTDIR/program/setup.log >>list.fixdir.txt
test -f $OOINSTDIR/program/instdb.ins &&  echo $OOINSTDIR/program/instdb.ins >>list.fixdir.txt
#
for file in `cat list.fixdir.txt` ; do
    perl -pi -e "s|$OODESTDIR||g" $file
done
rm -f list.fixdir.txt || exit 1;

echo "Done...";

echo "Installing extra dictionaries..."

$TOOLSDIR/bin/install-dictionaries || exit 1;


# create list of common files and directories
find $OOINSTDIR -type d -exec echo %dir {}/ \; >$BUILDDIR/common_list.txt || exit 1;
find $OOINSTDIR "(" -type f -or -type l ")" >>$BUILDDIR/common_list.txt || exit 1;


echo "Building lang-packs ...";

cd $TOOLSDIR/bin || exit 1;
./package-lang || exit 1;

# FIXME: this hack is not needed if the patch scp-no-ooo-res.diff is applied
test -f $OOINSTDIR/program/resource/ooo${UPD}01.res &&
  echo "$OOINSTDIR/program/resource/ooo${UPD}01.res" >>$BUILDDIR/lang_en_list.txt

echo "Installing localized help contents..."

$TOOLSDIR/bin/install-help || exit 1;

# install more icons sets if required
if (echo "${OOO_ICONS_NAMES}" | grep -q " ") ; then

    echo "Installing extra icons sets..."

    cd $OOINSTDIR/program/resource

    # install resource files with all the selected icons set
    for ooo_icons_name in $OOO_ICONS_NAMES ; do
	mkdir -p $OOINSTDIR/program/resource.$ooo_icons_name
	for file in *.res ; do
	    # use the OOo specific source file instead of the SO specific one
	    # this hack won't be needed with OOo, version 2.0, #28285
	    source_file=`echo $file | sed "s/^iso\($UPD[0-9][0-9].res\)/ooo\1/"`
	    cp -vf $OOBUILDDIR/solver/$UPD/$INPATH/bin.$ooo_icons_name/$source_file \
        	../resource.$ooo_icons_name/$file
	done
	# update file lists
	for file in $BUILDDIR/*list.txt ; do
	    perl -pi -e "s|^($OOINSTDIR/program)/resource/(.*res)\$|\1/resource/\2\n\1/resource.$ooo_icons_name/\2|;" \
        	     -e "s|^(%dir $OOINSTDIR/program)/resource/$|\1/resource/\n\1/resource.$ooo_icons_name/|" $file
	done	
    done
    
    cd $BUILDDIR

    # remove original resource files
    rm -rf $OOINSTDIR/program/resource
    # link to the default resource
    ln -sf resource.${OOO_ICONS_NAMES%% *} $OOINSTDIR/program/resource.default
    # update file lists
    for file in $BUILDDIR/*list.txt ; do
	perl -pi -e "s|^$OOINSTDIR/program/resource/.*res$||;" \
        	 -e "s|^%dir $OOINSTDIR/program/resource/$||" $file
    done
    # the link to the default resource dir should be only in the main package
    echo "$OOINSTDIR/program/resource.default" >>common_list.txt
fi	

# move one file from one list of files to a second one
# Params: target_file_list source_file_list file_to_move
mv_file_between_flists()
{
    if grep "^$3\$" $2 >/dev/null 2>&1 ; then
	echo "$3" >>$1
	perl -pi -e "s|^$3$||" $2
    fi
}

# add the directories from the source list of files to the target list of
# file which are used in the target list of files but are missing there
# Params: target_file_list source_file_list
add_used_directories()
{
    sort -u -r $2 | sed -n "s|^%dir \(.*\)\$|s%^\\\\(\1\\\\).*%\\\\1%p|p" >$2.pattern
    sed -n -f $2.pattern $1 | sort -u | sed "s|^|%dir |" >>$1
    rm $2.pattern
}

echo "Creating specialized lists of files..."

cd $BUILDDIR

# kde subpackage
rm -f kde_list.txt
mv_file_between_flists kde_list.txt common_list.txt $OOINSTDIR/program/kdefilepicker
mv_file_between_flists kde_list.txt common_list.txt $OOINSTDIR/program/libfps_kde.so
mv_file_between_flists kde_list.txt common_list.txt $OOINSTDIR/program/libvclplug_kde645li.so
add_used_directories kde_list.txt common_list.txt

# gnome subpackage
rm -f gnome_list.txt
mv_file_between_flists gnome_list.txt common_list.txt $OOINSTDIR/program/libevoab2.so
mv_file_between_flists gnome_list.txt common_list.txt $OOINSTDIR/program/libfps_gnome.so
mv_file_between_flists gnome_list.txt common_list.txt $OOINSTDIR/program/libvclplug_gtk645li.so
add_used_directories gnome_list.txt common_list.txt

echo "Cleaning up lists of files...";

cd $BUILDDIR

# remove English specific files
# remove everything mentioned in lang_en_list.txt from common_list.txt
sed "s|^\(.*\)\$|^\1\$|" lang_en_list.txt >lang_en_list.txt.pattern
grep -v -f lang_en_list.txt.pattern common_list.txt >common_list.txt.new
mv common_list.txt.new common_list.txt
# add back directories which are still used
add_used_directories common_list.txt lang_en_list.txt
# sort the list again
sort -u common_list.txt >common_list.txt.new
mv common_list.txt.new common_list.txt

# move English help to an extra list
echo "%dir $OOINSTDIR/" >help_en_list.txt
echo "%dir $OOINSTDIR/help/" >>help_en_list.txt
grep "$OOINSTDIR/help/en" lang_en_list.txt >>help_en_list.txt
grep -v "$OOINSTDIR/help/en" lang_en_list.txt >lang_en_list.txt.new
mv lang_en_list.txt.new lang_en_list.txt

# remove $DESTDIR
for file in *list.txt ; do
    perl -pi -e "s|$OODESTDIR||" $file
done

# mark the config files
if test "z$RPM_CONFIG_FILE_TAGS" != "z" ; then
    perl -pi -e "s|^($OOINSTBASE/help/.*\.xsl)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/help/.*\.css)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/program/[a-zA-Z0-9]*rc)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/program/.*\.xsl)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/config/[a-zA-Z0-9]*rc)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/dict/ooo/.*\.lst)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/psprint/.*\.conf)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/psprint/.*\.PS)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/registry/.*\.xcu)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/registry/.*\.properties)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/share/registry/.*\.xcs)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	    -e "s|^($OOINSTBASE/user/config/.*\.so.)\$|$RPM_CONFIG_FILE_TAGS \\1|;" \
	*_list.txt
fi

# Red Hat Post-install cleanup
if test "z$VENDORNAME" = "zRedHat" ; then
	# Fix openoffice/share/kde/net/applnk paths
	perl -pi -e "/^Module gid_Module_Optional_Kde/ .. /^End/ and s|YES|NO|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Installation gid_Installation/ .. /^End/ and s|$PREFIX||g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Directory gid_Dir_Home_Gnome_Apps_Product/ .. /^End/ and s|OpenOffice\.org\ 1\.1\.0|OpenOffice\.org|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Directory gid_Dir_Share_Kde_Net_Applnk_Product/ .. /^End/ and s|OpenOffice\.org\ 1\.1\.0|OpenOffice\.org|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Directory gid_Dir_Kde_Share_Applnk_Product/ .. /^End/ and s|OpenOffice\.org\ 1\.1\.0|OpenOffice\.org|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Procedure gid_Procedure_Kde_Inst/ .. /^End/ and s|OpenOffice\.org\ 1\.1\.0|OpenOffice\.org|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Procedure gid_Procedure_Gnome_Install/ .. /^End/ and s|OpenOffice\.org\ 1\.1\.0|OpenOffice\.org|g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	perl -pi -e "/^Procedure gid_Procedure_Gnome_Deinstall/ .. /^End/ and s|1\.1\.0||g" $PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins

	## Fix instdb.ins, to *not* install local copies of these
	for entry in Kdeapplnk Kdemimetext Kdeicons Gnome_Apps Gnome_Icons Gnome2_Apps; do
		perl -pi -e "/^File gid_File_Extra_$entry/ .. /^End/ and (\
			s|^\tSize\s+\= .*|\tSize\t\t = 0;\r| or \
			s|^\tArchiveFiles\s+\= .*|\tArchiveFiles\t = 0;\r| or \
			s|^\tArchiveSize\s+\= .*|\tArchiveSize\t = 0;\r| or \
			s|^\tContains\s+\= .*|\tContains\t = ();\r| or \
			s|\t\t\t\t\t\".*|\r|g)" \
			$PREFIX/lib/$OOOINSTALLDIRNAME/program/instdb.ins
	done
fi

echo "Packaging succeeded";
exit 0;