#!/bin/bash

. ./devel.bash

. ./config-settings.bash

tar_file="selfcontained-$dist_build_ver-$GSDLOS.tar.gz"

# The steps needed:
#
# 1. mkdir dist/pkg-config-n.n.n
# 2. rsync the following
#      $GEXT_PKGCONF_INSTALLED -> dist/pkg-config-n.n.n (stripping off the top-level GSDLOS)
#      e.g. dist/pkg-config-n.n.n/{bin,lib,share,...}


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

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

# 2. 
# When performing the rsync, lose the OS layer (e.g. '/linux') that is there
rsync -pav "$src_dir"/* "$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 "  ./SELFCONTAINED-DIST-SVN-COMMIT.sh"

echo "----"
echo ""
