aboutsummaryrefslogtreecommitdiff
path: root/debianify-srcdir
blob: bb7bd6498b7553ed63ea4e9be704f064ffaa325d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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