#!/bin/bash

. ./devel.bash

. ./config-settings.bash

tar_file=$dist_build_ver-$GSDLOS.tar.gz

# The steps needed:
#
# 1. mkdir dist/rsync-x.x
# 2. rsync (copy/move) the following
#      $GEXT_PKGCONF_INSTALLED -> dist/rsync-x.x/.
#      e.g. dist/rsync-x.x/<os>/{bin,lib,share,...}
# 3. setup.bash file needs to be copied in

src_dir="$GEXT_PKGCONF_INSTALLED"
dst_dir="dist/$dist_build_ver"

# 1.
/bin/rm -rf dist
mkdir -v -p "$dst_dir"

# 2. 
# For rsync to work, need to make sure no trailing '/' on src_dir
rsync -pav "${src_dir%/}" "${dst_dir}/"

# 3.
/bin/cp setup.bash "$dst_dir/."

cd dist \
    && tar cvzf $tar_file $dist_build_ver \
    && cd ..

echo ""
echo "----"
echo "To commit the tarred-up distribution into the Greenstone subversion repo, next run"
echo "  ./DIST-SVN-COMMIT.sh"

echo "----"
echo ""
