mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
86 lines
2.6 KiB
Bash
Executable File
86 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2007 (C) Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
|
# License: GPLv2
|
|
#
|
|
# This script is used to update the Maintainer field of an Ubuntu package
|
|
# to match the DebianMaintainerField specification.
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: $0 [--path=PATH] [--section=SECTION] [--nochangelog]
|
|
--path=PATH Specify the path of the source directory.
|
|
--section=SECTION Specify the section of the package (if the package is
|
|
not yet in the archive.
|
|
EOF
|
|
}
|
|
|
|
for argv in "$@"; do
|
|
param=${argv%=*}
|
|
value=${argv#*=}
|
|
case $param in
|
|
"--path")
|
|
path="$value"
|
|
;;
|
|
"--section")
|
|
[ "$value" != "main" ] &&
|
|
[ "$value" != "restricted" ] &&
|
|
[ "$value" != "universe" ] &&
|
|
[ "$value" != "multiverse" ] && echo "Invalid section. Valid sections: main restricted universe multiverse" >&2 && exit 1
|
|
section=$value
|
|
;;
|
|
"--help")
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Bad parameter."
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
cd ${path-.}
|
|
|
|
# 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 execute «$0» in the source folder." >&2 && exit 1
|
|
fi
|
|
|
|
if [ -z "$(head -1 $DEBIANDIR/changelog | grep -E '\(*ubuntu.*\)')" ]
|
|
then
|
|
echo "Latest changelog entry has no Ubuntu version number." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if grep -E "^Maintainer: .*@.*ubuntu.*>" $DEBIANDIR/control >/dev/null
|
|
then
|
|
echo "Package already maintained by the Ubuntu team." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$section" ]; then
|
|
DISTRO=$(sed -r '1!d;s/.*\) (.*);.*/\1/' $DEBIANDIR/changelog | cut -d'-' -f1)
|
|
pkgline=$(rmadison -u ubuntu -a source -s $DISTRO $(head -1 $DEBIANDIR/changelog | cut -d' ' -f1))
|
|
if [ -z "$pkgline" ]; then
|
|
echo "The package doesn't exist in the $DISTRO archive. You may have to use the" >&2
|
|
echo "--section argument. Run $0 --help for more information." >&2
|
|
exit 1
|
|
fi
|
|
section=$(echo $pkgline | grep -Eo "main|universe|multiverse|restricted") || section=main
|
|
fi
|
|
|
|
case $section in
|
|
"main"|"restricted") email="Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>" ;;
|
|
"universe"|"multiverse") email="Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>" ;;
|
|
*) echo "No section found for this package; aborting" >&2; exit 1 ;;
|
|
esac
|
|
|
|
for file in control{,.in,.real}; do
|
|
[ -f $DEBIANDIR/$file ] && sed -ri "s/(^Maintainer:) (.*)/\1 $email\nXSBC-Original-\1 \2/" $DEBIANDIR/$file
|
|
done
|