mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
update-maintainer: Rewrite completely using python-debian (LP: #666504).
This commit is contained in:
parent
00faea17e2
commit
3f3018aef2
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -43,12 +43,13 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
|
|||||||
* Recommend bzr-builddeb (used by sponsor-patch for branches).
|
* Recommend bzr-builddeb (used by sponsor-patch for branches).
|
||||||
* Add most dependencies to Build-Depends for successfully run the tests.
|
* Add most dependencies to Build-Depends for successfully run the tests.
|
||||||
* Recommend python-gnupginterface (used by dgetlp).
|
* Recommend python-gnupginterface (used by dgetlp).
|
||||||
|
* update-maintainer: Rewrite completely using python-debian (LP: #666504).
|
||||||
|
|
||||||
[ Michael Vogt ]
|
[ Michael Vogt ]
|
||||||
* add "add-patch" that provides the non-interactive version of
|
* add "add-patch" that provides the non-interactive version of
|
||||||
edit-patch
|
edit-patch
|
||||||
|
|
||||||
-- Stefano Rivera <stefanor@dvorak.kardiogramm.lan> Fri, 24 Dec 2010 12:16:10 +0200
|
-- Benjamin Drung <bdrung@ubuntu.com> Sat, 25 Dec 2010 19:47:14 +0100
|
||||||
|
|
||||||
ubuntu-dev-tools (0.108) experimental; urgency=low
|
ubuntu-dev-tools (0.108) experimental; urgency=low
|
||||||
|
|
||||||
|
8
debian/copyright
vendored
8
debian/copyright
vendored
@ -136,7 +136,6 @@ Files: dch-repeat,
|
|||||||
doc/pull-lp-source.1,
|
doc/pull-lp-source.1,
|
||||||
doc/pull-revu-source.1,
|
doc/pull-revu-source.1,
|
||||||
doc/ubuntu-build.1,
|
doc/ubuntu-build.1,
|
||||||
doc/update-maintainer.1,
|
|
||||||
doc/what-patch.1,
|
doc/what-patch.1,
|
||||||
get-build-deps,
|
get-build-deps,
|
||||||
grep-merges,
|
grep-merges,
|
||||||
@ -151,10 +150,8 @@ Files: dch-repeat,
|
|||||||
ubuntutools/lp/lpapicache.py,
|
ubuntutools/lp/lpapicache.py,
|
||||||
ubuntutools/misc.py,
|
ubuntutools/misc.py,
|
||||||
ubuntutools/packages.py,
|
ubuntutools/packages.py,
|
||||||
ubuntutools/update_maintainer.py,
|
|
||||||
what-patch
|
what-patch
|
||||||
Copyright: 2007, Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
Copyright: 2007-2010, Canonical Ltd.
|
||||||
2007-2010, Canonical Ltd.
|
|
||||||
2008-2009, Iain Lane <iain@orangesquash.org.uk>
|
2008-2009, Iain Lane <iain@orangesquash.org.uk>
|
||||||
2006, John Dong <jdong@ubuntu.com>
|
2006, John Dong <jdong@ubuntu.com>
|
||||||
2009, Jonathan Davies <jpds@ubuntu.com>
|
2009, Jonathan Davies <jpds@ubuntu.com>
|
||||||
@ -182,6 +179,7 @@ Files: doc/pull-debian-debdiff.1,
|
|||||||
doc/sponsor-patch.1,
|
doc/sponsor-patch.1,
|
||||||
doc/suspicious-source.1,
|
doc/suspicious-source.1,
|
||||||
doc/ubuntu-dev-tools.5,
|
doc/ubuntu-dev-tools.5,
|
||||||
|
doc/update-maintainer.1,
|
||||||
doc/wrap-and-sort.1,
|
doc/wrap-and-sort.1,
|
||||||
pull-debian-debdiff,
|
pull-debian-debdiff,
|
||||||
sponsor-patch,
|
sponsor-patch,
|
||||||
@ -193,10 +191,12 @@ Files: doc/pull-debian-debdiff.1,
|
|||||||
ubuntutools/question.py,
|
ubuntutools/question.py,
|
||||||
ubuntutools/sponsor_patch/*,
|
ubuntutools/sponsor_patch/*,
|
||||||
ubuntutools/test/*,
|
ubuntutools/test/*,
|
||||||
|
ubuntutools/update_maintainer.py,
|
||||||
update-maintainer,
|
update-maintainer,
|
||||||
wrap-and-sort
|
wrap-and-sort
|
||||||
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
2010, Evan Broder <evan@ebroder.net>
|
2010, Evan Broder <evan@ebroder.net>
|
||||||
|
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
2010, Stefano Rivera <stefanor@ubuntu.com>
|
2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
License: ISC
|
License: ISC
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
@ -1,10 +1,26 @@
|
|||||||
.TH UPDATE\-MAINTAINER "1" "August 04, 2008" "ubuntu-dev-tools"
|
.\" Copyright (c) 2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
|
.\" 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
|
.\"
|
||||||
|
.\" Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
.\" purpose with or without fee is hereby granted, provided that the above
|
||||||
|
.\" copyright notice and this permission notice appear in all copies.
|
||||||
|
.\"
|
||||||
|
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
.\"
|
||||||
|
.TH UPDATE\-MAINTAINER "1" "December 2010" "ubuntu-dev-tools"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
update\-maintainer \- change the Maintainer field in a Debian source package
|
update\-maintainer \- change the Maintainer field in a Debian source package
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B update\-maintainer [\fB\-\-path=<PATH>\fP] [\fB\-\-section=<SECTION>\fP]
|
.B update\-maintainer
|
||||||
|
[\fIoptions\fR]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBupdate\-maintainer\fP updates the Maintainer field in the source of
|
\fBupdate\-maintainer\fP updates the Maintainer field in the source of
|
||||||
@ -12,19 +28,20 @@ an Ubuntu package to match the DebianMaintainerField specification.
|
|||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-path=<PATH>\fP
|
\fB\-d \fIPATH\fR, \fB\-\-debian\-directory\fR=\fIPATH\fR
|
||||||
This option allows you to specify the path to the source directory.
|
location of the \fIdebian\fR directory (default: \fB./debian\fR)
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-section=<SECTION>\fP
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Manually specify the section of the package. This is necessary if the
|
show a help message and exit
|
||||||
package is not yet in the archive or if you don't have an Internet
|
.TP
|
||||||
connection available when you run \fBupdate\-maintainer\fP.
|
\fB\-q\fR, \fB\-\-quiet\fR
|
||||||
|
print no informational messages
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
See https://wiki.ubuntu.com/DebianMaintainerField for more information.
|
See https://wiki.ubuntu.com/DebianMaintainerField for more information.
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
\fBupdate-maintainer\fP has been written by Albin Tonnerre <lut1n.tne@gmail.com>
|
\fBupdate-maintainer\fP has been written by Benjamin Drung <bdrung@ubuntu.com>
|
||||||
and this manual page by Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>.
|
and this manual page by Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>.
|
||||||
.PP
|
.PP
|
||||||
Both are released under the GNU General Public License, version 2.
|
Both are released under the ISC license.
|
||||||
|
@ -1,145 +1,104 @@
|
|||||||
# update-maintainer.py - this script is used to update the Maintainer field
|
# update_maintainer.py - updates the Maintainer field of an Ubuntu package
|
||||||
# of an Ubuntu package, as approved by the
|
|
||||||
# Ubuntu Technical Board at:
|
|
||||||
#
|
#
|
||||||
# https://lists.ubuntu.com/archives/ubuntu-devel/2009-May/028213.html
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Jonathan Davies <jpds@ubuntu.com>
|
# Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
|
# copyright notice and this permission notice appear in all copies.
|
||||||
#
|
#
|
||||||
# Original shell script was:
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
#
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
# Copyright 2007 (C) Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
#
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
# it under the terms of the GNU General Public License as published by
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
"""This module is for updating the Maintainer field of an Ubuntu package."""
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import ubuntutools.packages
|
import debian.changelog
|
||||||
|
|
||||||
def update_maintainer(debian_directory, verbose=False):
|
from ubuntutools.control import Control
|
||||||
valid_locations = ["debian/control.in", "control.in", "debian/control",
|
from ubuntutools.logger import Logger
|
||||||
"control"]
|
|
||||||
control_file_found = False
|
|
||||||
|
|
||||||
# Check changelog file exists.
|
|
||||||
for location in valid_locations:
|
|
||||||
if os.path.isfile(location):
|
|
||||||
control_file_found = True
|
|
||||||
control_file = location
|
|
||||||
break # Stop looking.
|
|
||||||
|
|
||||||
# Check if we've found a control file.
|
|
||||||
if not control_file_found:
|
|
||||||
sys.stderr.write("Unable to find debian/control file.\n")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
# Read found file contents.
|
|
||||||
debian_control_file = open(control_file, "r")
|
|
||||||
file_contents = debian_control_file.read()
|
|
||||||
debian_control_file.close()
|
|
||||||
|
|
||||||
# Check if there is a Maintainer field in file found.
|
|
||||||
if not 'Maintainer' in file_contents:
|
|
||||||
sys.stderr.write("Unable to find Maintainer field in %s.\n" % \
|
|
||||||
control_file)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
package_field = re.findall('(Source:) (.*)', file_contents)
|
|
||||||
package_name = package_field[0][1]
|
|
||||||
|
|
||||||
# Get maintainer field information.
|
|
||||||
maintainer_field = re.findall('(Maintainer:) (.*) (<.*>)', file_contents)
|
|
||||||
|
|
||||||
# Split out maintainer name and email address.
|
|
||||||
maintainer_name = maintainer_field[0][1]
|
|
||||||
maintainer_mail = maintainer_field[0][2]
|
|
||||||
|
|
||||||
if maintainer_mail.endswith("@ubuntu.com>"):
|
|
||||||
if verbose:
|
|
||||||
print "Maintainer email is set to an @ubuntu.com address - doing nothing."
|
|
||||||
return 0
|
|
||||||
|
|
||||||
# Prior May 2009 these Maintainers were used:
|
# Prior May 2009 these Maintainers were used:
|
||||||
# main or restricted: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
_PREVIOUS_UBUNTU_MAINTAINER = (
|
||||||
# universe or multiverse: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
|
"ubuntu core developers <ubuntu-devel-discuss@lists.ubuntu.com>",
|
||||||
old_maintainer = maintainer_mail in ("<ubuntu-devel-discuss@lists.ubuntu.com>",
|
"ubuntu motu developers <ubuntu-motu@lists.ubuntu.com>",
|
||||||
"<ubuntu-motu@lists.ubuntu.com>")
|
)
|
||||||
if maintainer_mail.endswith("@lists.ubuntu.com>") and not old_maintainer:
|
_UBUNTU_MAINTAINER = "Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>"
|
||||||
|
|
||||||
|
def _get_distribution(changelog_file):
|
||||||
|
"""get distribution of latest changelog entry"""
|
||||||
|
changelog = debian.changelog.Changelog(open(changelog_file))
|
||||||
|
return changelog.distributions
|
||||||
|
|
||||||
|
def update_maintainer(debian_directory, verbose=False):
|
||||||
|
"""updates the Maintainer field of an Ubuntu package
|
||||||
|
|
||||||
|
* No modifications are made if the Maintainer field contains an ubuntu.com
|
||||||
|
email address. Otherwise, the Maintainer field will be set to
|
||||||
|
Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||||
|
* The old value will be saved in a field named XSBC-Original-Maintainer
|
||||||
|
if the Maintainer field is modified.
|
||||||
|
|
||||||
|
Policy: https://wiki.ubuntu.com/DebianMaintainerField
|
||||||
|
"""
|
||||||
|
possible_contol_files = [os.path.join(debian_directory, f) for
|
||||||
|
f in ["control", "control.in"]]
|
||||||
|
|
||||||
|
changelog_file = os.path.join(debian_directory, "changelog")
|
||||||
|
control_files = [f for f in possible_contol_files if os.path.isfile(f)]
|
||||||
|
|
||||||
|
# Make sure that a changelog and control file is available
|
||||||
|
if len(control_files) == 0:
|
||||||
|
Logger.error("No control file found in %s.", debian_directory)
|
||||||
|
return(1)
|
||||||
|
if not os.path.isfile(changelog_file):
|
||||||
|
Logger.error("No changelog file found in %s.", debian_directory)
|
||||||
|
return(1)
|
||||||
|
|
||||||
|
# Strip things like "-proposed-updates" or "-security" from distribution.
|
||||||
|
distribution = _get_distribution(changelog_file).split("-")[0]
|
||||||
|
|
||||||
|
for control_file in control_files:
|
||||||
|
control = Control(control_file)
|
||||||
|
original_maintainer = control.get_maintainer()
|
||||||
|
|
||||||
|
if original_maintainer is None:
|
||||||
|
Logger.error("No Maintainer field found in %s.", control_file)
|
||||||
|
return(1)
|
||||||
|
|
||||||
|
if original_maintainer.strip().lower() in _PREVIOUS_UBUNTU_MAINTAINER:
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Maintainer email is set to an @lists.ubuntu.com address - doing nothing."
|
print "The old maintainer was: %s" % original_maintainer
|
||||||
return 0
|
print "Resetting as: %s" % _UBUNTU_MAINTAINER
|
||||||
|
control.set_original_maintainer(_UBUNTU_MAINTAINER)
|
||||||
|
control.save()
|
||||||
|
continue
|
||||||
|
|
||||||
|
if original_maintainer.strip().endswith("ubuntu.com>"):
|
||||||
# Check if Maintainer field is as approved in TB decision.
|
|
||||||
if 'Ubuntu Developers' in maintainer_name and \
|
|
||||||
'<ubuntu-devel-discuss@lists.ubuntu.com>' in maintainer_mail:
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Ubuntu Developers is already set as maintainer."
|
print ("The Maintainer email is set to an ubuntu.com address. "
|
||||||
return 0
|
"Doing nothing.")
|
||||||
|
continue
|
||||||
|
|
||||||
if not old_maintainer and \
|
if distribution in ("stable", "testing", "unstable", "experimental"):
|
||||||
not (ubuntutools.packages.checkIsInDebian(package_name, 'unstable') or \
|
|
||||||
ubuntutools.packages.checkIsInDebian(package_name, 'experimental')):
|
|
||||||
user_email_address = os.getenv('DEBEMAIL')
|
|
||||||
if not user_email_address:
|
|
||||||
user_email_address = os.getenv('EMAIL')
|
|
||||||
if not user_email_address:
|
|
||||||
sys.stderr.write('The environment variable DEBEMAIL or ' + \
|
|
||||||
'EMAIL needs to be set to make proper use ' + \
|
|
||||||
'of this script.\n')
|
|
||||||
return 1
|
|
||||||
user_name = os.getenv('DEBFULLNAME')
|
|
||||||
if not user_name:
|
|
||||||
sys.stderr.write('The environment variable DEBFULLNAME needs ' + \
|
|
||||||
'to be set to make proper use of this script.\n')
|
|
||||||
return 1
|
|
||||||
target_maintainer = user_name + ' <' + 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
|
|
||||||
|
|
||||||
# If maintainer-field contained the pre-archive-reorganisation entries,
|
|
||||||
# don't add a new XSBC-Original maintainer field
|
|
||||||
|
|
||||||
if not "lists.ubuntu.com" in original_maintainer:
|
|
||||||
# Remove existing Original-Maintainer field
|
|
||||||
# to avoid multiple Original-Maintainer fields
|
|
||||||
original_maintainer_fields = re.findall('(.*Original-Maintainer): (.*)',
|
|
||||||
file_contents)
|
|
||||||
if len(original_maintainer_fields) > 0:
|
|
||||||
for original_maintainer_field in original_maintainer_fields:
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Removing existing %s: %s" % original_maintainer_field
|
print "The package targets Debian. Doing nothing."
|
||||||
file_contents = re.sub('.*Original-Maintainer: .*\n', "",
|
return(0)
|
||||||
file_contents)
|
|
||||||
final_addition = "Maintainer: " + target_maintainer + \
|
if control.get_original_maintainer() is not None:
|
||||||
"\nXSBC-Original-Maintainer: " + original_maintainer
|
print "Overwriting original maintainer: %s" % \
|
||||||
else:
|
control.get_original_maintainer()
|
||||||
final_addition = "Maintainer: " + target_maintainer
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "The original maintainer for this package is: " + original_maintainer
|
print "The original maintainer is: %s" % original_maintainer
|
||||||
print "Resetting as: " + target_maintainer
|
print "Resetting as: %s" % _UBUNTU_MAINTAINER
|
||||||
|
control.set_original_maintainer(original_maintainer)
|
||||||
|
control.set_maintainer(_UBUNTU_MAINTAINER)
|
||||||
|
control.save()
|
||||||
|
|
||||||
# Replace text.
|
return(0)
|
||||||
debian_control_file = open(control_file, "w")
|
|
||||||
original_maintainer_line = "Maintainer: " + original_maintainer
|
|
||||||
debian_control_file.write(re.sub(re.escape(original_maintainer_line),
|
|
||||||
final_addition, file_contents))
|
|
||||||
debian_control_file.close()
|
|
||||||
return 0
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user