source: trunk/debathena/scripts/dadch @ 22700

Revision 22700, 1.4 KB checked in by ghudson, 14 years ago (diff)
Allow apt repository location to be specified with $DEBATHENA_APT. The default value is the old hardcoded location /mit/debathena/apt. * debathena/scripts/dadch, debathena/scripts/daequivsupload, debathena/scripts/daupload-release: Set default value of $DEBATHENA_APT and use it in place ot /mit/debathena/apt.
  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3# Usage: dadch
4
5# Wrapper around dch for Debathena.  Increments the version number
6# according to Debathena rules if the current version has been
7# released, and leaves it alone otherwise.
8
9: ${DEBATHENA_APT=/mit/debathena/apt}
10
11if [ -e debian/changelog ]; then
12    debian=debian
13elif [ "$(basename "$PWD")" = debian ] && [ -e changelog ]; then
14    debian=.
15else
16    echo "Cannot find debian/changelog." >&2
17    exit 1
18fi
19
20package=$(head -n1 "$debian/changelog" | sed -n 's/^\([^ ]*\).*$/\1/ p')
21version=$(head -n1 "$debian/changelog" | sed -n 's/^[^ ]* (\([^)]*\)).*$/\1/ p')
22if [ -z "$package" ] || [ -z "$version" ]; then
23    echo "Invalid debian/changelog." >&2
24fi
25
26dch_opts=()
27
28newversion=$(
29    newversion=$version
30    dpkg-awk -f <(zcat ${DEBATHENA_APT}*/dists/*/*/source/Sources.gz) \
31        'Package:^'"$package"'$' -- Version | \
32        sed -n 's/Version: // p' | \
33        (
34            while read aptversion; do
35                if dpkg --compare-versions "$aptversion" '>=' "$newversion"; then
36                    newversion=$(
37                        echo "$aptversion" | \
38                            sed -n 's/debathena\([0-9]*\)/ \1/ p' | \
39                            (
40                                if read -r base darelease; then
41                                    echo "${base}debathena$(($darelease + 1))"
42                                else
43                                    echo "${aptversion}debathena1"
44                                fi
45                            )
46                    )
47                fi
48            done
49            echo "$newversion"
50        )
51)
52
53if [ "$newversion" != "$version" ]; then
54    echo "Changing version to $newversion"
55    dch_opts+=(--newversion "$newversion" --distribution unstable)
56fi
57
58dch "${dch_opts[@]}" "$@"
Note: See TracBrowser for help on using the repository browser.