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

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