#!/bin/bash

piece=$1
ooo_build_tag=$2

source $OO_TOOLSDIR/piece/sys-setup

# sort by lang
$OO_TOOLSDIR/piece/sort-l10n $piece $ooo_build_tag $DESTDIR

# put the rest into the common file list
$OO_TOOLSDIR/piece/merge-file-lists "files-$piece.txt" $DESTDIR/gid_*
# FIXME: hid.lst will be in testtool package (built in ?)
remove_file "files-$piece.txt" $OO_INSTDIR/basis$VERSION/program/hid.lst
# non-wanted mess
remove_dir "files-$piece.txt" $OO_INSTDIR/ure

# FIXME: is a generic solution possible?
# remove the duplicated .zip archives
rm -rf $DESTDIR$OO_SOLVERDIR/pck/*.zip

# prune redundant files the scp2 likes to make for us
remove_file "files-$piece.txt" "$OO_INSTDIR/basis-link"
remove_file "files-$piece.txt" "$OO_INSTDIR/basis$VERSION/ure-link"
remove_file "files-$piece.txt" "$OO_INSTDIR/share/extensions/package.txt"
remove_file "files-$piece.txt" "$OO_INSTDIR/LICENSE.odt"

# move the stuff to /usr/share when enabled
if test "$OOO_BUILD_NOARCH" = 'YES' ; then
    $OO_TOOLSDIR/piece/install-l10n-helper $piece $ooo_build_tag "$DESTDIR" files-$piece-*.txt
    $OO_TOOLSDIR/piece/install-devel-helper $piece $ooo_build_tag
fi
