File: repack.sh

package info (click to toggle)
quickfix 1.14.4+dfsg-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 38,884 kB
  • ctags: 174,468
  • sloc: cpp: 588,389; python: 102,102; ruby: 81,148; xml: 43,721; ansic: 7,673; java: 1,827; cs: 816; makefile: 453; sh: 424; sql: 313
file content (43 lines) | stat: -rwxr-xr-x 750 bytes parent folder | download | duplicates (2)
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
#!/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

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

printf "\nRepackaging $FILE\n"

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

tar xzf $FILE -C $DIR

TARGET=`echo $FILE |sed 's/_\(.*\)\.orig/_\1+dfsg.orig/'`
REPACK=`basename $TARGET`

UP_DIR=`ls -1 $DIR`

(
    set -e
    set -u

    cd $DIR

    rm -rv $UP_DIR/lib/*

    REPACK_DIR="$PKG-$VER.orig"
    mv $UP_DIR $REPACK_DIR
    tar -c $REPACK_DIR | gzip -9 > $REPACK
)

rm -v $FILE
mv $DIR/$REPACK $TARGET

echo "*** $FILE repackaged as $TARGET"