File: repack.sh

package info (click to toggle)
libdata-ical-perl 0.16+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 332 kB
  • ctags: 229
  • sloc: perl: 2,911; sh: 23; makefile: 4
file content (48 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download
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
#!/bin/sh
# Repackage upstream source to exclude non-distributable files
# should be called as "repack.sh --upstream-source <ver> <downloaded file>
# (for example, via uscan)

set -e
set -u

VER="$2"
FILE="$3"
PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'`

REPACK_DIR="$PKG-$VER.orig" # DevRef ยง 6.7.8.2

echo -e "\nRepackaging $FILE\n"

REPACKED_ORIG=`echo $FILE | sed 's/\.orig\./+dfsg.orig./'`

DIR=`mktemp -d ./tmpRepackXXXXXX`
trap "rm -rf \"$DIR\"" QUIT INT EXIT

# Create an extra directory to cope with rootless tarballs
UP_BASE="$DIR/unpack"
mkdir "$UP_BASE"
tar xzf "$FILE" -C "$UP_BASE"

if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then
	# Tarball does contain a root directory
	UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`"
fi

## Remove stuff

# remove rfc*, we cannot redistribute it
rm $UP_BASE/doc/rfc*

# drop all references to the rfc
sed -i '\,doc/rfc2445.txt, D' $UP_BASE/MANIFEST

mv "$UP_BASE" "$DIR/$REPACK_DIR"

# Using a pipe hides tar errors!
tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR"
gzip -9 -n < "$DIR/repacked.tar" > "$DIR/repacked.tar.gz"

mv "$DIR/repacked.tar.gz" "$REPACKED_ORIG"

echo "*** $REPACKED_ORIG ready"