source: trunk/debathena/scripts/dadch @ 22687

Revision 22687, 1.2 KB checked in by ghudson, 16 years ago (diff)
Snapshot scripts from /mit/debathena/bin and /mit/debathena/machines/awesome-build-server.
  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3if [ -e debian/changelog ]; then
4    debian=debian
5elif [ "$(basename "$PWD")" = debian ] && [ -e changelog ]; then
6    debian=.
7else
8    echo "Cannot find debian/changelog." >&2
9    exit 1
10fi
11
12package=$(head -n1 "$debian/changelog" | sed -n 's/^\([^ ]*\).*$/\1/ p')
13version=$(head -n1 "$debian/changelog" | sed -n 's/^[^ ]* (\([^)]*\)).*$/\1/ p')
14if [ -z "$package" ] || [ -z "$version" ]; then
15    echo "Invalid debian/changelog." >&2
16fi
17
18dch_opts=()
19
20newversion=$(
21    newversion=$version
22    dpkg-awk -f <(zcat /mit/debathena/apt*/dists/*/*/source/Sources.gz) \
23        'Package:^'"$package"'$' -- Version | \
24        sed -n 's/Version: // p' | \
25        (
26            while read aptversion; do
27                if dpkg --compare-versions "$aptversion" '>=' "$newversion"; then
28                    newversion=$(
29                        echo "$aptversion" | \
30                            sed -n 's/debathena\([0-9]*\)/ \1/ p' | \
31                            (
32                                if read -r base darelease; then
33                                    echo "${base}debathena$(($darelease + 1))"
34                                else
35                                    echo "${aptversion}debathena1"
36                                fi
37                            )
38                    )
39                fi
40            done
41            echo "$newversion"
42        )
43)
44
45if [ "$newversion" != "$version" ]; then
46    echo "Changing version to $newversion"
47    dch_opts+=(--newversion "$newversion" --distribution unstable)
48fi
49
50dch "${dch_opts[@]}" "$@"
Note: See TracBrowser for help on using the repository browser.