#! /bin/sh
set -e

package="adminer"
excludes=""

version="$2"
source="$3"

dest="$(dirname "$source")/${package}_${version}.orig.tar.gz"

dir="$(mktemp -d)"
trap "rm -rf -- '$dir'" EXIT

unzip -q "$source" -d "$dir"
tar -C "$dir" \
    $(for exclude in $excludes; do echo " --exclude $exclude"; done) \
    -caf "$dest" .

rm -rf - "$dir"
trap - EXIT
