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 | name=cyrus-sasl2-mit |
---|
26 | daversionappend=$(dpkg-parsechangelog -l$(dirname "$0")/debian/changelog | |
---|
27 | sed -nre 's/Version: .*(debathena.*)$/\1/p') |
---|
28 | |
---|
29 | cmd_source() { |
---|
30 | if [ "$a" != "-A" ]; then |
---|
31 | echo "Not building source package for $dist_arch." >&2 |
---|
32 | return |
---|
33 | fi |
---|
34 | |
---|
35 | if [ ! -e "cyrus-sasl2_$version.dsc" ]; then |
---|
36 | schroot -c "$chroot" -- apt-get -d source cyrus-sasl2 |
---|
37 | fi |
---|
38 | |
---|
39 | if [ ! -e "${name}_$daversion.dsc" ]; then |
---|
40 | tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX") |
---|
41 | trap 'rm -rf "$tmpdir"' EXIT |
---|
42 | pkgdir=$tmpdir/$name-$origversion |
---|
43 | mkdir "$pkgdir" |
---|
44 | cp -a $(dirname "$0")/debian "$pkgdir" |
---|
45 | cp -a "cyrus-sasl2_$origversion.orig.tar.gz" "$pkgdir" |
---|
46 | (cd $tmpdir && tar czf "${name}_$origversion.orig.tar.gz" \ |
---|
47 | "$name-$origversion/cyrus-sasl2_$origversion.orig.tar.gz") |
---|
48 | perl -0pe "s/\@TARDIR\@/cyrus-sasl-$origversion/m or die" \ |
---|
49 | -i "$pkgdir/debian/rules" |
---|
50 | ( |
---|
51 | sid=$(schroot -b -c "$chroot") |
---|
52 | trap 'schroot -e -c "$sid"' EXIT |
---|
53 | set -x |
---|
54 | cd "$tmpdir/$name-$origversion" |
---|
55 | schroot -r -c "$sid" -u root -- apt-get -q -y build-dep cyrus-sasl2 |
---|
56 | schroot -r -c "$sid" -u root -- apt-get -q -y install dbs |
---|
57 | schroot -r -c "$sid" -u root -- apt-get -q -y install devscripts |
---|
58 | schroot -r -c "$sid" -- debuild -S -sa -us -uc -i -I.svn |
---|
59 | ) |
---|
60 | cp -a "$tmpdir/${name}_$daversion"* . |
---|
61 | cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" . |
---|
62 | fi |
---|
63 | } |
---|
64 | |
---|
65 | cmd_binary () { |
---|
66 | sbuildhack "$dist_arch" $a "${name}_$daversion.dsc" |
---|
67 | } |
---|
68 | |
---|
69 | v() { |
---|
70 | echo "$@" |
---|
71 | "$@" |
---|
72 | } |
---|
73 | |
---|
74 | cmd_upload () { |
---|
75 | REPREPRO="v reprepro -Vb $DEBATHENA_APT" |
---|
76 | REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield" |
---|
77 | |
---|
78 | . /mit/debathena/bin/debian-versions.sh |
---|
79 | tag=$(gettag $dist) |
---|
80 | |
---|
81 | if [ "$a" = "-A" ]; then |
---|
82 | $REPREPROI include "$dist" "${name}_${daversion}_source.changes" |
---|
83 | fi |
---|
84 | $REPREPRO include "$dist" "${name}_${daversion}${tag}_${arch}.changes" |
---|
85 | } |
---|
86 | |
---|
87 | dist_arch=$1; shift |
---|
88 | a= |
---|
89 | if [ "$1" = "-A" ]; then a=-A; shift; fi |
---|
90 | chroot=$dist_arch-sbuild |
---|
91 | |
---|
92 | if [ -z "$dist_arch" -o $# -eq 0 ]; then |
---|
93 | echo 'No arguments!' >&2 |
---|
94 | exit 2 |
---|
95 | fi |
---|
96 | |
---|
97 | dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/') |
---|
98 | arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/') |
---|
99 | |
---|
100 | case $dist in |
---|
101 | sarge|dapper|edgy) |
---|
102 | echo "Native libsasl2-krb4-mit package exists; skipping $dist_arch." >&2 |
---|
103 | exit |
---|
104 | ;; |
---|
105 | esac |
---|
106 | |
---|
107 | version=$( |
---|
108 | schroot -q -c "$chroot" -- apt-cache showsrc cyrus-sasl2 | \ |
---|
109 | sed -n 's/^Version: \(.*\)$/\1/ p' | ( |
---|
110 | version='~~~' |
---|
111 | while read -r newversion; do |
---|
112 | if dpkg --compare-versions "$newversion" '>' "$version"; then |
---|
113 | version=$newversion |
---|
114 | fi |
---|
115 | done |
---|
116 | if [ "$version" = '~~~' ]; then |
---|
117 | echo "No version of $name found." >&2 |
---|
118 | exit 1 |
---|
119 | fi |
---|
120 | echo "$version" |
---|
121 | ) |
---|
122 | ) |
---|
123 | origversion=$(echo "$version" | sed 's/-[^-]*$//') |
---|
124 | daversion=$origversion-0$daversionappend |
---|
125 | |
---|
126 | if zcat "$DEBATHENA_APT/dists/$dist/debathena-system/binary-$arch/Packages.gz" | \ |
---|
127 | dpkg-awk -f - "Source:^$name\$" "Version:^$daversion~" -- Architecture | \ |
---|
128 | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi | \ |
---|
129 | grep -q .; then |
---|
130 | echo "$name $daversion already exists for $dist_arch." >&2 |
---|
131 | exit 0 |
---|
132 | fi |
---|
133 | |
---|
134 | for cmd; do |
---|
135 | "cmd_$cmd" |
---|
136 | done |
---|