#!/bin/sh

# to be invoked from uscan (debian/watch)

set -e
set -u
set -x

component="$1"
# --upstream-version <version>
version="$3"

if [ "$component" = "helpcontent2" ]; then
	tar_component=help;
else 
	tar_component=$component;
fi

upstream_tarball="libreoffice-$tar_component-$version.tar.xz"
orig_tarball="libreoffice_$version.orig-$component.tar.xz"

tar xfJ ../$upstream_tarball

# FIXME
# remove symlinks, isn't it supposed to NOT try to do it?
rm ../$orig_tarball*

# pack the thing in
cd libreoffice-$version
tar cfJ ../../$orig_tarball $component
cd ..

rm -rf libreoffice-$version

