1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#!/bin/sh
set -e
if ! egrep -qv "^(#| *)$" debian/sourceless; then
echo "No sourceless files specified. Skipping the dfsg tarball creation."
exit 0
fi
while [ $1 ]; do
case $1 in
--upstream-version)
shift
VERSION=$1
;;
*)
FILE=$1
esac
shift
done
if ! [ ${FILE} ]; then
echo "Usage: $0 [--upstream-version <version>] <filename>"
exit 0
fi
UPSTREAM_FILE=$(basename $(readlink -f ${FILE}))
NAME=$(dpkg-parsechangelog | sed -n 's/^Source: //p')
if [ $VERSION ]; then
DFSG_FILE=${NAME}_${VERSION}
else
DFSG_FILE=${FILE%%.orig*}
VERSION=${DFSG_FILE##*_}
fi
DFSG_NUM=$(dpkg-parsechangelog --show-field Changes --from ${VERSION} | grep ^${NAME} | head -n 1 | grep -o "${VERSION}.*-" | grep -E -o "dfsg[[:digit:]]*" | sed 's/dfsg//')
DFSG_FILE=${DFSG_FILE}+dfsg${DFSG_NUM}.orig.tar
EXT=${UPSTREAM_FILE##*.}
case ${EXT} in
"gz")
PACK="gzip -vf"
UNPACK="gunzip -vf"
;;
"bz2")
PACK="bzip2 -vf"
UNPACK="bunzip2 -vf"
;;
"lzma")
PACK="lzma -vf"
UNPACK="unzlma -vf"
;;
"xz")
PACK="xz -vf"
UNPACK="unxz -vf"
;;
*)
echo "Compression type not supported. Nothing to do..."
exit 0
esac
cp -i ../${UPSTREAM_FILE} ../${DFSG_FILE}.${EXT}
echo "Unpacking tarball... "
${UNPACK} ../${DFSG_FILE}.${EXT}
OLDIFS=$IFS
IFS='
'
SOURCELESS=$(grep -v ^
for ITEM in $SOURCELESS; do
echo -n "Deleting '${ITEM}' from tarball... "
if ! tar --delete --wildcards -f ../${DFSG_FILE} "${ITEM}"; then
echo "WARNING! THE CONTENT OF THE DEBIAN/SOURCELESS MAY BE WRONG!"
else
echo "done"
fi
done
IFS=$OLDIFS
echo "Packing tarball... "
${PACK} ../${DFSG_FILE}
|