| 1 |
operz |
1 |
#!/bin/ksh |
| 2 |
|
|
# |
| 3 |
|
|
# Copyright 2007 Yann Rouillard <yann@blastwave.org> |
| 4 |
|
|
# All rights reserved. Use is subject to license terms. |
| 5 |
|
|
# |
| 6 |
|
|
# Redistribution and/or use, with or without modification, is |
| 7 |
|
|
# permitted. This software is without warranty of any kind. The |
| 8 |
|
|
# author(s) shall not be liable in the event that use of the |
| 9 |
|
|
# software causes damage. |
| 10 |
|
|
# |
| 11 |
|
|
# mail2maintainer - works like mail except the recipient is |
| 12 |
|
|
# a package name, mail2maintainer find the real email |
| 13 |
|
|
# from the package name |
| 14 |
|
|
# |
| 15 |
|
|
|
| 16 |
|
|
# Function : get_package_maintainer |
| 17 |
|
|
# Purpose : given a package name, return the maintainer name |
| 18 |
|
|
# Arguments: the package name |
| 19 |
|
|
# Returns : the maintainer name |
| 20 |
|
|
# |
| 21 |
|
|
# TODO: find a proper way to get the maintainer |
| 22 |
|
|
# |
| 23 |
|
|
function get_package_maintainer |
| 24 |
|
|
{ |
| 25 |
|
|
_PACKAGE="$1" |
| 26 |
|
|
|
| 27 |
|
|
# This has to be improved. Maintainer is retrieved from the web page. It will be replaced by a sql query |
| 28 |
|
|
_MAINTAINER="`wget -q http://www.opencsw.org/packages/$_PACKAGE -O- | grep Maintainer | sed -e "s,.*/maintainers/\([^\'\\\"]*\).*,\1,g"`" |
| 29 |
|
|
|
| 30 |
|
|
# In case Maintainer string is empty, try to find the maintainer from a gspec file |
| 31 |
|
|
# It's a bit crappy, but it works in msot cases (but has to be replaced also) |
| 32 |
|
|
if [ "$_MAINTAINER" -eq "" ] ; then |
| 33 |
|
|
_PACKAGE="`grep bitname files/*.gspec | awk '{ print $3 }' | head -n 1`" |
| 34 |
|
|
_MAINTAINER="`wget -q http://www.opencsw.org/packages/$_PACKAGE -O- | grep Maintainer | sed -e "s,.*/maintainers/\([^\'\\\"]*\).*,\1,g"`" |
| 35 |
|
|
fi |
| 36 |
|
|
|
| 37 |
|
|
echo "$_MAINTAINER" |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
# Function : maintainer2mail |
| 41 |
|
|
# Purpose : given a maintainer name, returns his email |
| 42 |
|
|
# Arguments: the maintainer name |
| 43 |
|
|
# Returns : the maintainer email |
| 44 |
|
|
# |
| 45 |
|
|
# TODO: find a proper way to get the email |
| 46 |
|
|
# |
| 47 |
|
|
function maintainer2mail |
| 48 |
|
|
{ |
| 49 |
|
|
_MAINTAINER="$1" |
| 50 |
|
|
echo "$_MAINTAINER@opencsw.org" |
| 51 |
|
|
} |
| 52 |
|
|
|
| 53 |
|
|
PATH=$PATH:/opt/csw/bin:/usr/sfw/bin |
| 54 |
|
|
|
| 55 |
|
|
if [[ -z "$1" ]]; then |
| 56 |
|
|
cat <<EOF |
| 57 |
|
|
Usage: mail2maintainer [mail options] package_name |
| 58 |
|
|
Given a package name, send an email to the maintainer. |
| 59 |
|
|
EOF |
| 60 |
|
|
exit 1 |
| 61 |
|
|
fi |
| 62 |
|
|
|
| 63 |
|
|
eval PACKAGE_NAME=\$$# |
| 64 |
|
|
|
| 65 |
|
|
MAINTAINER=`get_package_maintainer $PACKAGE_NAME` |
| 66 |
|
|
EMAIL=`maintainer2mail $MAINTAINER` |
| 67 |
|
|
|
| 68 |
|
|
MAIL_OPTIONS="" |
| 69 |
|
|
while [ $# -ne 1 ]; do |
| 70 |
|
|
MAIL_OPTIONS="$MAIL_OPTIONS \"$1\"" |
| 71 |
|
|
shift |
| 72 |
|
|
done |
| 73 |
|
|
|
| 74 |
|
|
if [ ! -n "$MAINTAINER" ] ; then |
| 75 |
|
|
echo "No valid maintainer for package : $PACKAGE_NAME" |
| 76 |
|
|
eval mailx "-s" "\"[svn] Invalid maintainer for package $PACKAGE_NAME\"" -b "william@wbonnet.net" uwatch@opencsw.org |
| 77 |
|
|
else |
| 78 |
|
|
eval mailx $MAIL_OPTIONS -b "william@wbonnet.net" $EMAIL |
| 79 |
|
|
fi |