[22790] | 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 | |
---|
| 21 | set -e |
---|
| 22 | |
---|
| 23 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
| 24 | |
---|
[23042] | 25 | # Process arguments. |
---|
| 26 | dist_arch=$1; shift |
---|
| 27 | a= |
---|
| 28 | if [ "$1" = "-A" ]; then a=-A; shift; fi |
---|
| 29 | chroot=$dist_arch-sbuild |
---|
| 30 | |
---|
| 31 | if [ -z "$dist_arch" -o $# -eq 0 ]; then |
---|
| 32 | echo 'No arguments!' >&2 |
---|
| 33 | exit 2 |
---|
| 34 | fi |
---|
| 35 | |
---|
| 36 | dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/') |
---|
| 37 | arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/') |
---|
[23736] | 38 | : ${release=-proposed} |
---|
[23759] | 39 | . /mit/debathena/bin/debian-versions.sh |
---|
| 40 | tag=$(gettag $dist) |
---|
[23042] | 41 | |
---|
| 42 | # Create a chroot and define functions for using it. |
---|
| 43 | sid=$(schroot -b -c "$chroot") |
---|
| 44 | trap 'schroot -e -c "$sid"' EXIT |
---|
| 45 | sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot |
---|
| 46 | schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly |
---|
| 47 | schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root |
---|
[23117] | 48 | schr apt-get -qq -y update || exit 3 |
---|
[23042] | 49 | |
---|
[23761] | 50 | quote() { |
---|
| 51 | echo "$1" | sed 's/[^[:alnum:]]/\\&/g' |
---|
| 52 | } |
---|
| 53 | |
---|
[22790] | 54 | name=cyrus-sasl2-mit |
---|
| 55 | daversionappend=$(dpkg-parsechangelog -l$(dirname "$0")/debian/changelog | |
---|
| 56 | sed -nre 's/Version: .*(debathena.*)$/\1/p') |
---|
| 57 | |
---|
| 58 | cmd_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 |
---|
[23042] | 65 | sch apt-get -d source cyrus-sasl2 |
---|
[22790] | 66 | fi |
---|
| 67 | |
---|
| 68 | if [ ! -e "${name}_$daversion.dsc" ]; then |
---|
| 69 | ( |
---|
[23042] | 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" |
---|
[22790] | 81 | cd "$tmpdir/$name-$origversion" |
---|
[23042] | 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" |
---|
[22790] | 87 | ) |
---|
| 88 | fi |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | cmd_binary () { |
---|
| 92 | sbuildhack "$dist_arch" $a "${name}_$daversion.dsc" |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | v() { |
---|
| 96 | echo "$@" |
---|
| 97 | "$@" |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | cmd_upload () { |
---|
[23763] | 101 | REPREPRO="v reprepro -Vb $DEBATHENA_APT --ignore=wrongdistribution" |
---|
[23762] | 102 | REPREPROI="$REPREPRO --ignore=missingfield" |
---|
[22934] | 103 | |
---|
[22790] | 104 | if [ "$a" = "-A" ]; then |
---|
[23580] | 105 | $REPREPROI include "${dist}${release}" "${name}_${daversion}_source.changes" |
---|
[22790] | 106 | fi |
---|
[23580] | 107 | $REPREPRO include "${dist}${release}" "${name}_${daversion}${tag}_${arch}.changes" |
---|
[22790] | 108 | } |
---|
| 109 | |
---|
| 110 | case $dist in |
---|
| 111 | sarge|dapper|edgy) |
---|
| 112 | echo "Native libsasl2-krb4-mit package exists; skipping $dist_arch." >&2 |
---|
| 113 | exit |
---|
[22991] | 114 | ;; |
---|
[22790] | 115 | esac |
---|
| 116 | |
---|
| 117 | version=$( |
---|
[23042] | 118 | sch apt-cache showsrc cyrus-sasl2 | \ |
---|
[22790] | 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 | ) |
---|
| 133 | origversion=$(echo "$version" | sed 's/-[^-]*$//') |
---|
| 134 | daversion=$origversion-0$daversionappend |
---|
| 135 | |
---|
[23042] | 136 | if zcat "$DEBATHENA_APT/dists/$dist/debathena/binary-$arch/Packages.gz" | \ |
---|
[23761] | 137 | dpkg-awk -f - "Source:^$name\$" "Version:^$(quote "$daversion$tag")\$" -- Architecture | \ |
---|
[22790] | 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 |
---|
| 142 | fi |
---|
| 143 | |
---|
| 144 | for cmd; do |
---|
| 145 | "cmd_$cmd" |
---|
| 146 | done |
---|