#!/bin/bash set -e set -x DESTDIR="$(realpath $1)" TMPDIR="$(mktemp -d)" TMPDIRDEB="${TMPDIR}/$(basename ${DESTDIR})" if [ "x${DESTDIR}" = "x" ]; then echo "usage: $0 [DESTDIR]" >&2 exit 1 fi if [ -d "${DESTDIR}/debian" ]; then cp -rf "${DESTDIR}" "${TMPDIRDEB}" rm -rf "${TMPDIRDEB}/.git*" NEWNAME=$(basename ${DESTDIR} | sed 's/-/_/') NEWDIR=$(dirname ${DESTDIR}) tar -czf "${NEWDIR}/${NEWNAME}.orig.tar.gz" -C "${TMPDIR}" "$(basename ${DESTDIR})" else echo "$0: ${DESTDIR}/debian does not exist!" >&2 exit 2 fi