blob: 8890c68a2c8eb61ffa4c64f63523d387d95d3d3a (
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
|
#!/bin/bash
set -e
set -u
if [ "${1:-}" == "--binary-only" ]; then
BINARY_ARCH="--binary-arch"
BINARCH=1
shift
else
BINARCH=0
fi
if ! which grep-dctrl > /dev/null; then
echo "grep-dctrl not found. Maybe install dctrl-tools?"
exit 1
fi
if ! which changestool > /dev/null; then
echo "changestool not found. Maybe install reprepro?"
exit 1
fi
get_metadata() {
local dsc="$1"; shift
dsc="$(readlink -f "$dsc")"
local origtar="$(dcmd --orig $dsc)"
if ! [ -e "$origtar" ]; then
echo >&2 "File $origtar not found"
exit 1
fi
local dirname="$(tar tzf $origtar | head -n1)"
dirname="${dirname%%/}"
local tmpdir="`mktemp -d`"
pushd . >/dev/null
cd "$tmpdir"
dpkg-source -x "$dsc" > /dev/null
cd "$dirname"
local dist=$(dpkg-parsechangelog | grep-dctrl -n -s Distribution '')
local ver=$(dpkg-parsechangelog | grep-dctrl -n -s Version '')
popd >/dev/null
rm -rf "$tmpdir"
echo "$dist $ver"
}
DSC="${1:-}"; shift
if [ -z "$DSC" ] || [ -z "$BINARCH" ]; then
echo "Usage: $0 [--binary-arch] <foo.dsc>" >&2
exit 1;
fi
metadata="$(get_metadata "$DSC")"
read dscdist debian_version <<< "$metadata"
if [ -z "${DIST:-}" ]; then
DIST=sid
for d in lenny squeeze wheezy dapper hardy karmic lucid maverick natty oneiric; do
if echo $debian_version | grep -q "$d" ; then
DIST="$d"
break
fi
done
fi
if [ -z "${ARCH:-}" ]; then
if [ "`uname -m`" = "x86_64" ]; then
ARCH="amd64"
elif [ "`uname -m`" = "i386" ] || [ "`uname -m`" = "i686" ]; then
ARCH="i386"
else
echo >&2 "Do not know arch"
exit 1
fi
fi
if [ "$BINARCH" = 1 ]; then
extra="${EXTRA_ARGS:-}"
else
extra="${EXTRA_ARGS:-} -s --arch-all"
fi
sbuild --arch="$ARCH" --dist="$DIST" --apt-update $extra "$DSC"
changesfile="${DSC%.dsc}_$ARCH.changes"
if ! [ -e "$changesfile" ]; then
echo >&2 "Expected file $changesfile does not exist"
exit 1
fi
changestool "$changesfile" setdistribution "$dscdist"
|