blob: 8daf673027a3b66853b669764c8ce7938d5e7fee (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/sh
set -e
if [ "$1" = "-o" ]
then
shift
dest="$1"
shift
else
dest="."
fi
until [ -z "$1" ]
do
case "$1" in
*)
DIRS="$DIRS $1"
;;
esac
shift
done
if [ -z "$DIRS" ]
then
cat <<__END__
Usage: $0 [-o output/] [dir ...]
Expects directories containing the contents of the debian/ directory of a
Debian source package (i.e. control, changelog, watch, ...). Uses the watch
file to retrieve the upstream tarball (unless it already exists in the local
directory), creates a debian.tar.xz tarball from the given directory (ignoring
the ususal suspects like _darcs and *~) and creates a corresponding .dsc file;
all without unpacking the upstream tarball.
__END__
exit 1
fi
for DIR in $DIRS
do
if [ ! -e $DIR/control -o ! -e $DIR/changelog ]
then
echo "Did not find $DIR/control or $DIR/changelog."
echo "Is the repository in the debian/-only format?"
exit 1
fi
VERSION=`dpkg-parsechangelog -l$DIR/changelog -c1 -SVersion`
PACKAGE=`dpkg-parsechangelog -l$DIR/changelog -c1 -SSource`
UPSTREAM=`echo $VERSION | cut -d- -f1` # this could be improved
if echo $UPSTREAM | fgrep -q : ; then
UPSTREAM=`echo $UPSTREAM | cut -d: -f2-`
VERSION=`echo $VERSION | cut -d: -f2-`
fi
TARBALL_GZ=$dest/${PACKAGE}_$UPSTREAM.orig.tar.gz
TARBALL_BZ2=$dest/${PACKAGE}_$UPSTREAM.orig.tar.bz2
TARBALL_XZ=$dest/${PACKAGE}_$UPSTREAM.orig.tar.xz
# see 375138 for why this doesn't work as well as it could. Fall back to apt-get source
# as a last resort.
[ ! -e $TARBALL_GZ -a ! -e $TARBALL_BZ2 -a ! -e $TARBALL_XZ ] && \
( uscan \
--rename \
--force-download \
--package "$PACKAGE" \
--download \
--watchfile $DIR/watch \
--copyright-file $DIR/copyright \
--download-version "$UPSTREAM" \
--upstream-version "$UPSTREAM" \
--destdir "$dest" \
--rename ||
( cd $dest ; apt-get source "$PACKAGE" --tar-only ) )
if [ ! -e $TARBALL_GZ -a ! -e $TARBALL_BZ2 -a ! -e $TARBALL_XZ ]
then
echo "Couldn't download tarball with uscan or apt-get source. See above for errors"
exit 1
fi
TARBALL=""
if [ -e $TARBALL_GZ ]
then
TARBALL="$TARBALL_GZ"
else
if [ -e $TARBALL_XZ ]
then
TARBALL="$TARBALL_XZ"
else
if [ -e $TARBALL_BZ2 ]
then
TARBALL="$TARBALL_BZ2"
else
echo "Unreachable code"
exit 1
fi
fi
fi
DEBIAN_TARBALL=$dest/${PACKAGE}_${VERSION}.debian.tar.xz
# -I line taken from "man dpkg-source"
tar --create \
--xz \
--transform s,^.,debian, \
--force-local \
--file $DEBIAN_TARBALL \
--directory $DIR \
"--exclude=*.a" "--exclude=*.la" "--exclude=*.o" "--exclude=*.so" "--exclude=.*.sw?" "--exclude=*/*~" "--exclude=,,*" "--exclude=.[#~]*" "--exclude=.arch-ids" "--exclude=.arch-inventory" "--exclude=.be" "--exclude=.bzr" "--exclude=.bzr.backup" "--exclude=.bzr.tags" "--exclude=.bzrignore" "--exclude=.cvsignore" "--exclude=.deps" "--exclude=.git" "--exclude=.gitattributes" "--exclude=.gitignore" "--exclude=.gitmodules" "--exclude=.hg" "--exclude=.hgignore" "--exclude=.hgsigs" "--exclude=.hgtags" "--exclude=.shelf" "--exclude=.svn" "--exclude=CVS" "--exclude=DEADJOE" "--exclude=RCS" "--exclude=_MTN" "--exclude=_darcs" "--exclude={arch}" \
.
# dpkg-source insists on cluttering the current directory
dpkg-source \
-c$DIR/control -l$DIR/changelog \
--format="3.0 (custom)" --target-format="3.0 (quilt)" \
-b / \
$DEBIAN_TARBALL \
$TARBALL
DSC=${PACKAGE}_${VERSION}.dsc
if [ -e $DSC ]
then
mv $DSC "$dest/$DSC"
echo "Successfully created $DSC."
else
echo "Failed to create $DSC."
fi
done
|