3 # who-uploads sourcepkg [ sourcepkg ... ]
4 # Tells you who made the latest uploads of a source package.
5 # NB: I'm encoded in UTF-8!!
7 # Written and copyright 2006 by Julian Gilbey <jdg@debian.org>
8 # Based on an original script
9 # copyright 2006 Adeodato Simó <dato@net.com.org.es>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 PROGNAME=`basename $0`
25 MODIFIED_CONF_MSG='Default settings modified by devscripts configuration files:'
29 "Usage: $PROGNAME [options] package ...
30 Display the most recent three uploaders of each package.
31 Packages should be source packages, not binary packages.
35 Display at most the N most recent uploads (default: 3)
36 --keyring KEYRING Add KEYRING as a GPG keyring for Debian Developers'
37 keys in addition to /usr/share/keyrings/debian-keyring.*
38 and /usr/share/keyrings/debian-maintainers.gpg;
39 this option may be given multiple times
41 Do not use the default keyrings
43 Don't read devscripts config files;
44 must be the first option given
45 --date Display the date of the upload
47 Don't display the date of the upload (default)
48 --help Show this message
49 --version Show version and copyright information
56 "This is $PROGNAME, from the Debian devscripts package, version ###VERSION###
57 This code is copyright 2006 by Julian Gilbey <jdg@debian.org>,
59 Based on original code copyright 2006 Adeodato Simó <dato@net.com.org.es>
60 This program comes with ABSOLUTELY NO WARRANTY.
61 You are free to redistribute this code under the terms of the
62 GNU General Public License, version 2 or later."
66 # Boilerplate: set config variables
67 DEFAULT_WHOUPLOADS_KEYRINGS=/usr/share/keyrings/debian-keyring.gpg:/usr/share/keyrings/debian-keyring.pgp:/usr/share/keyrings/debian-maintainers.gpg
68 DEFAULT_WHOUPLOADS_MAXUPLOADS=3
69 DEFAULT_WHOUPLOADS_DATE=no
70 VARS="WHOUPLOADS_KEYRINGS WHOUPLOADS_MAXUPLOADS WHOUPLOADS_DATE"
72 if [ "$1" = "--no-conf" -o "$1" = "--noconf" ]; then
74 MODIFIED_CONF_MSG="$MODIFIED_CONF_MSG
75 (no configuration files read)"
79 eval "$var=\$DEFAULT_$var"
82 # Run in a subshell for protection against accidental errors
87 eval "$var=\$DEFAULT_$var"
90 for file in /etc/devscripts.conf ~/.devscripts
92 [ -r $file ] && . $file
95 set | grep "^WHOUPLOADS_")
98 if [ "$WHOUPLOADS_MAXUPLOADS" != \
99 "$(echo \"$WHOUPLOADS_MAXUPLOADS\" | tr -cd 0-9)" ]; then
100 WHOUPLOADS_MAXUPLOADS=3
103 WHOUPLOADS_DATE="$(echo "$WHOUPLOADS_DATE" | tr A-Z a-z)"
104 if [ "$WHOUPLOADS_DATE" != "yes" ] && [ "$WHOUPLOADS_DATE" != "no" ]; then
108 # don't check WHOUPLOADS_KEYRINGS here
113 eval "if [ \"\$$var\" != \"\$DEFAULT_$var\" ]; then
114 MODIFIED_CONF_MSG=\"\$MODIFIED_CONF_MSG
120 if [ -z "$MODIFIED_CONF" ]; then
121 MODIFIED_CONF_MSG="$MODIFIED_CONF_MSG
126 MAXUPLOADS=$WHOUPLOADS_MAXUPLOADS
127 WANT_DATE=$WHOUPLOADS_DATE
131 declare -a GPG_DEFAULT_KEYRINGS
133 for keyring in $WHOUPLOADS_KEYRINGS; do
134 if [ -f "$keyring" ]; then
135 GPG_DEFAULT_KEYRINGS=("${GPG_DEFAULT_KEYRINGS[@]}" "--keyring" "$keyring")
136 elif [ -n "$keyring" ]; then
137 echo "Could not find keyring $keyring, skipping it" >&2
142 declare -a GPG_KEYRINGS
144 # Command-line options
145 TEMP=$(getopt -s bash -o 'h' \
146 --long max-uploads:,keyring:,no-default-keyrings \
147 --long no-conf,noconf \
148 --long date,nodate,no-date \
149 --long help,version \
151 -n "$PROGNAME" -- "$@")
152 if [ $? != 0 ] ; then exit 1 ; fi
161 if [ "$1" = "$(echo \"$1\" | tr -cd 0-9)" ]; then
168 GPG_KEYRINGS=("${GPG_KEYRINGS[@]}" "--keyring" "$1")
170 echo "Could not find keyring $1, skipping" >&2
173 --no-default-keyrings)
174 GPG_DEFAULT_KEYRINGS=( ) ;;
176 echo "$PROGNAME: $1 is only acceptable as the first command-line option!" >&2
178 --date) WANT_DATE=yes ;;
179 --no-date|--nodate) WANT_DATE=no ;;
180 --help|-h) usage; exit 0 ;;
181 --version) version; exit 0 ;;
183 *) echo "$PROGNAME: bug in option parser, sorry!" >&2 ; exit 1 ;;
188 # Some useful abbreviations for gpg options
189 GPG_NO_KEYRING="--no-options --no-auto-check-trustdb --no-default-keyring --keyring /dev/null"
190 GPG_OPTIONS="--no-options --no-auto-check-trustdb --no-default-keyring"
192 if [ $# -eq 0 ]; then
197 # Now actually get the reports :)
200 echo "Uploads for $package:"
202 prefix=$(echo $package | sed -re 's/^((lib)?.).*$/\1/')
203 pkgurl="http://packages.qa.debian.org/${prefix}/${package}.html"
204 baseurl="http://packages.qa.debian.org/${prefix}/"
206 # only grab the actual "Accepted" news announcements; hopefully this
207 # won't pick up many false positives
208 WGETOPTS="-q -O - --timeout=30 "
210 for news in $(wget $WGETOPTS $pkgurl |
211 sed -ne 's%^.*<a href="\('$package'/news/[0-9A-Z]*\.html\)">Accepted .*%\1%p'); do
212 HTML_TEXT=$(wget $WGETOPTS "$baseurl$news")
213 GPG_TEXT=$(echo "$HTML_TEXT" |
214 sed -ne 's/^<pre>//; /-----BEGIN PGP SIGNED MESSAGE-----/,/-----END PGP SIGNATURE-----/p')
216 test -n "$GPG_TEXT" || continue
218 VERSION=$(echo "$GPG_TEXT" | awk '/^Version/ { print $2; exit }')
219 DISTRO=$(echo "$GPG_TEXT" | awk '/^Distribution/ { print $2; exit }')
220 if [ "$WANT_DATE" = "yes" ]; then
221 DATE=$(echo "$HTML_TEXT" | sed -ne 's%<li><em>Date</em>: \(.*\)</li>%\1%p')
224 GPG_ID=$(echo "$GPG_TEXT" | LC_ALL=C gpg $GPG_NO_KEYRING --verify 2>&1 |
225 sed -rne 's/.*ID ([0-9A-Z]+).*/\1/p')
227 UPLOADER=$(gpg $GPG_OPTIONS \
228 "${GPG_DEFAULT_KEYRINGS[@]}" "${GPG_KEYRINGS[@]}" \
229 --list-key --with-colons $GPG_ID 2>/dev/null |
230 awk -F: '/@debian\.org>/ { a = $10; exit} /^pub/ { a = $10 } END { print a }' )
231 if [ -z "$UPLOADER" ]; then UPLOADER="<unrecognised public key ($GPG_ID)>"; fi
233 output="$VERSION to $DISTRO: $UPLOADER"
234 [ "$WANT_DATE" = "yes" ] && output="$output on $DATE"
235 echo $output | iconv -c -f UTF-8
237 count=$(($count + 1))
238 [ $count -eq $MAXUPLOADS ] && break
240 test $# -eq 1 || echo