source: trunk/debathena/third/cyrus-sasl2-mit/debathenify-cyrus-sasl2-mit @ 23117

Revision 23117, 4.1 KB checked in by ghudson, 16 years ago (diff)
In debathenificator and the standalone debathenify scripts, exit with status 3 if "apt-get update" fails in the chroot. This will allow autodebathenify to distinguish the most common transient failure case from actual build failures. It's not perfect; if apt-get update fails inside sbuild we'll still exit with status 1.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3# This script follows the interface of debathenificator scripts but
4# does not itself use debathenificator because what we need to do
5# doesn't fit the model.  Most of the code here is copied from
6# debathenificator, but:
7#
8# 1. We don't do anything on platforms which already have a usable
9#    version of cyrus-sasl2-mit.
10#
11# 2. The version check is modified to check the native version of
12#    cybus-sasl2 (which we want to match) rather than cyrus-sasl2-mit
13#    (which does not exist on most of the platforms we want to build
14#    for).
15#
16# 3. cmd_source creates the source package by combining the tarfile
17#    from the native cyrus-sasl2 package with the packaging materials
18#    stored here (which are based on the now-defunct cyrus-sasl2-mit
19#    but are heavily modified).
20
21set -e
22
23: ${DEBATHENA_APT=/mit/debathena/apt}
24
25# Process arguments.
26dist_arch=$1; shift
27a=
28if [ "$1" = "-A" ]; then a=-A; shift; fi
29chroot=$dist_arch-sbuild
30
31if [ -z "$dist_arch" -o $# -eq 0 ]; then
32  echo 'No arguments!' >&2
33  exit 2
34fi
35
36dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/')
37arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/')
38
39# Create a chroot and define functions for using it.
40sid=$(schroot -b -c "$chroot")
41trap 'schroot -e -c "$sid"' EXIT
42sch() { schroot -r -c "$sid" -- "$@"; }           # Run in the chroot
43schq() { schroot -q -r -c "$sid" -- "$@"; }       # Run in the chroot quietly
44schr() { schroot -r -c "$sid" -u root -- "$@"; }  # Run in the chroot as root
45schr apt-get -qq -y update || exit 3
46
47name=cyrus-sasl2-mit
48daversionappend=$(dpkg-parsechangelog -l$(dirname "$0")/debian/changelog |
49  sed -nre 's/Version: .*(debathena.*)$/\1/p')
50
51cmd_source() {
52  if [ "$a" != "-A" ]; then
53    echo "Not building source package for $dist_arch." >&2
54    return
55  fi
56
57  if [ ! -e "cyrus-sasl2_$version.dsc" ]; then
58    sch apt-get -d source cyrus-sasl2
59  fi
60
61  if [ ! -e "${name}_$daversion.dsc" ]; then
62    (
63      tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX")
64      trap 'rm -rf "$tmpdir"' EXIT
65      pkgdir=$tmpdir/$name-$origversion
66      mkdir "$pkgdir"
67      cp -a $(dirname "$0")/debian "$pkgdir"
68      cp -a "cyrus-sasl2_$origversion.orig.tar.gz" "$pkgdir"
69      here=$(pwd)
70      (cd $tmpdir && tar czf "${name}_$origversion.orig.tar.gz" \
71        "$name-$origversion/cyrus-sasl2_$origversion.orig.tar.gz")
72      perl -0pe "s/\@TARDIR\@/cyrus-sasl-$origversion/m or die" \
73        -i "$pkgdir/debian/rules"
74      cd "$tmpdir/$name-$origversion"
75      schr apt-get -q -y build-dep cyrus-sasl2
76      schr apt-get -q -y install dbs devscripts
77      sch debuild -S -sa -us -uc -i -I.svn
78      cp -a "$tmpdir/${name}_$daversion"* "$here"
79      cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$here"
80    )
81  fi
82}
83
84cmd_binary () {
85  sbuildhack "$dist_arch" $a "${name}_$daversion.dsc"
86}
87
88v() {
89    echo "$@"
90    "$@"
91}
92
93cmd_upload () {
94  REPREPRO="v reprepro -Vb $DEBATHENA_APT"
95  REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield"
96
97  . /mit/debathena/bin/debian-versions.sh
98  tag=$(gettag $dist)
99
100  if [ "$a" = "-A" ]; then
101    $REPREPROI include "$dist" "${name}_${daversion}_source.changes"
102  fi
103  $REPREPRO include "$dist" "${name}_${daversion}${tag}_${arch}.changes"
104}
105
106case $dist in
107sarge|dapper|edgy)
108  echo "Native libsasl2-krb4-mit package exists; skipping $dist_arch." >&2
109  exit
110  ;;
111esac
112
113version=$(
114  sch apt-cache showsrc cyrus-sasl2 | \
115    sed -n 's/^Version: \(.*\)$/\1/ p' | (
116      version='~~~'
117      while read -r newversion; do
118        if dpkg --compare-versions "$newversion" '>' "$version"; then
119          version=$newversion
120        fi
121      done
122      if [ "$version" = '~~~' ]; then
123        echo "No version of $name found." >&2
124        exit 1
125      fi
126      echo "$version"
127    )
128)
129origversion=$(echo "$version" | sed 's/-[^-]*$//')
130daversion=$origversion-0$daversionappend
131
132if zcat "$DEBATHENA_APT/dists/$dist/debathena/binary-$arch/Packages.gz" | \
133  dpkg-awk -f - "Source:^$name\$" "Version:^$daversion~" -- Architecture | \
134  if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi | \
135  grep -q .; then
136  echo "$name $daversion already exists for $dist_arch." >&2
137  exit 0
138fi
139
140for cmd; do
141  "cmd_$cmd"
142done
Note: See TracBrowser for help on using the repository browser.