mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
control.py: Add required methods for update-maintainer.
This commit is contained in:
parent
c28ddf5698
commit
1054307414
2
debian/copyright
vendored
2
debian/copyright
vendored
@ -154,7 +154,6 @@ Files: dch-repeat,
|
|||||||
ubuntutools/misc.py,
|
ubuntutools/misc.py,
|
||||||
ubuntutools/packages.py,
|
ubuntutools/packages.py,
|
||||||
ubuntutools/update_maintainer.py,
|
ubuntutools/update_maintainer.py,
|
||||||
update-maintainer,
|
|
||||||
what-patch
|
what-patch
|
||||||
Copyright: 2007, Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
Copyright: 2007, Albin Tonnerre (Lutin) <lut1n.tne@gmail.com>
|
||||||
2007-2010, Canonical Ltd.
|
2007-2010, Canonical Ltd.
|
||||||
@ -193,6 +192,7 @@ Files: doc/sponsor-patch.1,
|
|||||||
ubuntutools/question.py,
|
ubuntutools/question.py,
|
||||||
ubuntutools/sponsor_patch/*,
|
ubuntutools/sponsor_patch/*,
|
||||||
ubuntutools/test/*,
|
ubuntutools/test/*,
|
||||||
|
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>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#
|
|
||||||
# control.py - Represents a debian/control file
|
# control.py - Represents a debian/control file
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
@ -15,10 +14,27 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
"""This module implements facilities to deal with Debian control."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import debian.deb822
|
import debian.deb822
|
||||||
|
|
||||||
|
def _insert_after(paragraph, item_before, new_item, new_value):
|
||||||
|
"""Insert new_item into directly after item_before
|
||||||
|
|
||||||
|
New items added to a dictionary are appended."""
|
||||||
|
item_found = False
|
||||||
|
for item in paragraph:
|
||||||
|
if item_found:
|
||||||
|
value = paragraph.pop(item)
|
||||||
|
paragraph[item] = value
|
||||||
|
if item == item_before:
|
||||||
|
item_found = True
|
||||||
|
paragraph[new_item] = new_value
|
||||||
|
if not item_found:
|
||||||
|
paragraph[new_item] = new_value
|
||||||
|
|
||||||
class Control(object):
|
class Control(object):
|
||||||
"""Represents a debian/control file"""
|
"""Represents a debian/control file"""
|
||||||
|
|
||||||
@ -30,12 +46,13 @@ class Control(object):
|
|||||||
for paragraph in debian.deb822.Deb822.iter_paragraphs(sequence):
|
for paragraph in debian.deb822.Deb822.iter_paragraphs(sequence):
|
||||||
self.paragraphs.append(paragraph)
|
self.paragraphs.append(paragraph)
|
||||||
|
|
||||||
def get_source_paragraph(self):
|
def get_maintainer(self):
|
||||||
"""Returns the source paragraph of the control file."""
|
"""Returns the value of the Maintainer field."""
|
||||||
if self.paragraphs:
|
return self.paragraphs[0].get("Maintainer")
|
||||||
return self.paragraphs[0]
|
|
||||||
else:
|
def get_original_maintainer(self):
|
||||||
return None
|
"""Returns the value of the XSBC-Original-Maintainer field."""
|
||||||
|
return self.paragraphs[0].get("XSBC-Original-Maintainer")
|
||||||
|
|
||||||
def save(self, filename=None):
|
def save(self, filename=None):
|
||||||
"""Saves the control file."""
|
"""Saves the control file."""
|
||||||
@ -46,6 +63,18 @@ class Control(object):
|
|||||||
control_file.write(content.encode("utf-8"))
|
control_file.write(content.encode("utf-8"))
|
||||||
control_file.close()
|
control_file.close()
|
||||||
|
|
||||||
|
def set_maintainer(self, maintainer):
|
||||||
|
"""Sets the value of the Maintainer field."""
|
||||||
|
self.paragraphs[0]["Maintainer"] = maintainer
|
||||||
|
|
||||||
|
def set_original_maintainer(self, original_maintainer):
|
||||||
|
"""Sets the value of the XSBC-Original-Maintainer field."""
|
||||||
|
if "XSBC-Original-Maintainer" in self.paragraphs[0]:
|
||||||
|
self.paragraphs[0]["XSBC-Original-Maintainer"] = original_maintainer
|
||||||
|
else:
|
||||||
|
_insert_after(self.paragraphs[0], "Maintainer",
|
||||||
|
"XSBC-Original-Maintainer", original_maintainer)
|
||||||
|
|
||||||
def strip_trailing_spaces(self):
|
def strip_trailing_spaces(self):
|
||||||
"""Strips all trailing spaces from the control file."""
|
"""Strips all trailing spaces from the control file."""
|
||||||
for paragraph in self.paragraphs:
|
for paragraph in self.paragraphs:
|
||||||
|
@ -26,7 +26,7 @@ import debian.changelog
|
|||||||
import debian.deb822
|
import debian.deb822
|
||||||
import launchpadlib.launchpad
|
import launchpadlib.launchpad
|
||||||
|
|
||||||
import ubuntutools.update_maintainer
|
from ubuntutools.update_maintainer import update_maintainer
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.question import Question, YesNoQuestion, input_number
|
from ubuntutools.question import Question, YesNoQuestion, input_number
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ def main(bug_number, build, builder, edit, keyid, lpinstance, update, upload,
|
|||||||
|
|
||||||
# update the Maintainer field
|
# update the Maintainer field
|
||||||
Logger.command(["update-maintainer"])
|
Logger.command(["update-maintainer"])
|
||||||
if ubuntutools.update_maintainer.update_maintainer(verbose) != 0:
|
if update_maintainer("debian", verbose) != 0:
|
||||||
Logger.error("update-maintainer script failed.")
|
Logger.error("update-maintainer script failed.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import sys
|
|||||||
|
|
||||||
import ubuntutools.packages
|
import ubuntutools.packages
|
||||||
|
|
||||||
def update_maintainer(verbose=False):
|
def update_maintainer(debian_directory, verbose=False):
|
||||||
valid_locations = ["debian/control.in", "control.in", "debian/control",
|
valid_locations = ["debian/control.in", "control.in", "debian/control",
|
||||||
"control"]
|
"control"]
|
||||||
control_file_found = False
|
control_file_found = False
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
#! /usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# update-maintainer - this script is used to update the Maintainer field of an
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
# Ubuntu package, as approved by the Ubuntu Technical
|
|
||||||
# Board at:
|
|
||||||
#
|
#
|
||||||
# https://lists.ubuntu.com/archives/ubuntu-devel/2009-May/028213.html
|
# 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 (C) 2009 Jonathan Davies <jpds@ubuntu.com>
|
# copyright notice and this permission notice appear in all copies.
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
#
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import ubuntutools.update_maintainer
|
from ubuntutools.update_maintainer import update_maintainer
|
||||||
|
|
||||||
script_name = os.path.basename(sys.argv[0])
|
def main():
|
||||||
usage = "%s [options]" % (script_name)
|
script_name = os.path.basename(sys.argv[0])
|
||||||
epilog = "See %s(1) for more info." % (script_name)
|
usage = "%s [options]" % (script_name)
|
||||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
epilog = "See %s(1) for more info." % (script_name)
|
||||||
parser.add_option("-q", "--quiet", help="print no informational messages",
|
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||||
dest="quiet", action="store_true", default=False)
|
parser.add_option("-d", "--debian-directory", dest="debian_directory",
|
||||||
(options, args) = parser.parse_args()
|
help="location of the 'debian' directory (default: "
|
||||||
|
"%default).", metavar="PATH", default="./debian")
|
||||||
|
parser.add_option("-q", "--quiet", help="print no informational messages",
|
||||||
|
dest="quiet", action="store_true", default=False)
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
sys.exit(ubuntutools.update_maintainer.update_maintainer(not options.quiet))
|
if len(args) != 0:
|
||||||
|
print >> sys.stderr, ("%s: Error: Unsupported additional parameters "
|
||||||
|
"specified: %s") % (script_name, ", ".join(args))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.exit(update_maintainer(options.debian_directory, not options.quiet))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user