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

Revision 23736, 4.2 KB checked in by broder, 15 years ago (diff)
/Never/ automatically upload to production in the debathenificator.
  • 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: ${release=-proposed}
39
40# Create a chroot and define functions for using it.
41sid=$(schroot -b -c "$chroot")
42trap 'schroot -e -c "$sid"' EXIT
43sch() { schroot -r -c "$sid" -- "$@"; }           # Run in the chroot
44schq() { schroot -q -r -c "$sid" -- "$@"; }       # Run in the chroot quietly
45schr() { schroot -r -c "$sid" -u root -- "$@"; }  # Run in the chroot as root
46schr apt-get -qq -y update || exit 3
47
48name=cyrus-sasl2-mit
49daversionappend=$(dpkg-parsechangelog -l$(dirname "$0")/debian/changelog |
50  sed -nre 's/Version: .*(debathena.*)$/\1/p')
51
52cmd_source() {
53  if [ "$a" != "-A" ]; then
54    echo "Not building source package for $dist_arch." >&2
55    return
56  fi
57
58  if [ ! -e "cyrus-sasl2_$version.dsc" ]; then
59    sch apt-get -d source cyrus-sasl2
60  fi
61
62  if [ ! -e "${name}_$daversion.dsc" ]; then
63    (
64      tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX")
65      trap 'rm -rf "$tmpdir"' EXIT
66      pkgdir=$tmpdir/$name-$origversion
67      mkdir "$pkgdir"
68      cp -a $(dirname "$0")/debian "$pkgdir"
69      cp -a "cyrus-sasl2_$origversion.orig.tar.gz" "$pkgdir"
70      here=$(pwd)
71      (cd $tmpdir && tar czf "${name}_$origversion.orig.tar.gz" \
72        "$name-$origversion/cyrus-sasl2_$origversion.orig.tar.gz")
73      perl -0pe "s/\@TARDIR\@/cyrus-sasl-$origversion/m or die" \
74        -i "$pkgdir/debian/rules"
75      cd "$tmpdir/$name-$origversion"
76      schr apt-get -q -y build-dep cyrus-sasl2
77      schr apt-get -q -y install dbs devscripts
78      sch debuild -S -sa -us -uc -i -I.svn
79      cp -a "$tmpdir/${name}_$daversion"* "$here"
80      cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$here"
81    )
82  fi
83}
84
85cmd_binary () {
86  sbuildhack "$dist_arch" $a "${name}_$daversion.dsc"
87}
88
89v() {
90    echo "$@"
91    "$@"
92}
93
94cmd_upload () {
95  REPREPRO="v reprepro -Vb $DEBATHENA_APT"
96  REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield"
97
98  . /mit/debathena/bin/debian-versions.sh
99  tag=$(gettag $dist)
100
101  if [ "$a" = "-A" ]; then
102    $REPREPROI include "${dist}${release}" "${name}_${daversion}_source.changes"
103  fi
104  $REPREPRO include "${dist}${release}" "${name}_${daversion}${tag}_${arch}.changes"
105}
106
107case $dist in
108sarge|dapper|edgy)
109  echo "Native libsasl2-krb4-mit package exists; skipping $dist_arch." >&2
110  exit
111  ;;
112esac
113
114version=$(
115  sch apt-cache showsrc cyrus-sasl2 | \
116    sed -n 's/^Version: \(.*\)$/\1/ p' | (
117      version='~~~'
118      while read -r newversion; do
119        if dpkg --compare-versions "$newversion" '>' "$version"; then
120          version=$newversion
121        fi
122      done
123      if [ "$version" = '~~~' ]; then
124        echo "No version of $name found." >&2
125        exit 1
126      fi
127      echo "$version"
128    )
129)
130origversion=$(echo "$version" | sed 's/-[^-]*$//')
131daversion=$origversion-0$daversionappend
132
133if zcat "$DEBATHENA_APT/dists/$dist/debathena/binary-$arch/Packages.gz" | \
134  dpkg-awk -f - "Source:^$name\$" "Version:^$daversion~" -- Architecture | \
135  if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi | \
136  grep -q .; then
137  echo "$name $daversion already exists for $dist_arch." >&2
138  exit 0
139fi
140
141for cmd; do
142  "cmd_$cmd"
143done
Note: See TracBrowser for help on using the repository browser.