#!/bin/bash
set -e

# Autodetect pyopus version from the doc-demo archive in this folder
docdemoname=$(ls pyopus-*-doc-demo.tar.gz 2>/dev/null | sort -V | tail -n 1)
if [ -z "$docdemoname" ]; then
	echo "No pyopus-*-doc-demo.tar.gz found" >&2
	exit 1
fi

basename=${docdemoname%-doc-demo.tar.gz}
echo "Detected $basename"

echo Unpacking docs and demos
rm -rf ./demo
rm -rf ./docsrc
tar xf "$docdemoname"
mv "$basename"/* .
rm -rf "$basename"
