mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
* ubuntutools/packages.py: Created checkIsInDebian() function.
* requestsync: Adapt to use new function above. * update-maintainer: Rewrote in Python and adapted to use Maintainer field spec approved by the Technical Board at: - https://lists.ubuntu.com/archives/ubuntu-devel/2009-May/028213.html
This commit is contained in:
parent
78b7833ea9
commit
6a17e7c6c7
14
requestsync
14
requestsync
@ -42,6 +42,7 @@ import ubuntutools.lp.libsupport as lp_libsupport
|
|||||||
import ubuntutools.lp.udtexceptions as udtexceptions
|
import ubuntutools.lp.udtexceptions as udtexceptions
|
||||||
# https_proxy fix
|
# https_proxy fix
|
||||||
import ubuntutools.common
|
import ubuntutools.common
|
||||||
|
import ubuntutools.packages
|
||||||
|
|
||||||
launchpad_cookiefile = lp_cookie.prepareLaunchpadCookie()
|
launchpad_cookiefile = lp_cookie.prepareLaunchpadCookie()
|
||||||
|
|
||||||
@ -138,17 +139,10 @@ def cur_version_component(sourcepkg, release):
|
|||||||
|
|
||||||
def cur_deb_version(sourcepkg, distro):
|
def cur_deb_version(sourcepkg, distro):
|
||||||
'''Return the current debian version of a package in a Debian distro.'''
|
'''Return the current debian version of a package in a Debian distro.'''
|
||||||
madison = subprocess.Popen(['rmadison', '-u', 'debian', '-a', 'source', \
|
if not ubuntutools.packages.checkIsInDebian(sourcepkg, distro):
|
||||||
'-s', distro, sourcepkg], \
|
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
out = madison.communicate()[0]
|
|
||||||
assert (madison.returncode == 0)
|
|
||||||
|
|
||||||
try:
|
|
||||||
assert out
|
|
||||||
except AssertionError:
|
|
||||||
print "%s doesn't appear to exist in Debian." % sourcepkg
|
print "%s doesn't appear to exist in Debian." % sourcepkg
|
||||||
sys.exit(1)
|
sys.exit(0)
|
||||||
|
|
||||||
# Work-around for a bug in Debians madison.php script not returning
|
# Work-around for a bug in Debians madison.php script not returning
|
||||||
# only the source line
|
# only the source line
|
||||||
for line in out.splitlines():
|
for line in out.splitlines():
|
||||||
|
@ -101,3 +101,17 @@ def packageComponent(package, release):
|
|||||||
component = rel.split('/')[1]
|
component = rel.split('/')[1]
|
||||||
|
|
||||||
return component.strip()
|
return component.strip()
|
||||||
|
|
||||||
|
def checkIsInDebian(package, distro):
|
||||||
|
madison = subprocess.Popen(['rmadison', '-u', 'debian', '-a', 'source', \
|
||||||
|
'-s', distro, package], \
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
out = madison.communicate()[0]
|
||||||
|
assert (madison.returncode == 0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
assert out
|
||||||
|
except AssertionError:
|
||||||
|
out = False
|
||||||
|
|
||||||
|
return out
|
||||||
|
@ -1,120 +1,95 @@
|
|||||||
#!/bin/sh
|
#! /usr/bin/python
|
||||||
#
|
|
||||||
# Copyright 2007 (C) Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
|
||||||
#
|
|
||||||
# ##################################################################
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; version 2.
|
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# update-maintainer - this script is used to update the Maintainer field of an
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# Ubuntu package, as approved by the Ubuntu Technical
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# Board at:
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# See file /usr/share/common-licenses/GPL-2 for more details.
|
|
||||||
#
|
#
|
||||||
# ##################################################################
|
# https://lists.ubuntu.com/archives/ubuntu-devel/2009-May/028213.html
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Jonathan Davies <jpds@ubuntu.com>
|
||||||
|
#
|
||||||
|
# Original shell script was:
|
||||||
|
#
|
||||||
|
# Copyright 2007 (C) Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# This script is used to update the Maintainer field of an Ubuntu package
|
|
||||||
# to match the DebianMaintainerField specification.
|
|
||||||
|
|
||||||
usage() {
|
import os
|
||||||
cat <<EOF
|
import re
|
||||||
Usage: $0 [--path=PATH] [--section=SECTION]
|
import sys
|
||||||
--path=PATH Specify the path of the source directory.
|
import ubuntutools.packages
|
||||||
--section=SECTION Specify the section of the package (if the package is
|
|
||||||
not yet in the archive.
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
eval set -- "$(getopt -o '' -l path:,section:,help -- "$@")" || { usage >&2; exit 1; }
|
valid_locations = ["debian/control", "control"]
|
||||||
while :; do
|
control_file_found = False
|
||||||
case $1 in
|
|
||||||
--path)
|
|
||||||
path="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--section)
|
|
||||||
[ "$2" != "main" ] &&
|
|
||||||
[ "$2" != "restricted" ] &&
|
|
||||||
[ "$2" != "universe" ] &&
|
|
||||||
[ "$2" != "multiverse" ] && echo "Invalid section. Valid sections: main restricted universe multiverse" >&2 && exit 1
|
|
||||||
section="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--help)
|
|
||||||
usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Bad parameter."
|
|
||||||
usage >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ${path-.}
|
# Check changelog file exists.
|
||||||
|
for location in valid_locations:
|
||||||
|
if os.path.exists(location):
|
||||||
|
control_file_found = True
|
||||||
|
control_file = location
|
||||||
|
break # Stop looking.
|
||||||
|
|
||||||
# look for the debian directory
|
# Check if we've found a control file.
|
||||||
if [ -f debian/control ] && [ -f debian/changelog ]; then
|
if not control_file_found:
|
||||||
DEBIANDIR=debian
|
sys.stderr.write("Unable to find debian/control file.\n")
|
||||||
elif [ -f control ] && [ -f changelog ]; then
|
sys.exit(1)
|
||||||
DEBIANDIR=.
|
|
||||||
else
|
|
||||||
echo "Please execute «$0» in the source folder." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -r $DEBIANDIR/changelog ]
|
# Read found file contents.
|
||||||
then
|
debian_control_file = open(control_file, "r")
|
||||||
echo "Make sure that the changelog file is readable." >&2 && exit 1
|
file_contents = debian_control_file.read()
|
||||||
fi
|
debian_control_file.close()
|
||||||
|
|
||||||
for file in control control.in control.real; do
|
# Check if there is a Maintainer field in file found.
|
||||||
if [ -f $DEBIANDIR/$file ]; then
|
if not 'Maintainer' in file_contents:
|
||||||
if [ ! -r $DEBIANDIR/$file ] || [ ! -w $DEBIANDIR/$file ]; then
|
sys.stderr.write("Unable to find Maintainer field in %s.\n" % control_file)
|
||||||
echo "Make sure that the control file(s) is (are) readable and writable." >&2 && exit 1
|
sys.exit(1)
|
||||||
fi
|
|
||||||
controls="$controls $file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! head -1 $DEBIANDIR/changelog | grep -q '(*ubuntu.*)'
|
package_field = re.findall('(Source:) (.*)', file_contents)
|
||||||
then
|
package_name = package_field[0][1]
|
||||||
echo "Latest changelog entry has no Ubuntu version number." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -E "^Maintainer: .*@.*ubuntu.*>" $DEBIANDIR/control >/dev/null
|
# Get maintainer field information.
|
||||||
then
|
maintainer_field = re.findall('(Maintainer:) (.*) (<.*>)', file_contents)
|
||||||
echo "Package already maintained by the Ubuntu team." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$section" ]; then
|
# Split out maintainer name and email address.
|
||||||
DISTRO=$(sed -r '1!d;s/.*\) (.*);.*/\1/' $DEBIANDIR/changelog | cut -d'-' -f1)
|
maintainer_name = maintainer_field[0][1]
|
||||||
pkgline=$(rmadison -u ubuntu -a source -s $DISTRO $(head -1 $DEBIANDIR/changelog | cut -d' ' -f1))
|
maintainer_mail = maintainer_field[0][2]
|
||||||
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
|
# Check if Maintainer field is as approved in TB decision.
|
||||||
"main"|"restricted") email="Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>" ;;
|
if 'Ubuntu Developers' in maintainer_name and \
|
||||||
"universe"|"multiverse") email="Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>" ;;
|
'<ubuntu-devel-discuss@lists.ubuntu.com>' in maintainer_mail:
|
||||||
*) echo "No section found for this package; aborting" >&2; exit 1 ;;
|
print "Ubuntu Developers is already set as maintainer."
|
||||||
esac
|
sys.exit(0)
|
||||||
|
|
||||||
for file in $controls; do
|
if not ubuntutools.packages.checkIsInDebian(package_name, 'unstable'):
|
||||||
sed -ri "s/(^Maintainer:) (.*)/\1 $email\nXSBC-Original-\1 \2/" $DEBIANDIR/$file
|
user_email_address = os.getenv('DEBEMAIL')
|
||||||
done
|
if not user_email_address:
|
||||||
|
sys.stderr.write('The environment variable DEBEMAIL needs to be ' +\
|
||||||
|
'set to make proper use of this script.\n')
|
||||||
|
sys.exit(1)
|
||||||
|
target_maintainer = user_email_address
|
||||||
|
else:
|
||||||
|
target_maintainer = "Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>"
|
||||||
|
|
||||||
|
# Set original maintainer field in a string.
|
||||||
|
original_maintainer = maintainer_name + " " + maintainer_mail
|
||||||
|
final_addition = target_maintainer + "\nXSBC-Original-Maintainer: " + original_maintainer
|
||||||
|
|
||||||
|
print "The original maintainer for this package is: " + original_maintainer
|
||||||
|
print "Resetting as: " + target_maintainer
|
||||||
|
|
||||||
|
# Replace text.
|
||||||
|
debian_control_file = open(control_file, "w")
|
||||||
|
debian_control_file.write(re.sub(original_maintainer, final_addition, file_contents))
|
||||||
|
debian_control_file.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user