#!/bin/bash

piece=$1
ooo_build_tag=$2

source $OO_TOOLSDIR/piece/sys-setup

# install mono GAC, pkgconfig file, ...
rm -f files-mono.txt
$OO_TOOLSDIR/install-mono

# pyuno subpackages
$OO_TOOLSDIR/piece/merge-file-lists "files-pyuno.txt" $DESTDIR/gid_Module_Optional_Pyuno

# merge the rest already now, so we could extract the mono stuff
$OO_TOOLSDIR/piece/merge-file-lists "files-$piece.txt" $DESTDIR/gid_*

# finalize mono subpackage
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/basis3.0/program/cli_.*.dll
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/basis3.0/program/cli_.*.dll.config
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/basis3.0/program/policy.*.cli_.*.dll
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/ure/lib/cli_.*.dll
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/ure/lib/cli_.*.dll.config
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/ure/lib/policy.*.cli_.*.dll
mv_file_between_flists files-mono.txt files-$piece.txt $OO_INSTDIR/ure/lib/libcli_.*.so
add_used_directories files-mono.txt files-$piece.txt

# FIXME: generate pythonloader.unorc to be ready for python components registration
#        it might be generated in postprocess togeter with other profiles but it is too late
#        might be fixed by the planed scp2-split
# IMPORTANT: the other variant generated in postprocess is explicitely removed in bin/piece/post-inst-postprocess
cat <<EOT  >$DESTDIR$OO_INSTDIR/basis3.0/program/pythonloader.unorc
[Bootstrap]
PYUNO_LOADER_PYTHONPATH=\$ORIGIN
EOT
echo "%config $OO_INSTDIR/basis3.0/program/pythonloader.unorc" >>files-pyuno.txt

exit 0
