2
# Repackage upstream source to exclude non-distributable files
3
# should be called as "repack sh --upstream-source <ver> <downloaded file>
4
# (for example, via uscan)
3
# Repackage upstream source to exclude non-distributable files.
4
# Should be called as "repack sh --upstream-source <version> <file>
5
# (for example, via uscan).
10
PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'`
11
VER=`dpkg-parsechangelog|grep ^Version:|sed 's/^Version: //; s/.dfsg1-[^-]\+$//'`
13
printf "\nRepackaging $FILE\n"
15
DIR=`mktemp -d ./tmpRepackXXXXXX`
16
trap "rm -rf $DIR" QUIT INT EXIT
20
REPACK=`basename $FILE`
30
rm -v $UP_DIR/doc/draft*
31
rm -v $UP_DIR/doc/rfc*
33
REPACK_DIR="$PKG-$VER.orig"
34
mv $UP_DIR $REPACK_DIR
35
tar -c $REPACK_DIR | gzip -9 > $REPACK
40
echo "*** $FILE repackaged"
11
echo "Usage: $0 --upstream-source <version> <file>"
18
trap "rm -rf $TMPDIR" QUIT INT EXIT
20
echo "Repackaging $OPT_FILE"
22
tar xzf $OPT_FILE -C $TMPDIR
24
orig_file_path=`readlink --canonicalize $OPT_FILE`
25
upstream_directory=`ls -1 $TMPDIR | head -1`
26
package_name=`dpkg-parsechangelog | sed -n 's/^Source: //p'`
27
dfsg_directory=${package_name}_${OPT_VERSION}.dfsg1
28
dfsg_file_path=`dirname $orig_file_path`/$dfsg_directory.orig.tar.gz
30
# Use a subshell to remove the non-dfsg-free files
35
cd $TMPDIR/$upstream_directory
37
# Individual files to remove
45
# Whole directories to remove
47
dlcompat-20010505 ; do
52
# Rename upstream tarball root directory and repackage the file
55
mv $upstream_directory $dfsg_directory
56
tar czf $orig_file_path *
57
mv $orig_file_path $dfsg_file_path
60
echo "File $OPT_FILE repackaged successfully to $dfsg_file_path"