source: trunk/debathena/third/common/debathenificator.sh @ 22791

Revision 22791, 4.2 KB checked in by ghudson, 17 years ago (diff)
* debathena/third/common/debathenificator.sh: Make "./debathenify-foo source binary upload" work by returning rather than exiting when cmd_source decides not to act.
Line 
1# Interface: define variables name, daversionappend, and function
2# hack_package ().
3
4set -e
5
6: ${DEBATHENA_APT=/mit/debathena/apt}
7
8munge_sections () {
9    perl -0pe 's/^Section: /Section: debathena-system\//gm or die' -i debian/control
10}
11
12add_changelog () {
13    if [ -n "$dch_done" ]; then
14        dch "$@"
15    else
16        echo | dch -v"${daversion}" -D unstable "$@"
17        dch_done=1
18    fi
19}
20
21append_description () {
22    perl -0pe 'open THREE, "</dev/fd/3"; $x = <THREE>; s/(^Description:.*\n( .*\n)*)/$1$x/gm or die' -i debian/control 3<&0
23}
24
25add_build_depends () {
26    perl -0pe 's/^(Build-Depends:.*)$/$1, '"$1"'/m or die' -i debian/control
27}
28
29add_debathena_provides () {
30    perl -0pe 's/^(Package: (.*)\n(?:(?!Provides:).+\n)*)(?:Provides: (.*)\n((?:.+\n)*))?(?=\n|\z)/$1Provides: $3, debathena-$2\n$4/mg or die; s/^Provides: , /Provides: /mg' -i debian/control
31    add_changelog "Provide debathena-$name."
32}
33
34cmd_source () {
35    if [ "$a" != "-A" ]; then
36        echo "Not building source package for $dist_arch." >&2
37        return
38    fi
39    echo "Building source for $name-$daversion on $dist_arch" >&2
40   
41    if ! [ -e "${name}_$version.dsc" ]; then
42        schroot -c "$chroot" -- apt-get -d source "$name"
43    fi
44   
45    if ! [ -e "${name}_$daversion.dsc" ]; then
46        tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX")
47        trap 'rm -rf "$tmpdir"' EXIT
48        origversion=$(echo "$version" | sed 's/-[^-]*$//')
49        #echo "! [ -e '$tmpdir/${name}_$origversion.orig.tar.gz' ] || diff -u <(xxd '${name}_$origversion.orig.tar.gz') <(xxd '$tmpdir/${name}_$origversion.orig.tar.gz')" >| /tmp/wtf
50       
51        (
52            sid=$(schroot -b -c "$chroot")
53            trap 'schroot -e -c "$sid"' EXIT
54            set -x
55            cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/"
56            dpkg-source -x "${name}_$version.dsc" "$tmpdir/$name-$origversion"
57            cd "$tmpdir/$name-$origversion"
58            dch_done=
59            hack_package
60            [ -n "$dch_done" ]
61            schroot -r -c "$sid" -u root -- apt-get -q -y build-dep "$name"
62            schroot -r -c "$sid" -u root -- apt-get -q -y install devscripts
63            schroot -r -c "$sid" -- debuild -S -sa -us -uc -i -I.svn
64        )
65        [ $? -eq 0 ] || {
66            bash -c "diff -u <(xxd '${name}_$origversion.orig.tar.gz') <(xxd '$tmpdir/${name}_$origversion.orig.tar.gz')"
67            exit 1
68        }
69       
70        cp -a "$tmpdir/${name}_$daversion"* .
71        if [ -n "$DA_CHECK_DIFFS" ]; then
72            interdiff -z "${name}_$version.diff.gz" "${name}_$daversion.diff.gz" | \
73                enscript --color --language=ansi --highlight=diffu --output=- -q | \
74                less -R
75            echo -n "Press Enter to continue: " >&2
76            read dummy
77        fi
78    fi
79}
80
81cmd_binary () {
82    sbuildhack "$dist_arch" $a "${name}_$daversion.dsc"
83}
84
85v () {
86    echo "$@"
87    "$@"
88}
89
90cmd_upload () {
91    REPREPRO="v reprepro -Vb $DEBATHENA_APT"
92    REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield"
93   
94    case "$dist" in
95        sarge) tag='~debian3.1' ;;
96        etch) tag='~debian4.0' ;;
97        lenny) tag='~debian4.1~0.1' ;;
98        dapper) tag='~ubuntu6.06' ;;
99        edgy) tag='~ubuntu6.10' ;;
100        feisty) tag='~ubuntu7.04' ;;
101        gutsy) tag='~ubuntu7.10' ;;
102    esac
103   
104    if [ "$a" = "-A" ]; then
105        $REPREPROI include "$dist" "${name}_${daversion}_source.changes"
106    fi
107    $REPREPRO include "$dist" "${name}_${daversion}${tag}_${arch}.changes"
108}
109
110dist_arch=$1; shift
111a=
112if [ "$1" = "-A" ]; then a=-A; shift; fi
113chroot=$dist_arch-sbuild
114
115if [ -z "$dist_arch" -o $# -eq 0 ]; then
116    echo 'No arguments!' >&2
117    exit 2
118fi
119
120dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/')
121arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/')
122
123version=$(
124    schroot -q -c "$chroot" -- apt-cache showsrc "$name" | \
125        sed -n 's/^Version: \(.*\)$/\1/ p' | (
126        version='~~~'
127        while read -r newversion; do
128            if dpkg --compare-versions "$newversion" '>' "$version"; then
129                version=$newversion
130            fi
131        done
132        if [ "$version" = '~~~' ]; then
133            echo "No version of $name found." >&2
134            exit 1
135        fi
136        echo "$version"
137        )
138    )
139daversion=$version$daversionappend
140
141if zcat "$DEBATHENA_APT/dists/$dist/debathena-system/binary-$arch/Packages.gz" | \
142    dpkg-awk -f - "Source:^$name\$" "Version:^$daversion~" -- Architecture | \
143    if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi | \
144    grep -q .; then
145    echo "$name $daversion already exists for $dist_arch." >&2
146    exit 0
147fi
148
149for cmd; do
150    "cmd_$cmd"
151done
Note: See TracBrowser for help on using the repository browser.