-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdadch
executable file
·58 lines (49 loc) · 1.44 KB
/
dadch
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
#!/bin/bash
# Usage: dadch
# Wrapper around dch for Debathena. Increments the version number
# according to Debathena rules if the current version has been
# released, and leaves it alone otherwise.
: ${DEBATHENA_APT=/mit/debathena/apt}
if [ -e debian/changelog ]; then
debian=debian
elif [ "$(basename "$PWD")" = debian ] && [ -e changelog ]; then
debian=.
else
echo "Cannot find debian/changelog." >&2
exit 1
fi
package=$(head -n1 "$debian/changelog" | sed -n 's/^\([^ ]*\).*$/\1/ p')
version=$(head -n1 "$debian/changelog" | sed -n 's/^[^ ]* (\([^)]*\)).*$/\1/ p')
if [ -z "$package" ] || [ -z "$version" ]; then
echo "Invalid debian/changelog." >&2
fi
dch_opts=()
newversion=$(
newversion=$version
dpkg-awk -f <(zcat ${DEBATHENA_APT}*/dists/*/*/source/Sources.gz) \
'Package:^'"$package"'$' -- Version | \
sed -n 's/Version: // p' | \
(
while read aptversion; do
if dpkg --compare-versions "$aptversion" '>=' "$newversion"; then
newversion=$(
echo "$aptversion" | \
sed -n 's/debathena\([0-9]*\)/ \1/ p' | \
(
if read -r base darelease; then
echo "${base}debathena$(($darelease + 1))"
else
echo "${aptversion}debathena1"
fi
)
)
fi
done
echo "$newversion"
)
)
if [ "$newversion" != "$version" ]; then
echo "Changing version to $newversion"
dch_opts+=(--newversion "$newversion" --distribution unstable)
fi
dch "${dch_opts[@]}" "$@"