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 | |
---|
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/') |
---|
38 | |
---|
39 | # Create a chroot and define functions for using it. |
---|
40 | sid=$(schroot -b -c "$chroot") |
---|
41 | trap 'schroot -e -c "$sid"' EXIT |
---|
42 | sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot |
---|
43 | schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly |
---|
44 | schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root |
---|
45 | schr apt-get -qq -y update || exit 3 |
---|
46 | |
---|
47 | name=cyrus-sasl2-mit |
---|
48 | daversionappend=$(dpkg-parsechangelog -l$(dirname "$0")/debian/changelog | |
---|
49 | sed -nre 's/Version: .*(debathena.*)$/\1/p') |
---|
50 | |
---|
51 | cmd_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 | |
---|
84 | cmd_binary () { |
---|
85 | sbuildhack "$dist_arch" $a "${name}_$daversion.dsc" |
---|
86 | } |
---|
87 | |
---|
88 | v() { |
---|
89 | echo "$@" |
---|
90 | "$@" |
---|
91 | } |
---|
92 | |
---|
93 | cmd_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 | |
---|
106 | case $dist in |
---|
107 | sarge|dapper|edgy) |
---|
108 | echo "Native libsasl2-krb4-mit package exists; skipping $dist_arch." >&2 |
---|
109 | exit |
---|
110 | ;; |
---|
111 | esac |
---|
112 | |
---|
113 | version=$( |
---|
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 | ) |
---|
129 | origversion=$(echo "$version" | sed 's/-[^-]*$//') |
---|
130 | daversion=$origversion-0$daversionappend |
---|
131 | |
---|
132 | if 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 |
---|
138 | fi |
---|
139 | |
---|
140 | for cmd; do |
---|
141 | "cmd_$cmd" |
---|
142 | done |
---|