]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/byhand-dm
Modified dak to use non-braindead DM schema, and use an actual column for
[dak.git] / scripts / debian / byhand-dm
1 #!/bin/sh -e
2
3 BYHAND="$1"
4 VERSION="$2"
5 ARCH="$3"
6 CHANGES="$4"
7
8 KEYRING=/srv/keyring.debian.org/keyrings/debian-keyring.gpg
9
10 DESTKR=/srv/ftp.debian.org/keyrings/debian-maintainers.gpg
11
12 get_id () {
13   echo "SELECT U.name, U.uid FROM fingerprint F JOIN uid U ON (F.uid = U.id) WHERE F.fingerprint = '$1';" |
14     psql projectb -At |
15     sed 's/|\(.*\)/ <\1@debian.org>/'
16 }
17
18 is_allowed () {
19   echo "SELECT M.name from src_uploaders U join source S on (U.source = S.id) join maintainer M on (U.maintainer = M.id) WHERE S.source = 'debian-maintainers';" |
20     psql projectb -At | 
21     while read ALLOWED; do
22       if [ "$1" = "$ALLOWED" ]; then
23         echo yes
24         break
25       fi
26     done
27 }
28
29 FPRINT=$(gpgv --keyring "$KEYRING" --status-fd 3 3>&1 >/dev/null 2>&1 "$CHANGES" |
30     cut -d\  -f2,3 | grep ^VALIDSIG | head -n1 | cut -d\  -f2)
31
32 ID="$(get_id "$FPRINT")"
33
34 if [ "$(is_allowed "$ID")" != "yes" ]; then
35   echo "Unauthorised upload by $ID"
36   exit 1
37 fi
38
39 echo "Authorised upload by $ID, copying into place"
40
41 OUT=$(mktemp)
42
43 cp "$BYHAND" "$DESTKR"
44 dak import-keyring -D --generate-users "%s" "$DESTKR" >$OUT
45
46 if [ -s "$OUT" ]; then
47   /usr/sbin/sendmail -odq -oi -t <<EOF
48 From: $ID
49 To: <debian-project@lists.debian.org>
50 Subject: Updated Debian Maintainers Keyring
51 Content-Type: text/plain; charset=utf-8
52 MIME-Version: 1.0
53
54 With the upload of debian-maintainers version $VERSION, the following
55 changes to the keyring have been made:
56
57 $(cat $OUT)
58
59 A summary of all the changes in this upload follows.
60
61 Debian distribution maintenance software,
62 on behalf of,
63 $ID
64
65 $(cat $CHANGES)
66 EOF
67 fi
68 rm -f "$OUT"
69
70 exit 0