2007-04-01 20:32:17 +10:00
#!/bin/bash
#update-maintainer
#small - thus not perfect - script to update maintainer field in ubuntu packages
#written and (c) 2007 by Albin Tonnerre <lut1n.tne@gmail.com> (Lutin)
#this code is under the GNU GPL V2 licence
2007-04-01 12:54:14 +02:00
[ -n "`echo $1 | sed -r 's/(--help|universe|multiverse|main|restricted)//'`" ]\
&& echo "Bad parameter, please use --help" >&2 && exit 1
[ "$1" == --help ] && echo "Launch this script without any option or with the section as the only parameter (if the package is not yet in the archive or if you don't have the feisty source repo in your sources.list)" && exit 0
# look for the debian directory
if [ -f debian/control -a -f debian/changelog ]; then
DEBIANDIR=debian
elif [ -f control -a -f changelog ]; then
DEBIANDIR=.
else
echo "Please run that script in the source folder" >&2 && exit 1
fi
2007-04-01 20:32:17 +10:00
2007-04-01 12:54:14 +02:00
IGNORE_DOMAINS="ubuntu\.com|ubuntu\.com\.au"
2007-04-01 20:32:17 +10:00
2007-04-01 12:54:14 +02:00
[ -n "`head -n 1 $DEBIANDIR/changelog | grep -E "\(*ubuntu.*\)"`" ] &&
[ -z "`grep -E "^Maintainer: .*($IGNORE_DOMAINS)>" $DEBIANDIR/control`" ] || \
{ echo "Not an ubuntu package or already maintained by the ubuntu team" >&2 && \
exit 1; }
2007-04-01 20:32:17 +10:00
2007-04-01 12:54:14 +02:00
mail=$(grep -E "^Maintainer" $DEBIANDIR/control | sed -r 's/.*<(.*)>/\1/')
2007-04-01 20:32:17 +10:00
case $mail in
"adconrad@0c3.net") email="Adam Conrad <adconrad@ubuntu.com>" ;;
"mpitt@debian.org") email="Martin Pitt <martin.pitt@ubuntu.com>" ;;
esac
if [ -z "$email" ]; then
2007-04-01 12:54:14 +02:00
if [ -z "$1" ]; then
DISTRO=$(head -n 1 $DEBIANDIR/changelog|sed -r 's/.*\) (.*);.*/\1/' | cut -d'-' -f1)
pkgline=$(apt-cache madison `head -n 1 $DEBIANDIR/changelog | cut -d' ' -f1`|\
grep -m 1 "$DISTRO.*Sources")
[ -z "$pkgline" ] && echo "You don't have $DISTRO in your source repos" \
>&2 && exit 1
section=$(echo $pkgline | grep -Eo "main|universe|multiverse|restricted")
else section=$1; fi
2007-04-01 20:32:17 +10:00
case $section in
2007-04-01 12:54:14 +02:00
"main"|"restricted") email="Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>" ;;
"universe"|"multiverse") email="Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>" ;;
2007-04-01 20:32:17 +10:00
esac
fi
2007-04-01 12:54:14 +02:00
sed -ri "s/(^Maintainer:) (.*)/\1 $email\nXSBC-Original-\1 \2/" $DEBIANDIR/control
[ -f $DEBIANDIR/control.in ] && sed -ri "s/(^Maintainer:) (.*)/\1 $email\nXSBC-Original-\1 \2/" $DEBIANDIR/control.in
2007-04-01 20:32:17 +10:00
2007-04-01 12:54:14 +02:00
dch "Modified Maintainer value to match Debian-Maintainer-Field Spec"
2007-04-01 20:32:17 +10:00
echo "Maintainer changed to $email"
exit 0