2
# Repackage upstream source, removing shipped debian/ directory
3
# should be called as "repack.sh --upstream-source <ver> <downloaded file>
4
# (for example, via uscan)
12
PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'`
14
REPACK_DIR="$PKG-$VER.orig" # DevRef § 6.7.8.2
16
echo -e "\nRepackaging $FILE\n"
18
DIR=`mktemp -d ./tmpRepackXXXXXX`
19
trap "rm -rf \"$DIR\"" QUIT INT EXIT
21
# Create an extra directory to cope with rootless tarballs
24
tar xzf "$FILE" -C "$UP_BASE"
26
if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then
27
# Tarball does contain a root directory
28
UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`"
31
## Here we remove the upstream debian directory and delete all of the
32
## occurences about debian in the MANIFEST file.
33
rm -vr $UP_BASE/debian
34
sed '/^debian/d' $UP_BASE/MANIFEST> $UP_BASE/MANIFEST.no-debian
35
mv $UP_BASE/MANIFEST.no-debian $UP_BASE/MANIFEST
38
mv "$UP_BASE" "$DIR/$REPACK_DIR"
40
# Using a pipe hides tar errors!
41
tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR"
42
gzip -9 < "$DIR/repacked.tar" > "$DIR/repacked.tar.gz"
45
mv "$DIR/repacked.tar.gz" "$FILE"
47
echo "*** $FILE repackaged"
49
prename --verbose --force "s/$VER/$DVER/" $FILE