
#!/usr/bin/env bash

set -xeuo pipefail

ipghome=${IPGHOME}

temp_dir="$(mktemp --directory --tmpdir ipg.XXXXXXXXXX)"

mkdir "$temp_dir"/carmaker
mkdir "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/bin "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/Data "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/GUI "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/include "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/lib "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/Movie "$temp_dir"/carmaker/linux64-9.1
cp -rf "$ipghome"/carmaker/linux64-9.1/Plugins "$temp_dir"/carmaker/linux64-9.1
rm -rf "$temp_dir"/carmaker/linux64-9.1/Movie/3D/Vegetation
rm -rf "$temp_dir"/carmaker/linux64-9.1/Movie/3D/StreetFurniture
rm -rf "$temp_dir"/carmaker/linux64-9.1/Movie/3D/Buildings
rm -rf "$temp_dir"/carmaker/linux64-9.1/Movie/3D/Animals


mkdir "$temp_dir"/control
mkdir "$temp_dir"/control/linux64-3.0.7
cp -rf "$ipghome"/control/linux64-3.0.7/bin "$temp_dir"/control/linux64-3.0.7
cp -rf "$ipghome"/control/linux64-3.0.7/fonts "$temp_dir"/control/linux64-3.0.7
cp -rf "$ipghome"/control/linux64-3.0.7/lib "$temp_dir"/control/linux64-3.0.7
cp -rf "$ipghome"/control/linux64-3.0.7/Setup "$temp_dir"/control/linux64-3.0.7

mkdir "$temp_dir"/etc
cp -rf "$ipghome"/etc/Licenses "$temp_dir"/etc/Licenses

mkdir "$temp_dir"/graph
mkdir "$temp_dir"/graph/linux64-2.9.1
cp -rf "$ipghome"/graph/linux64-2.9.1/bin "$temp_dir"/graph/linux64-2.9.1
cp -rf "$ipghome"/graph/linux64-2.9.1/include "$temp_dir"/graph/linux64-2.9.1
cp -rf "$ipghome"/graph/linux64-2.9.1/lib "$temp_dir"/graph/linux64-2.9.1
cp -f "$ipghome"/graph/linux64-2.9.1/Package.info "$temp_dir"/graph/linux64-2.9.1/Package.info

cd "$temp_dir"
tar -czf ../ipg.tar.gz ./

cd ..
~/driving/scripts/build/upload-to-third-party.sh ipg.tar.gz
