mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-04-19 22:31:07 +00:00
Replace deprecated optparse with argparse
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
This commit is contained in:
parent
f6fde2e217
commit
909d945af4
129
backportpackage
129
backportpackage
@ -18,8 +18,8 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import optparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -62,10 +62,10 @@ def check_call(cmd, *args, **kwargs):
|
||||
error("%s returned %d.", cmd[0], ret)
|
||||
|
||||
|
||||
def parse(args):
|
||||
usage = "Usage: %prog [options] <source package name or .dsc URL/file>"
|
||||
parser = optparse.OptionParser(usage)
|
||||
parser.add_option(
|
||||
def parse(argv):
|
||||
usage = "%(prog)s [options] <source package name or .dsc URL/file>"
|
||||
parser = argparse.ArgumentParser(usage=usage)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--destination",
|
||||
metavar="DEST",
|
||||
@ -74,20 +74,20 @@ def parse(args):
|
||||
action="append",
|
||||
help="Backport to DEST release (default: current release)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--source",
|
||||
metavar="SOURCE",
|
||||
dest="source_release",
|
||||
help="Backport from SOURCE release (default: devel release)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-S",
|
||||
"--suffix",
|
||||
metavar="SUFFIX",
|
||||
help="Suffix to append to version number (default: ~ppa1 when uploading to a PPA)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-e",
|
||||
"--message",
|
||||
metavar="MESSAGE",
|
||||
@ -95,34 +95,34 @@ def parse(args):
|
||||
help='Changelog message to use instead of "No-change" '
|
||||
"(default: No-change backport to DEST.)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--build",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Build the package before uploading (default: %default)",
|
||||
help="Build the package before uploading (default: %(default)s)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-B",
|
||||
"--builder",
|
||||
metavar="BUILDER",
|
||||
help="Specify the package builder (default: pbuilder)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-U",
|
||||
"--update",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Update the build environment before attempting to build",
|
||||
)
|
||||
parser.add_option("-u", "--upload", metavar="UPLOAD", help="Specify an upload destination")
|
||||
parser.add_option(
|
||||
parser.add_argument("-u", "--upload", metavar="UPLOAD", help="Specify an upload destination")
|
||||
parser.add_argument(
|
||||
"-k", "--key", dest="keyid", help="Specify the key ID to be used for signing."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--dont-sign", dest="keyid", action="store_false", help="Do not sign the upload."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-y",
|
||||
"--yes",
|
||||
dest="prompt",
|
||||
@ -130,16 +130,16 @@ def parse(args):
|
||||
action="store_false",
|
||||
help="Do not prompt before uploading to a PPA",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-v", "--version", metavar="VERSION", help="Package version to backport (or verify)"
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-w",
|
||||
"--workdir",
|
||||
metavar="WORKDIR",
|
||||
help="Specify a working directory (default: temporary dir)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"--release-pocket",
|
||||
default=False,
|
||||
@ -147,45 +147,46 @@ def parse(args):
|
||||
help="Target the release pocket in the .changes file. "
|
||||
"Necessary (and default) for uploads to PPAs",
|
||||
)
|
||||
parser.add_option("-c", "--close", metavar="BUG", help="Bug to close in the changelog entry.")
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-c", "--close", metavar="BUG", help="Bug to close in the changelog entry."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m", "--mirror", metavar="URL", help="Preferred mirror (default: Launchpad)"
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
metavar="INSTANCE",
|
||||
help="Launchpad instance to connect to (default: production)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Don't read config files or environment variables",
|
||||
)
|
||||
parser.add_argument("package_or_dsc", help=argparse.SUPPRESS)
|
||||
|
||||
opts, args = parser.parse_args(args)
|
||||
if len(args) != 1:
|
||||
parser.error("You must specify a single source package or a .dsc URL/path.")
|
||||
config = UDTConfig(opts.no_conf)
|
||||
if opts.builder is None:
|
||||
opts.builder = config.get_value("BUILDER")
|
||||
if not opts.update:
|
||||
opts.update = config.get_value("UPDATE_BUILDER", boolean=True)
|
||||
if opts.workdir is None:
|
||||
opts.workdir = config.get_value("WORKDIR")
|
||||
if opts.lpinstance is None:
|
||||
opts.lpinstance = config.get_value("LPINSTANCE")
|
||||
if opts.upload is None:
|
||||
opts.upload = config.get_value("UPLOAD")
|
||||
if opts.keyid is None:
|
||||
opts.keyid = config.get_value("KEYID")
|
||||
if not opts.upload and not opts.workdir:
|
||||
args = parser.parse_args(argv)
|
||||
config = UDTConfig(args.no_conf)
|
||||
if args.builder is None:
|
||||
args.builder = config.get_value("BUILDER")
|
||||
if not args.update:
|
||||
args.update = config.get_value("UPDATE_BUILDER", boolean=True)
|
||||
if args.workdir is None:
|
||||
args.workdir = config.get_value("WORKDIR")
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
if args.upload is None:
|
||||
args.upload = config.get_value("UPLOAD")
|
||||
if args.keyid is None:
|
||||
args.keyid = config.get_value("KEYID")
|
||||
if not args.upload and not args.workdir:
|
||||
parser.error("Please specify either a working dir or an upload target!")
|
||||
if opts.upload and opts.upload.startswith("ppa:"):
|
||||
opts.release_pocket = True
|
||||
if args.upload and args.upload.startswith("ppa:"):
|
||||
args.release_pocket = True
|
||||
|
||||
return opts, args, config
|
||||
return args, config
|
||||
|
||||
|
||||
def find_release_package(mirror, workdir, package, version, source_release, config):
|
||||
@ -429,14 +430,14 @@ def do_backport(
|
||||
shutil.rmtree(srcdir)
|
||||
|
||||
|
||||
def main(args):
|
||||
def main(argv):
|
||||
ubu_email()
|
||||
|
||||
opts, (package_or_dsc,), config = parse(args[1:])
|
||||
args, config = parse(argv[1:])
|
||||
|
||||
Launchpad.login_anonymously(service=opts.lpinstance)
|
||||
Launchpad.login_anonymously(service=args.lpinstance)
|
||||
|
||||
if not opts.dest_releases:
|
||||
if not args.dest_releases:
|
||||
if lsb_release:
|
||||
distinfo = lsb_release.get_distro_information()
|
||||
try:
|
||||
@ -449,14 +450,14 @@ def main(args):
|
||||
error("Could not run lsb_release to retrieve distribution")
|
||||
|
||||
if current_distro == "Ubuntu":
|
||||
opts.dest_releases = [UbuntuDistroInfo().lts()]
|
||||
args.dest_releases = [UbuntuDistroInfo().lts()]
|
||||
if current_distro == "Debian":
|
||||
opts.dest_releases = [DebianDistroInfo().stable()]
|
||||
args.dest_releases = [DebianDistroInfo().stable()]
|
||||
else:
|
||||
error("Unknown distribution %s, can't guess target release", current_distro)
|
||||
|
||||
if opts.workdir:
|
||||
workdir = os.path.expanduser(opts.workdir)
|
||||
if args.workdir:
|
||||
workdir = os.path.expanduser(args.workdir)
|
||||
else:
|
||||
workdir = tempfile.mkdtemp(prefix="backportpackage-")
|
||||
|
||||
@ -465,30 +466,30 @@ def main(args):
|
||||
|
||||
try:
|
||||
pkg = find_package(
|
||||
opts.mirror, workdir, package_or_dsc, opts.version, opts.source_release, config
|
||||
args.mirror, workdir, args.package_or_dsc, args.version, args.source_release, config
|
||||
)
|
||||
pkg.pull()
|
||||
|
||||
for release in opts.dest_releases:
|
||||
for release in args.dest_releases:
|
||||
do_backport(
|
||||
workdir,
|
||||
pkg,
|
||||
opts.suffix,
|
||||
opts.message,
|
||||
opts.close,
|
||||
args.suffix,
|
||||
args.message,
|
||||
args.close,
|
||||
release,
|
||||
opts.release_pocket,
|
||||
opts.build,
|
||||
opts.builder,
|
||||
opts.update,
|
||||
opts.upload,
|
||||
opts.keyid,
|
||||
opts.prompt,
|
||||
args.release_pocket,
|
||||
args.build,
|
||||
args.builder,
|
||||
args.update,
|
||||
args.upload,
|
||||
args.keyid,
|
||||
args.prompt,
|
||||
)
|
||||
except DownloadError as e:
|
||||
error("%s", str(e))
|
||||
finally:
|
||||
if not opts.workdir:
|
||||
if not args.workdir:
|
||||
shutil.rmtree(workdir)
|
||||
|
||||
|
||||
|
30
bitesize
30
bitesize
@ -21,8 +21,8 @@
|
||||
# Authors:
|
||||
# Daniel Holbach <daniel.holbach@canonical.com>
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
from launchpadlib.errors import HTTPError
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
@ -51,9 +51,8 @@ def tag_bug(bug):
|
||||
|
||||
|
||||
def main():
|
||||
usage = "Usage: %prog <bug number>"
|
||||
opt_parser = OptionParser(usage)
|
||||
opt_parser.add_option(
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] <bug number>")
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
metavar="INSTANCE",
|
||||
@ -61,30 +60,33 @@ def main():
|
||||
dest="lpinstance",
|
||||
default=None,
|
||||
)
|
||||
opt_parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
help="Don't read config files or environment variables.",
|
||||
dest="no_conf",
|
||||
default=False,
|
||||
action="store_true",
|
||||
)
|
||||
(options, args) = opt_parser.parse_args()
|
||||
config = UDTConfig(options.no_conf)
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value("LPINSTANCE")
|
||||
if len(args) < 1:
|
||||
opt_parser.error("Need at least one bug number.")
|
||||
parser.add_argument("bug_number", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
config = UDTConfig(args.no_conf)
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
|
||||
launchpad = Launchpad.login_with("ubuntu-dev-tools", options.lpinstance)
|
||||
launchpad = Launchpad.login_with("ubuntu-dev-tools", args.lpinstance)
|
||||
if launchpad is None:
|
||||
error_out("Couldn't authenticate to Launchpad.")
|
||||
|
||||
# check that the new main bug isn't a duplicate
|
||||
try:
|
||||
bug = launchpad.bugs[args[0]]
|
||||
bug = launchpad.bugs[args.bug_number]
|
||||
except HTTPError as error:
|
||||
if error.response.status == 401:
|
||||
error_out("Don't have enough permissions to access bug %s. %s", args[0], error.content)
|
||||
error_out(
|
||||
"Don't have enough permissions to access bug %s. %s",
|
||||
args.bug_number,
|
||||
error.content,
|
||||
)
|
||||
else:
|
||||
raise
|
||||
if "bitesize" in bug.tags:
|
||||
|
14
check-mir
14
check-mir
@ -24,7 +24,12 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
"""Check if any of a package's build or binary dependencies are in universe or multiverse.
|
||||
|
||||
Run this inside an unpacked source package
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
@ -128,12 +133,7 @@ def check_binary_dependencies(apt_cache, control):
|
||||
|
||||
|
||||
def main():
|
||||
description = (
|
||||
"Check if any of a package's build or binary "
|
||||
+ "dependencies are in universe or multiverse. "
|
||||
+ "Run this inside an unpacked source package"
|
||||
)
|
||||
parser = optparse.OptionParser(description=description)
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.parse_args()
|
||||
apt_cache = apt.Cache()
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
|
||||
@ -33,14 +33,11 @@ from ubuntutools.question import EditFile
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser("%prog [options] filename")
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("A filename must be specified")
|
||||
body = args[0]
|
||||
if not os.path.isfile(body):
|
||||
parser.error("File %s does not exist" % body)
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] filename")
|
||||
parser.add_argument("filename", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
if not os.path.isfile(args.filename):
|
||||
parser.error("File %s does not exist" % args.filename)
|
||||
|
||||
if "UDT_EDIT_WRAPPER_EDITOR" in os.environ:
|
||||
os.environ["EDITOR"] = os.environ["UDT_EDIT_WRAPPER_EDITOR"]
|
||||
@ -58,7 +55,7 @@ def main():
|
||||
|
||||
description = os.environ.get("UDT_EDIT_WRAPPER_FILE_DESCRIPTION", "file")
|
||||
|
||||
EditFile(body, description, placeholders).edit()
|
||||
EditFile(args.filename, description, placeholders).edit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
26
grep-merges
26
grep-merges
@ -22,8 +22,8 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
from httplib2 import Http, HttpLib2Error
|
||||
@ -35,18 +35,12 @@ Logger = getLogger()
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser(
|
||||
usage="%prog [options] [string]",
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="%(prog)s [options] [string]",
|
||||
description="List pending merges from Debian matching string",
|
||||
)
|
||||
args = parser.parse_args()[1]
|
||||
|
||||
if len(args) > 1:
|
||||
parser.error("Too many arguments")
|
||||
elif len(args) == 1:
|
||||
match = args[0]
|
||||
else:
|
||||
match = None
|
||||
parser.add_argument("string", nargs="?", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
ubuntutools.misc.require_utf8()
|
||||
|
||||
@ -82,11 +76,11 @@ def main():
|
||||
|
||||
pretty_uploader = "{} {}".format(author, uploader)
|
||||
if (
|
||||
match is None
|
||||
or match in package
|
||||
or match in author
|
||||
or match in uploader
|
||||
or match in teams
|
||||
args.string is None
|
||||
or args.string in package
|
||||
or args.string in author
|
||||
or args.string in uploader
|
||||
or args.string in teams
|
||||
):
|
||||
Logger.info("%s\t%s", package, pretty_uploader)
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
import debian.changelog
|
||||
@ -51,8 +51,8 @@ def previous_version(package, version, distance):
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser("%prog [options] <package> <version> [distance]")
|
||||
parser.add_option(
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] <package> <version> [distance]")
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--fetch",
|
||||
dest="fetch_only",
|
||||
@ -60,47 +60,42 @@ def main():
|
||||
action="store_true",
|
||||
help="Only fetch the source packages, don't diff.",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--debian-mirror",
|
||||
metavar="DEBIAN_MIRROR",
|
||||
dest="debian_mirror",
|
||||
help="Preferred Debian mirror (default: http://deb.debian.org/debian)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--debsec-mirror",
|
||||
metavar="DEBSEC_MIRROR",
|
||||
dest="debsec_mirror",
|
||||
help="Preferred Debian Security mirror (default: http://security.debian.org)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
dest="no_conf",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Don't read config files or environment variables",
|
||||
)
|
||||
parser.add_argument("package", help=argparse.SUPPRESS)
|
||||
parser.add_argument("version", help=argparse.SUPPRESS)
|
||||
parser.add_argument("distance", default=1, type=int, nargs="?", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
opts, args = parser.parse_args()
|
||||
if len(args) < 2:
|
||||
parser.error("Must specify package and version")
|
||||
elif len(args) > 3:
|
||||
parser.error("Too many arguments")
|
||||
package = args[0]
|
||||
version = args[1]
|
||||
distance = int(args[2]) if len(args) > 2 else 1
|
||||
config = UDTConfig(args.no_conf)
|
||||
if args.debian_mirror is None:
|
||||
args.debian_mirror = config.get_value("DEBIAN_MIRROR")
|
||||
if args.debsec_mirror is None:
|
||||
args.debsec_mirror = config.get_value("DEBSEC_MIRROR")
|
||||
mirrors = [args.debsec_mirror, args.debian_mirror]
|
||||
|
||||
config = UDTConfig(opts.no_conf)
|
||||
if opts.debian_mirror is None:
|
||||
opts.debian_mirror = config.get_value("DEBIAN_MIRROR")
|
||||
if opts.debsec_mirror is None:
|
||||
opts.debsec_mirror = config.get_value("DEBSEC_MIRROR")
|
||||
mirrors = [opts.debsec_mirror, opts.debian_mirror]
|
||||
Logger.info("Downloading %s %s", args.package, args.version)
|
||||
|
||||
Logger.info("Downloading %s %s", package, version)
|
||||
|
||||
newpkg = DebianSourcePackage(package, version, mirrors=mirrors)
|
||||
newpkg = DebianSourcePackage(args.package, args.version, mirrors=mirrors)
|
||||
try:
|
||||
newpkg.pull()
|
||||
except DownloadError as e:
|
||||
@ -108,16 +103,16 @@ def main():
|
||||
sys.exit(1)
|
||||
newpkg.unpack()
|
||||
|
||||
if opts.fetch_only:
|
||||
if args.fetch_only:
|
||||
sys.exit(0)
|
||||
|
||||
oldversion = previous_version(package, version, distance)
|
||||
oldversion = previous_version(args.package, args.version, args.distance)
|
||||
if not oldversion:
|
||||
Logger.error("No previous version could be found")
|
||||
sys.exit(1)
|
||||
Logger.info("Downloading %s %s", package, oldversion)
|
||||
Logger.info("Downloading %s %s", args.package, oldversion)
|
||||
|
||||
oldpkg = DebianSourcePackage(package, oldversion, mirrors=mirrors)
|
||||
oldpkg = DebianSourcePackage(args.package, oldversion, mirrors=mirrors)
|
||||
try:
|
||||
oldpkg.pull()
|
||||
except DownloadError as e:
|
||||
|
@ -14,7 +14,7 @@
|
||||
# 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 argparse
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
@ -269,8 +269,8 @@ def request_backport(package_spph, source, destinations):
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser("%prog [options] package")
|
||||
parser.add_option(
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] package")
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--destination",
|
||||
metavar="DEST",
|
||||
@ -278,53 +278,50 @@ def main():
|
||||
"intermediate releases "
|
||||
"(default: current LTS release)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--source",
|
||||
metavar="SOURCE",
|
||||
help="Backport from SOURCE release (default: current devel release)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
metavar="INSTANCE",
|
||||
default=None,
|
||||
help="Launchpad instance to connect to (default: production).",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
action="store_true",
|
||||
dest="no_conf",
|
||||
default=False,
|
||||
help="Don't read config files or environment variables",
|
||||
)
|
||||
options, args = parser.parse_args()
|
||||
parser.add_argument("package", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("One (and only one) package must be specified")
|
||||
package = args[0]
|
||||
config = UDTConfig(args.no_conf)
|
||||
|
||||
config = UDTConfig(options.no_conf)
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
Launchpad.login(args.lpinstance)
|
||||
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value("LPINSTANCE")
|
||||
Launchpad.login(options.lpinstance)
|
||||
|
||||
if options.source is None:
|
||||
options.source = Distribution("ubuntu").getDevelopmentSeries().name
|
||||
if args.source is None:
|
||||
args.source = Distribution("ubuntu").getDevelopmentSeries().name
|
||||
|
||||
try:
|
||||
destinations = determine_destinations(options.source, options.destination)
|
||||
destinations = determine_destinations(args.source, args.destination)
|
||||
except DestinationException as e:
|
||||
Logger.error(str(e))
|
||||
sys.exit(1)
|
||||
|
||||
disclaimer()
|
||||
|
||||
package_spph = locate_package(package, options.source)
|
||||
package_spph = locate_package(args.package, args.source)
|
||||
|
||||
check_existing(package_spph)
|
||||
request_backport(package_spph, options.source, destinations)
|
||||
request_backport(package_spph, args.source, destinations)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
126
requestsync
126
requestsync
@ -26,7 +26,7 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -48,45 +48,40 @@ Logger = getLogger()
|
||||
|
||||
def main():
|
||||
# Our usage options.
|
||||
usage = "Usage: %prog [options] <source package> [<target release> [base version]]"
|
||||
parser = optparse.OptionParser(usage)
|
||||
usage = "%(prog)s [options] <source package> [<target release> [base version]]"
|
||||
parser = argparse.ArgumentParser(usage=usage)
|
||||
|
||||
parser.add_option(
|
||||
"-d",
|
||||
type="string",
|
||||
dest="dist",
|
||||
default="unstable",
|
||||
help="Debian distribution to sync from.",
|
||||
parser.add_argument(
|
||||
"-d", dest="dist", default="unstable", help="Debian distribution to sync from."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-k",
|
||||
type="string",
|
||||
dest="keyid",
|
||||
default=None,
|
||||
help="GnuPG key ID to use for signing report "
|
||||
"(only used when emailing the sync request).",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
action="store_true",
|
||||
dest="newpkg",
|
||||
default=False,
|
||||
help="Whether package to sync is a new package in Ubuntu.",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--email",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Use a PGP-signed email for filing the sync request, rather than the LP API.",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--lp",
|
||||
dest="deprecated_lp_flag",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help=optparse.SUPPRESS_HELP,
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
metavar="INSTANCE",
|
||||
@ -94,17 +89,17 @@ def main():
|
||||
default=None,
|
||||
help="Launchpad instance to connect to (default: production).",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s", action="store_true", dest="sponsorship", default=False, help="Force sponsorship"
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-C",
|
||||
action="store_true",
|
||||
dest="missing_changelog_ok",
|
||||
default=False,
|
||||
help="Allow changelog to be manually filled in when missing",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-e",
|
||||
action="store_true",
|
||||
dest="ffe",
|
||||
@ -113,49 +108,47 @@ def main():
|
||||
"syncs, changes default subscription to the "
|
||||
"appropriate release team.",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
action="store_true",
|
||||
dest="no_conf",
|
||||
default=False,
|
||||
help="Don't read config files or environment variables",
|
||||
)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if not len(args):
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
parser.add_argument("source_package", help=argparse.SUPPRESS)
|
||||
parser.add_argument("release", nargs="?", help=argparse.SUPPRESS)
|
||||
parser.add_argument("base_version", nargs="?", type=Version, help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
require_utf8()
|
||||
|
||||
config = UDTConfig(options.no_conf)
|
||||
config = UDTConfig(args.no_conf)
|
||||
|
||||
if options.deprecated_lp_flag:
|
||||
if args.deprecated_lp_flag:
|
||||
Logger.info("The --lp flag is now default, ignored.")
|
||||
if options.email:
|
||||
options.lpapi = False
|
||||
if args.email:
|
||||
args.lpapi = False
|
||||
else:
|
||||
options.lpapi = config.get_value("USE_LPAPI", default=True, boolean=True)
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value("LPINSTANCE")
|
||||
args.lpapi = config.get_value("USE_LPAPI", default=True, boolean=True)
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
|
||||
if options.keyid is None:
|
||||
options.keyid = config.get_value("KEYID")
|
||||
if args.keyid is None:
|
||||
args.keyid = config.get_value("KEYID")
|
||||
|
||||
if not options.lpapi:
|
||||
if options.lpinstance == "production":
|
||||
if not args.lpapi:
|
||||
if args.lpinstance == "production":
|
||||
bug_mail_domain = "bugs.launchpad.net"
|
||||
elif options.lpinstance == "staging":
|
||||
elif args.lpinstance == "staging":
|
||||
bug_mail_domain = "bugs.staging.launchpad.net"
|
||||
else:
|
||||
Logger.error("Error: Unknown launchpad instance: %s", options.lpinstance)
|
||||
Logger.error("Error: Unknown launchpad instance: %s", args.lpinstance)
|
||||
sys.exit(1)
|
||||
|
||||
mailserver_host = config.get_value(
|
||||
"SMTP_SERVER", default=None, compat_keys=["UBUSMTP", "DEBSMTP"]
|
||||
)
|
||||
if not options.lpapi and not mailserver_host:
|
||||
if not args.lpapi and not mailserver_host:
|
||||
try:
|
||||
import DNS
|
||||
|
||||
@ -174,7 +167,7 @@ def main():
|
||||
mailserver_pass = config.get_value("SMTP_PASS", compat_keys=["UBUSMTP_PASS", "DEBSMTP_PASS"])
|
||||
|
||||
# import the needed requestsync module
|
||||
if options.lpapi:
|
||||
if args.lpapi:
|
||||
from ubuntutools.lp.lpapicache import Distribution, Launchpad
|
||||
from ubuntutools.requestsync.lp import (
|
||||
check_existing_reports,
|
||||
@ -190,7 +183,7 @@ def main():
|
||||
|
||||
try:
|
||||
# devel for changelogUrl()
|
||||
Launchpad.login(service=options.lpinstance, api_version="devel")
|
||||
Launchpad.login(service=args.lpinstance, api_version="devel")
|
||||
except IOError:
|
||||
sys.exit(1)
|
||||
else:
|
||||
@ -210,35 +203,25 @@ def main():
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
newsource = options.newpkg
|
||||
sponsorship = options.sponsorship
|
||||
distro = options.dist
|
||||
ffe = options.ffe
|
||||
lpapi = options.lpapi
|
||||
newsource = args.newpkg
|
||||
sponsorship = args.sponsorship
|
||||
distro = args.dist
|
||||
ffe = args.ffe
|
||||
lpapi = args.lpapi
|
||||
need_interaction = False
|
||||
force_base_version = None
|
||||
srcpkg = args[0]
|
||||
srcpkg = args.source_package
|
||||
|
||||
if len(args) == 1:
|
||||
if not args.release:
|
||||
if lpapi:
|
||||
release = Distribution("ubuntu").getDevelopmentSeries().name
|
||||
args.release = Distribution("ubuntu").getDevelopmentSeries().name
|
||||
else:
|
||||
ubu_info = UbuntuDistroInfo()
|
||||
release = ubu_info.devel()
|
||||
Logger.warning("Target release missing - assuming %s", release)
|
||||
elif len(args) == 2:
|
||||
release = args[1]
|
||||
elif len(args) == 3:
|
||||
release = args[1]
|
||||
force_base_version = Version(args[2])
|
||||
else:
|
||||
Logger.error("Too many arguments.")
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
args.release = ubu_info.devel()
|
||||
Logger.warning("Target release missing - assuming %s", args.release)
|
||||
|
||||
# Get the current Ubuntu source package
|
||||
try:
|
||||
ubuntu_srcpkg = get_ubuntu_srcpkg(srcpkg, release, "Proposed")
|
||||
ubuntu_srcpkg = get_ubuntu_srcpkg(srcpkg, args.release, "Proposed")
|
||||
ubuntu_version = Version(ubuntu_srcpkg.getVersion())
|
||||
ubuntu_component = ubuntu_srcpkg.getComponent()
|
||||
newsource = False # override the -n flag
|
||||
@ -247,7 +230,7 @@ def main():
|
||||
ubuntu_version = Version("~")
|
||||
ubuntu_component = None # Set after getting the Debian info
|
||||
if not newsource:
|
||||
Logger.info("'%s' doesn't exist in 'Ubuntu %s'.", srcpkg, release)
|
||||
Logger.info("'%s' doesn't exist in 'Ubuntu %s'.", srcpkg, args.release)
|
||||
Logger.info("Do you want to sync a new package?")
|
||||
confirmation_prompt()
|
||||
newsource = True
|
||||
@ -274,7 +257,7 @@ def main():
|
||||
ubuntu_component = "multiverse"
|
||||
|
||||
# Stop if Ubuntu has already the version from Debian or a newer version
|
||||
if (ubuntu_version >= debian_version) and options.lpapi:
|
||||
if (ubuntu_version >= debian_version) and args.lpapi:
|
||||
# try rmadison
|
||||
import ubuntutools.requestsync.mail
|
||||
|
||||
@ -302,7 +285,7 @@ def main():
|
||||
|
||||
# -s flag not specified - check if we do need sponsorship
|
||||
if not sponsorship:
|
||||
sponsorship = need_sponsorship(srcpkg, ubuntu_component, release)
|
||||
sponsorship = need_sponsorship(srcpkg, ubuntu_component, args.release)
|
||||
|
||||
if not sponsorship and not ffe:
|
||||
Logger.error(
|
||||
@ -350,15 +333,18 @@ def main():
|
||||
if need_interaction:
|
||||
confirmation_prompt()
|
||||
|
||||
base_version = force_base_version or ubuntu_version
|
||||
base_version = args.base_version or ubuntu_version
|
||||
|
||||
if newsource:
|
||||
report += "All changelog entries:\n\n"
|
||||
else:
|
||||
report += "Changelog entries since current %s version %s:\n\n" % (release, ubuntu_version)
|
||||
report += "Changelog entries since current %s version %s:\n\n" % (
|
||||
args.release,
|
||||
ubuntu_version,
|
||||
)
|
||||
changelog = debian_srcpkg.getChangelog(since_version=base_version)
|
||||
if not changelog:
|
||||
if not options.missing_changelog_ok:
|
||||
if not args.missing_changelog_ok:
|
||||
Logger.error(
|
||||
"Did not retrieve any changelog entries. "
|
||||
"Do you need to specify '-C'? "
|
||||
@ -408,7 +394,7 @@ def main():
|
||||
title,
|
||||
report,
|
||||
bug_mail_domain,
|
||||
options.keyid,
|
||||
args.keyid,
|
||||
email_from,
|
||||
mailserver_host,
|
||||
mailserver_port,
|
||||
|
@ -51,7 +51,7 @@ def main():
|
||||
"-r",
|
||||
"--release",
|
||||
default=default_release,
|
||||
help="Query dependencies in RELEASE. Default: %s" % default_release,
|
||||
help="Query dependencies in RELEASE. Default: %(default)s",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-R",
|
||||
|
@ -17,10 +17,10 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import gzip
|
||||
import json
|
||||
import optparse
|
||||
import os
|
||||
import time
|
||||
import urllib.request
|
||||
@ -117,34 +117,32 @@ def output_by_source(index, by_source):
|
||||
|
||||
def main():
|
||||
"""Query which images the specified packages are on"""
|
||||
parser = optparse.OptionParser("%prog [options] package...")
|
||||
parser.add_option(
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] package...")
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--binary",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Binary packages are being specified, not source packages (fast)",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-u",
|
||||
"--data-url",
|
||||
metavar="URL",
|
||||
default=DATA_URL,
|
||||
help="URL for the seeded packages index. Default: UbuntuWire",
|
||||
)
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if len(args) < 1:
|
||||
parser.error("At least one package must be specified")
|
||||
parser.add_argument("packages", metavar="package", nargs="+", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Login anonymously to LP
|
||||
Launchpad.login_anonymously()
|
||||
|
||||
index = load_index(options.data_url)
|
||||
if options.binary:
|
||||
output_binaries(index, args)
|
||||
index = load_index(args.data_url)
|
||||
if args.binary:
|
||||
output_binaries(index, args.packages)
|
||||
else:
|
||||
binaries = resolve_binaries(args)
|
||||
binaries = resolve_binaries(args.packages)
|
||||
output_by_source(index, binaries)
|
||||
|
||||
|
||||
|
137
sponsor-patch
137
sponsor-patch
@ -17,8 +17,8 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
@ -35,169 +35,132 @@ Logger = getLogger()
|
||||
def parse(script_name):
|
||||
"""Parse the command line parameters."""
|
||||
usage = (
|
||||
"%s [options] <bug number>\n" % (script_name)
|
||||
+ "One of --upload, --workdir, or --sponsor must be specified."
|
||||
"%(prog)s [options] <bug number>\n"
|
||||
"One of --upload, --workdir, or --sponsor must be specified."
|
||||
)
|
||||
epilog = "See %s(1) for more info." % (script_name)
|
||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||
parser = argparse.ArgumentParser(usage=usage, epilog=epilog)
|
||||
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--build",
|
||||
dest="build",
|
||||
help="Build the package with the specified builder.",
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser.add_option(
|
||||
"-B",
|
||||
"--builder",
|
||||
dest="builder",
|
||||
default=None,
|
||||
help="Specify the package builder (default pbuilder)",
|
||||
parser.add_argument(
|
||||
"-B", "--builder", dest="builder", help="Specify the package builder (default pbuilder)"
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-e",
|
||||
"--edit",
|
||||
help="launch sub-shell to allow editing of the patch",
|
||||
dest="edit",
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser.add_option(
|
||||
"-k",
|
||||
"--key",
|
||||
dest="keyid",
|
||||
default=None,
|
||||
help="Specify the key ID to be used for signing.",
|
||||
parser.add_argument(
|
||||
"-k", "--key", dest="keyid", help="Specify the key ID to be used for signing."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
dest="lpinstance",
|
||||
default=None,
|
||||
help="Launchpad instance to connect to (default: production)",
|
||||
metavar="INSTANCE",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--no-conf",
|
||||
dest="no_conf",
|
||||
default=False,
|
||||
help="Don't read config files or environment variables.",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--sponsor",
|
||||
help="sponsoring; equals -b -u ubuntu",
|
||||
dest="sponsoring",
|
||||
action="store_true",
|
||||
default=False,
|
||||
)
|
||||
parser.add_option(
|
||||
"-u",
|
||||
"--upload",
|
||||
dest="upload",
|
||||
default=None,
|
||||
help="Specify an upload destination (default none).",
|
||||
parser.add_argument(
|
||||
"-u", "--upload", dest="upload", help="Specify an upload destination (default none)."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-U",
|
||||
"--update",
|
||||
dest="update",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Update the build environment before building.",
|
||||
)
|
||||
parser.add_option(
|
||||
"-v",
|
||||
"--verbose",
|
||||
help="print more information",
|
||||
dest="verbose",
|
||||
action="store_true",
|
||||
default=False,
|
||||
parser.add_argument(
|
||||
"-v", "--verbose", help="print more information", dest="verbose", action="store_true"
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-w",
|
||||
"--workdir",
|
||||
dest="workdir",
|
||||
default=None,
|
||||
help="Specify a working directory (default is a "
|
||||
"temporary directory, deleted afterwards).",
|
||||
)
|
||||
parser.add_argument("bug_number", type=int, help=argparse.SUPPRESS)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if options.verbose:
|
||||
args = parser.parse_args()
|
||||
if args.verbose:
|
||||
Logger.setLevel(logging.DEBUG)
|
||||
check_dependencies()
|
||||
|
||||
if len(args) == 0:
|
||||
Logger.error("No bug number specified.")
|
||||
sys.exit(1)
|
||||
elif len(args) > 1:
|
||||
Logger.error("Multiple bug numbers specified: %s", ", ".join(args))
|
||||
sys.exit(1)
|
||||
config = UDTConfig(args.no_conf)
|
||||
if args.builder is None:
|
||||
args.builder = config.get_value("BUILDER")
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
if not args.update:
|
||||
args.update = config.get_value("UPDATE_BUILDER", boolean=True)
|
||||
if args.workdir is None:
|
||||
args.workdir = config.get_value("WORKDIR")
|
||||
if args.keyid is None:
|
||||
args.keyid = config.get_value("KEYID")
|
||||
|
||||
bug_number = args[0]
|
||||
if bug_number.isdigit():
|
||||
bug_number = int(bug_number)
|
||||
else:
|
||||
Logger.error("Invalid bug number specified: %s", bug_number)
|
||||
sys.exit(1)
|
||||
if args.sponsoring:
|
||||
args.build = True
|
||||
args.upload = "ubuntu"
|
||||
|
||||
config = UDTConfig(options.no_conf)
|
||||
if options.builder is None:
|
||||
options.builder = config.get_value("BUILDER")
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value("LPINSTANCE")
|
||||
if not options.update:
|
||||
options.update = config.get_value("UPDATE_BUILDER", boolean=True)
|
||||
if options.workdir is None:
|
||||
options.workdir = config.get_value("WORKDIR")
|
||||
if options.keyid is None:
|
||||
options.keyid = config.get_value("KEYID")
|
||||
|
||||
if options.sponsoring:
|
||||
options.build = True
|
||||
options.upload = "ubuntu"
|
||||
|
||||
return (options, bug_number)
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
(options, bug_number) = parse(script_name)
|
||||
args = parse(script_name)
|
||||
|
||||
builder = get_builder(options.builder)
|
||||
builder = get_builder(args.builder)
|
||||
if not builder:
|
||||
sys.exit(1)
|
||||
|
||||
if not options.upload and not options.workdir:
|
||||
if not args.upload and not args.workdir:
|
||||
Logger.error("Please specify either a working directory or an upload target!")
|
||||
sys.exit(1)
|
||||
|
||||
if options.workdir is None:
|
||||
if args.workdir is None:
|
||||
workdir = tempfile.mkdtemp(prefix=script_name + "-")
|
||||
else:
|
||||
workdir = options.workdir
|
||||
workdir = args.workdir
|
||||
|
||||
try:
|
||||
sponsor_patch(
|
||||
bug_number,
|
||||
options.build,
|
||||
args.bug_number,
|
||||
args.build,
|
||||
builder,
|
||||
options.edit,
|
||||
options.keyid,
|
||||
options.lpinstance,
|
||||
options.update,
|
||||
options.upload,
|
||||
args.edit,
|
||||
args.keyid,
|
||||
args.lpinstance,
|
||||
args.update,
|
||||
args.upload,
|
||||
workdir,
|
||||
)
|
||||
except KeyboardInterrupt:
|
||||
Logger.error("User abort.")
|
||||
sys.exit(2)
|
||||
finally:
|
||||
if options.workdir is None:
|
||||
if args.workdir is None:
|
||||
shutil.rmtree(workdir)
|
||||
|
||||
|
||||
|
@ -22,7 +22,12 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import optparse
|
||||
"""Submit the Ubuntu changes in a package to Debian.
|
||||
|
||||
Run inside an unpacked Ubuntu source package.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@ -235,11 +240,7 @@ reportbug --configure for its configuration wizard.
|
||||
|
||||
|
||||
def main():
|
||||
description = (
|
||||
"Submit the Ubuntu changes in a package to Debian. "
|
||||
+ "Run inside an unpacked Ubuntu source package."
|
||||
)
|
||||
parser = optparse.OptionParser(description=description)
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.parse_args()
|
||||
|
||||
if not os.path.exists("/usr/bin/reportbug"):
|
||||
|
194
syncpackage
194
syncpackage
@ -20,9 +20,9 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import argparse
|
||||
import fnmatch
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -509,15 +509,15 @@ def close_bugs(bugs, package, version, changes, sponsoree):
|
||||
def parse():
|
||||
"""Parse given command-line parameters."""
|
||||
|
||||
usage = "%prog [options] <.dsc URL/path or package name>"
|
||||
usage = "%(prog)s [options] <.dsc URL/path or package name>"
|
||||
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||
parser = argparse.ArgumentParser(usage=usage, epilog=epilog)
|
||||
|
||||
parser.add_option("-d", "--distribution", help="Debian distribution to sync from.")
|
||||
parser.add_option("-r", "--release", help="Specify target Ubuntu release.")
|
||||
parser.add_option("-V", "--debian-version", help="Specify the version to sync from.")
|
||||
parser.add_option("-c", "--component", help="Specify the Debian component to sync from.")
|
||||
parser.add_option(
|
||||
parser.add_argument("-d", "--distribution", help="Debian distribution to sync from.")
|
||||
parser.add_argument("-r", "--release", help="Specify target Ubuntu release.")
|
||||
parser.add_argument("-V", "--debian-version", help="Specify the version to sync from.")
|
||||
parser.add_argument("-c", "--component", help="Specify the Debian component to sync from.")
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--bug",
|
||||
metavar="BUG",
|
||||
@ -526,173 +526,151 @@ def parse():
|
||||
default=list(),
|
||||
help="Mark Launchpad bug BUG as being fixed by this upload.",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--sponsor",
|
||||
metavar="USERNAME",
|
||||
dest="sponsoree",
|
||||
default=None,
|
||||
help="Sponsor the sync for USERNAME (a Launchpad username).",
|
||||
)
|
||||
parser.add_option(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Display more progress information.",
|
||||
parser.add_argument(
|
||||
"-v", "--verbose", action="store_true", help="Display more progress information."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-F",
|
||||
"--fakesync",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Perform a fakesync (a sync where Debian and "
|
||||
"Ubuntu have a .orig.tar mismatch). "
|
||||
"This implies --no-lp and will leave a signed "
|
||||
".changes file for you to upload.",
|
||||
)
|
||||
parser.add_option(
|
||||
"-f",
|
||||
"--force",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Force sync over the top of Ubuntu changes.",
|
||||
parser.add_argument(
|
||||
"-f", "--force", action="store_true", help="Force sync over the top of Ubuntu changes."
|
||||
)
|
||||
parser.add_option(
|
||||
"--no-conf",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Don't read config files or environment variables.",
|
||||
parser.add_argument(
|
||||
"--no-conf", action="store_true", help="Don't read config files or environment variables."
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--lpinstance",
|
||||
metavar="INSTANCE",
|
||||
help="Launchpad instance to connect to (default: production).",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"--simulate",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Show what would be done, but don't actually do it.",
|
||||
)
|
||||
|
||||
no_lp = optparse.OptionGroup(
|
||||
parser,
|
||||
no_lp = parser.add_argument_group(
|
||||
"Local sync preparation options",
|
||||
"Options that only apply when using --no-lp. "
|
||||
"WARNING: The use of --no-lp is not recommended for uploads "
|
||||
"targeted at Ubuntu. "
|
||||
"The archive-admins discourage its use, except for fakesyncs.",
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"--no-lp",
|
||||
dest="lp",
|
||||
action="store_false",
|
||||
default=True,
|
||||
help="Construct sync locally, rather than letting "
|
||||
"Launchpad copy the package directly. "
|
||||
"It will leave a signed .changes file for you to "
|
||||
"upload.",
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"-n",
|
||||
"--uploader-name",
|
||||
help="Use UPLOADER_NAME as the name of the maintainer for this upload.",
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"-e",
|
||||
"--uploader-email",
|
||||
help="Use UPLOADER_EMAIL as email address of the maintainer for this upload.",
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"-k", "--key", dest="keyid", help="Specify the key ID to be used for signing."
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"--dont-sign", dest="keyid", action="store_false", help="Do not sign the upload."
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"-D",
|
||||
"--debian-mirror",
|
||||
metavar="DEBIAN_MIRROR",
|
||||
help="Preferred Debian mirror (default: %s)" % UDTConfig.defaults["DEBIAN_MIRROR"],
|
||||
)
|
||||
no_lp.add_option(
|
||||
no_lp.add_argument(
|
||||
"-U",
|
||||
"--ubuntu-mirror",
|
||||
metavar="UBUNTU_MIRROR",
|
||||
help="Preferred Ubuntu mirror (default: %s)" % UDTConfig.defaults["UBUNTU_MIRROR"],
|
||||
)
|
||||
parser.add_option_group(no_lp)
|
||||
parser.add_argument("package", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.fakesync:
|
||||
options.lp = False
|
||||
|
||||
if len(args) == 0:
|
||||
parser.error("No .dsc URL/path or package name specified.")
|
||||
if len(args) > 1:
|
||||
parser.error("Multiple .dsc URLs/paths or package names specified: " + ", ".join(args))
|
||||
if args.fakesync:
|
||||
args.lp = False
|
||||
|
||||
try:
|
||||
options.bugs = [int(b) for b in options.bugs]
|
||||
args.bugs = [int(b) for b in args.bugs]
|
||||
except TypeError:
|
||||
parser.error("Invalid bug number(s) specified.")
|
||||
|
||||
if options.component not in (None, "main", "contrib", "non-free"):
|
||||
if args.component not in (None, "main", "contrib", "non-free"):
|
||||
parser.error(
|
||||
"%s is not a valid Debian component. "
|
||||
"It should be one of main, contrib, or non-free." % options.component
|
||||
"It should be one of main, contrib, or non-free." % args.component
|
||||
)
|
||||
|
||||
if options.lp and options.uploader_name:
|
||||
if args.lp and args.uploader_name:
|
||||
parser.error("Uploader name can only be overridden using --no-lp.")
|
||||
if options.lp and options.uploader_email:
|
||||
if args.lp and args.uploader_email:
|
||||
parser.error("Uploader email address can only be overridden using --no-lp.")
|
||||
# --key, --dont-sign, --debian-mirror, and --ubuntu-mirror are just
|
||||
# ignored with options.lp, and do not require warnings.
|
||||
# ignored with args.lp, and do not require warnings.
|
||||
|
||||
if options.lp:
|
||||
if args[0].endswith(".dsc"):
|
||||
if args.lp:
|
||||
if args.package.endswith(".dsc"):
|
||||
parser.error(".dsc files can only be synced using --no-lp.")
|
||||
|
||||
return (options, args[0])
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
"""Handle parameters and get the ball rolling"""
|
||||
(options, package) = parse()
|
||||
args = parse()
|
||||
|
||||
if options.verbose:
|
||||
if args.verbose:
|
||||
Logger.setLevel("DEBUG")
|
||||
config = UDTConfig(options.no_conf)
|
||||
if options.debian_mirror is None:
|
||||
options.debian_mirror = config.get_value("DEBIAN_MIRROR")
|
||||
if options.ubuntu_mirror is None:
|
||||
options.ubuntu_mirror = config.get_value("UBUNTU_MIRROR")
|
||||
config = UDTConfig(args.no_conf)
|
||||
if args.debian_mirror is None:
|
||||
args.debian_mirror = config.get_value("DEBIAN_MIRROR")
|
||||
if args.ubuntu_mirror is None:
|
||||
args.ubuntu_mirror = config.get_value("UBUNTU_MIRROR")
|
||||
|
||||
if options.keyid is None:
|
||||
options.keyid = config.get_value("KEYID")
|
||||
if args.keyid is None:
|
||||
args.keyid = config.get_value("KEYID")
|
||||
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value("LPINSTANCE")
|
||||
if args.lpinstance is None:
|
||||
args.lpinstance = config.get_value("LPINSTANCE")
|
||||
|
||||
try:
|
||||
# devel for copyPackage and changelogUrl
|
||||
kwargs = {"service": options.lpinstance, "api_version": "devel"}
|
||||
if options.lp and not options.simulate:
|
||||
kwargs = {"service": args.lpinstance, "api_version": "devel"}
|
||||
if args.lp and not args.simulate:
|
||||
Launchpad.login(**kwargs)
|
||||
else:
|
||||
Launchpad.login_anonymously(**kwargs)
|
||||
except IOError:
|
||||
sys.exit(1)
|
||||
|
||||
if options.release is None:
|
||||
if args.release is None:
|
||||
ubuntu = Launchpad.distributions["ubuntu"]
|
||||
options.release = "%s-proposed" % ubuntu.current_series.name
|
||||
args.release = "%s-proposed" % ubuntu.current_series.name
|
||||
|
||||
if not options.fakesync and not options.lp:
|
||||
if not args.fakesync and not args.lp:
|
||||
Logger.warning(
|
||||
"The use of --no-lp is not recommended for uploads "
|
||||
"targeted at Ubuntu. "
|
||||
@ -701,23 +679,23 @@ def main():
|
||||
)
|
||||
|
||||
sponsoree = None
|
||||
if options.sponsoree:
|
||||
if args.sponsoree:
|
||||
try:
|
||||
sponsoree = PersonTeam(options.sponsoree)
|
||||
sponsoree = PersonTeam(args.sponsoree)
|
||||
except KeyError:
|
||||
Logger.error('Cannot find the username "%s" in Launchpad.', options.sponsoree)
|
||||
Logger.error('Cannot find the username "%s" in Launchpad.', args.sponsoree)
|
||||
sys.exit(1)
|
||||
|
||||
if sponsoree and options.uploader_name is None:
|
||||
options.uploader_name = sponsoree.display_name
|
||||
elif options.uploader_name is None:
|
||||
options.uploader_name = ubu_email(export=False)[0]
|
||||
if sponsoree and args.uploader_name is None:
|
||||
args.uploader_name = sponsoree.display_name
|
||||
elif args.uploader_name is None:
|
||||
args.uploader_name = ubu_email(export=False)[0]
|
||||
|
||||
if sponsoree and options.uploader_email is None:
|
||||
if sponsoree and args.uploader_email is None:
|
||||
try:
|
||||
options.uploader_email = sponsoree.preferred_email_address.email
|
||||
args.uploader_email = sponsoree.preferred_email_address.email
|
||||
except ValueError:
|
||||
if not options.lp:
|
||||
if not args.lp:
|
||||
Logger.error(
|
||||
"%s doesn't have a publicly visible e-mail "
|
||||
"address in LP, please provide one "
|
||||
@ -725,16 +703,16 @@ def main():
|
||||
sponsoree.display_name,
|
||||
)
|
||||
sys.exit(1)
|
||||
elif options.uploader_email is None:
|
||||
options.uploader_email = ubu_email(export=False)[1]
|
||||
elif args.uploader_email is None:
|
||||
args.uploader_email = ubu_email(export=False)[1]
|
||||
|
||||
src_pkg = fetch_source_pkg(
|
||||
package,
|
||||
options.distribution,
|
||||
options.debian_version,
|
||||
options.component,
|
||||
options.release,
|
||||
options.debian_mirror,
|
||||
args.package,
|
||||
args.distribution,
|
||||
args.debian_version,
|
||||
args.component,
|
||||
args.release,
|
||||
args.debian_mirror,
|
||||
)
|
||||
|
||||
blacklisted, comments = is_blacklisted(src_pkg.source)
|
||||
@ -751,7 +729,7 @@ def main():
|
||||
src_pkg.source,
|
||||
)
|
||||
else:
|
||||
if options.fakesync:
|
||||
if args.fakesync:
|
||||
messages += ["Doing a fakesync, overriding blacklist."]
|
||||
else:
|
||||
blacklist_fail = True
|
||||
@ -780,22 +758,22 @@ def main():
|
||||
if blacklist_fail:
|
||||
sys.exit(1)
|
||||
|
||||
if options.lp:
|
||||
copy(src_pkg, options.release, options.bugs, sponsoree, options.simulate, options.force)
|
||||
if args.lp:
|
||||
copy(src_pkg, args.release, args.bugs, sponsoree, args.simulate, args.force)
|
||||
else:
|
||||
os.environ["DEB_VENDOR"] = "Ubuntu"
|
||||
sync_dsc(
|
||||
src_pkg,
|
||||
options.distribution,
|
||||
options.release,
|
||||
options.uploader_name,
|
||||
options.uploader_email,
|
||||
options.bugs,
|
||||
options.ubuntu_mirror,
|
||||
options.keyid,
|
||||
options.simulate,
|
||||
options.force,
|
||||
options.fakesync,
|
||||
args.distribution,
|
||||
args.release,
|
||||
args.uploader_name,
|
||||
args.uploader_email,
|
||||
args.bugs,
|
||||
args.ubuntu_mirror,
|
||||
args.keyid,
|
||||
args.simulate,
|
||||
args.force,
|
||||
args.fakesync,
|
||||
)
|
||||
|
||||
|
||||
|
91
ubuntu-build
91
ubuntu-build
@ -25,8 +25,8 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from optparse import OptionGroup, OptionParser
|
||||
|
||||
from launchpadlib.credentials import TokenAuthorizationException
|
||||
|
||||
@ -44,7 +44,7 @@ Logger = getLogger()
|
||||
|
||||
def main():
|
||||
# Usage.
|
||||
usage = "%prog <srcpackage> <release> <operation>\n\n"
|
||||
usage = "%(prog)s <srcpackage> <release> <operation>\n\n"
|
||||
usage += "Where operation may be one of: rescore, retry, or status.\n"
|
||||
usage += "Only Launchpad Buildd Admins may rescore package builds."
|
||||
|
||||
@ -68,18 +68,16 @@ def main():
|
||||
)
|
||||
|
||||
# Prepare our option parser.
|
||||
opt_parser = OptionParser(usage)
|
||||
parser = argparse.ArgumentParser(usage=usage)
|
||||
|
||||
# Retry options
|
||||
retry_rescore_options = OptionGroup(
|
||||
opt_parser,
|
||||
retry_rescore_options = parser.add_argument_group(
|
||||
"Retry and rescore options",
|
||||
"These options may only be used with the 'retry' and 'rescore' operations.",
|
||||
)
|
||||
retry_rescore_options.add_option(
|
||||
retry_rescore_options.add_argument(
|
||||
"-a",
|
||||
"--arch",
|
||||
type="string",
|
||||
action="append",
|
||||
dest="architecture",
|
||||
help="Rebuild or rescore a specific "
|
||||
@ -88,69 +86,54 @@ def main():
|
||||
)
|
||||
|
||||
# Batch processing options
|
||||
batch_options = OptionGroup(
|
||||
opt_parser,
|
||||
batch_options = parser.add_argument_group(
|
||||
"Batch processing",
|
||||
"These options and parameter ordering is only "
|
||||
"available in --batch mode.\nUsage: "
|
||||
"ubuntu-build --batch [options] <package>...",
|
||||
)
|
||||
batch_options.add_option(
|
||||
"--batch", action="store_true", dest="batch", default=False, help="Enable batch mode"
|
||||
batch_options.add_argument(
|
||||
"--batch", action="store_true", dest="batch", help="Enable batch mode"
|
||||
)
|
||||
batch_options.add_option(
|
||||
batch_options.add_argument(
|
||||
"--series",
|
||||
action="store",
|
||||
dest="series",
|
||||
type="string",
|
||||
help="Selects the Ubuntu series to operate on (default: current development series)",
|
||||
)
|
||||
batch_options.add_option(
|
||||
"--retry",
|
||||
action="store_true",
|
||||
dest="retry",
|
||||
default=False,
|
||||
help="Retry builds (give-back).",
|
||||
batch_options.add_argument(
|
||||
"--retry", action="store_true", dest="retry", help="Retry builds (give-back)."
|
||||
)
|
||||
batch_options.add_option(
|
||||
batch_options.add_argument(
|
||||
"--rescore",
|
||||
action="store",
|
||||
dest="priority",
|
||||
type="int",
|
||||
type=int,
|
||||
help="Rescore builds to <priority>.",
|
||||
)
|
||||
batch_options.add_option(
|
||||
batch_options.add_argument(
|
||||
"--arch2",
|
||||
action="append",
|
||||
dest="architecture",
|
||||
type="string",
|
||||
help="Affect only 'architecture' (can be used "
|
||||
"several times). Valid architectures are: %s." % ", ".join(valid_archs),
|
||||
)
|
||||
|
||||
# Add the retry options to the main group.
|
||||
opt_parser.add_option_group(retry_rescore_options)
|
||||
# Add the batch mode to the main group.
|
||||
opt_parser.add_option_group(batch_options)
|
||||
parser.add_argument("packages", metavar="package", nargs="+", help=argparse.SUPPRESS)
|
||||
|
||||
# Parse our options.
|
||||
(options, args) = opt_parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
if not len(args):
|
||||
opt_parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if not options.batch:
|
||||
if not args.batch:
|
||||
# Check we have the correct number of arguments.
|
||||
if len(args) < 3:
|
||||
opt_parser.error("Incorrect number of arguments.")
|
||||
if len(args.packages) < 3:
|
||||
parser.error("Incorrect number of arguments.")
|
||||
|
||||
try:
|
||||
package = str(args[0]).lower()
|
||||
release = str(args[1]).lower()
|
||||
operation = str(args[2]).lower()
|
||||
package = str(args.packages[0]).lower()
|
||||
release = str(args.packages[1]).lower()
|
||||
operation = str(args.packages[2]).lower()
|
||||
except IndexError:
|
||||
opt_parser.print_help()
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Check our operation.
|
||||
@ -160,9 +143,9 @@ def main():
|
||||
|
||||
# If the user has specified an architecture to build, we only wish to
|
||||
# rebuild it and nothing else.
|
||||
if options.architecture:
|
||||
if options.architecture[0] not in valid_archs:
|
||||
Logger.error("Invalid architecture specified: %s.", options.architecture[0])
|
||||
if args.architecture:
|
||||
if args.architecture[0] not in valid_archs:
|
||||
Logger.error("Invalid architecture specified: %s.", args.architecture[0])
|
||||
sys.exit(1)
|
||||
else:
|
||||
one_arch = True
|
||||
@ -236,7 +219,7 @@ def main():
|
||||
# Output list of arches for package and their status.
|
||||
done = False
|
||||
for build in builds:
|
||||
if one_arch and build.arch_tag != options.architecture[0]:
|
||||
if one_arch and build.arch_tag != args.architecture[0]:
|
||||
# Skip this architecture.
|
||||
continue
|
||||
|
||||
@ -267,16 +250,16 @@ def main():
|
||||
|
||||
# Batch mode
|
||||
|
||||
if not options.architecture:
|
||||
if not args.architecture:
|
||||
# no specific architectures specified, assume all valid ones
|
||||
archs = valid_archs
|
||||
else:
|
||||
archs = set(options.architecture)
|
||||
archs = set(args.architecture)
|
||||
|
||||
# filter out duplicate and invalid architectures
|
||||
archs.intersection_update(valid_archs)
|
||||
|
||||
release = options.series
|
||||
release = args.series
|
||||
if not release:
|
||||
release = Distribution("ubuntu").getDevelopmentSeries().name + "-proposed"
|
||||
try:
|
||||
@ -294,13 +277,13 @@ def main():
|
||||
me = PersonTeam.me
|
||||
|
||||
# Check permisions (part 1): Rescoring can only be done by buildd admins
|
||||
can_rescore = (options.priority and me.isLpTeamMember("launchpad-buildd-admins")) or False
|
||||
if options.priority and not can_rescore:
|
||||
can_rescore = (args.priority and me.isLpTeamMember("launchpad-buildd-admins")) or False
|
||||
if args.priority and not can_rescore:
|
||||
Logger.error(
|
||||
"You don't have the permissions to rescore builds. Ignoring your rescore request."
|
||||
)
|
||||
|
||||
for pkg in args:
|
||||
for pkg in args.packages:
|
||||
try:
|
||||
pkg = ubuntu_archive.getSourcePackage(pkg, release, pocket)
|
||||
except PackageNotFoundException as error:
|
||||
@ -309,10 +292,10 @@ def main():
|
||||
|
||||
# Check permissions (part 2): check upload permissions for the source
|
||||
# package
|
||||
can_retry = options.retry and me.canUploadPackage(
|
||||
can_retry = args.retry and me.canUploadPackage(
|
||||
ubuntu_archive, distroseries, pkg.getPackageName(), pkg.getComponent()
|
||||
)
|
||||
if options.retry and not can_retry:
|
||||
if args.retry and not can_retry:
|
||||
Logger.error(
|
||||
"You don't have the permissions to retry the "
|
||||
"build of '%s'. Ignoring your request.",
|
||||
@ -330,8 +313,8 @@ def main():
|
||||
Logger.info(pkg.getBuildStates(archs))
|
||||
if can_retry:
|
||||
Logger.info(pkg.retryBuilds(archs))
|
||||
if options.priority and can_rescore:
|
||||
Logger.info(pkg.rescoreBuilds(archs, options.priority))
|
||||
if args.priority and can_rescore:
|
||||
Logger.info(pkg.rescoreBuilds(archs, args.priority))
|
||||
|
||||
Logger.info("")
|
||||
|
||||
|
13
ubuntu-iso
13
ubuntu-iso
@ -23,7 +23,7 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@ -46,13 +46,14 @@ def extract(iso, path):
|
||||
|
||||
|
||||
def main():
|
||||
desc = "Given an ISO, %prog will display the Ubuntu version information"
|
||||
parser = optparse.OptionParser(usage="%prog [options] iso...", description=desc)
|
||||
isos = parser.parse_args()[1]
|
||||
desc = "Given an ISO, %(prog)s will display the Ubuntu version information"
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] iso...", description=desc)
|
||||
parser.add_argument("isos", nargs="*", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
err = False
|
||||
|
||||
for iso in isos:
|
||||
if len(isos) > 1:
|
||||
for iso in args.isos:
|
||||
if len(args.isos) > 1:
|
||||
prefix = "%s:" % iso
|
||||
else:
|
||||
prefix = ""
|
||||
|
@ -17,7 +17,7 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from ubuntutools import getLogger
|
||||
@ -36,77 +36,71 @@ Logger = getLogger()
|
||||
|
||||
def parse_arguments():
|
||||
"""Parse arguments and return (options, package)"""
|
||||
parser = optparse.OptionParser("%prog [options] package")
|
||||
parser.add_option(
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options] package")
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"--release",
|
||||
default=None,
|
||||
metavar="RELEASE",
|
||||
help="Use RELEASE, rather than the current development release",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--list-uploaders",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="List all the people/teams with upload rights",
|
||||
)
|
||||
parser.add_option(
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--list-team-members",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="List all team members of teams with upload rights (implies --list-uploaders)",
|
||||
)
|
||||
options, args = parser.parse_args()
|
||||
parser.add_argument("package", help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("One (and only one) package must be specified")
|
||||
package = args[0]
|
||||
if args.list_team_members:
|
||||
args.list_uploaders = True
|
||||
|
||||
if options.list_team_members:
|
||||
options.list_uploaders = True
|
||||
|
||||
return (options, package)
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
"""Query upload permissions"""
|
||||
options, package = parse_arguments()
|
||||
args = parse_arguments()
|
||||
# Need to be logged in to see uploaders:
|
||||
Launchpad.login()
|
||||
|
||||
ubuntu = Distribution("ubuntu")
|
||||
archive = ubuntu.getArchive()
|
||||
if options.release is None:
|
||||
options.release = ubuntu.getDevelopmentSeries().name
|
||||
if args.release is None:
|
||||
args.release = ubuntu.getDevelopmentSeries().name
|
||||
try:
|
||||
release, pocket = split_release_pocket(options.release)
|
||||
release, pocket = split_release_pocket(args.release)
|
||||
series = ubuntu.getSeries(release)
|
||||
except SeriesNotFoundException as e:
|
||||
Logger.error(str(e))
|
||||
sys.exit(2)
|
||||
|
||||
try:
|
||||
spph = archive.getSourcePackage(package)
|
||||
spph = archive.getSourcePackage(args.package)
|
||||
except PackageNotFoundException as e:
|
||||
Logger.error(str(e))
|
||||
sys.exit(2)
|
||||
component = spph.getComponent()
|
||||
if options.list_uploaders and (
|
||||
if args.list_uploaders and (
|
||||
pocket != "Release"
|
||||
or series.status in ("Experimental", "Active Development", "Pre-release Freeze")
|
||||
):
|
||||
|
||||
component_uploader = archive.getUploadersForComponent(component_name=component)[0]
|
||||
Logger.info("All upload permissions for %s:", package)
|
||||
Logger.info("All upload permissions for %s:", args.package)
|
||||
Logger.info("")
|
||||
Logger.info("Component (%s)", component)
|
||||
Logger.info("============%s", "=" * len(component))
|
||||
print_uploaders([component_uploader], options.list_team_members)
|
||||
print_uploaders([component_uploader], args.list_team_members)
|
||||
|
||||
packagesets = sorted(
|
||||
Packageset.setsIncludingSource(distroseries=series, sourcepackagename=package),
|
||||
Packageset.setsIncludingSource(distroseries=series, sourcepackagename=args.package),
|
||||
key=lambda p: p.name,
|
||||
)
|
||||
if packagesets:
|
||||
@ -118,22 +112,22 @@ def main():
|
||||
Logger.info("%s:", packageset.name)
|
||||
print_uploaders(
|
||||
archive.getUploadersForPackageset(packageset=packageset),
|
||||
options.list_team_members,
|
||||
args.list_team_members,
|
||||
)
|
||||
|
||||
ppu_uploaders = archive.getUploadersForPackage(source_package_name=package)
|
||||
ppu_uploaders = archive.getUploadersForPackage(source_package_name=args.package)
|
||||
if ppu_uploaders:
|
||||
Logger.info("")
|
||||
Logger.info("Per-Package-Uploaders")
|
||||
Logger.info("=====================")
|
||||
Logger.info("")
|
||||
print_uploaders(ppu_uploaders, options.list_team_members)
|
||||
print_uploaders(ppu_uploaders, args.list_team_members)
|
||||
Logger.info("")
|
||||
|
||||
if PersonTeam.me.canUploadPackage(archive, series, package, component, pocket):
|
||||
Logger.info("You can upload %s to %s.", package, options.release)
|
||||
if PersonTeam.me.canUploadPackage(archive, series, args.package, component, pocket):
|
||||
Logger.info("You can upload %s to %s.", args.package, args.release)
|
||||
else:
|
||||
Logger.info("You can not upload %s to %s, yourself.", package, options.release)
|
||||
Logger.info("You can not upload %s to %s, yourself.", args.package, args.release)
|
||||
if (
|
||||
series.status in ("Current Stable Release", "Supported", "Obsolete")
|
||||
and pocket == "Release"
|
||||
@ -149,7 +143,7 @@ def main():
|
||||
"But you can still contribute to it via the sponsorship "
|
||||
"process: https://wiki.ubuntu.com/SponsorshipProcess"
|
||||
)
|
||||
if not options.list_uploaders:
|
||||
if not args.list_uploaders:
|
||||
Logger.info(
|
||||
"To see who has the necessary upload rights, "
|
||||
"use the --list-uploaders option."
|
||||
|
@ -17,7 +17,7 @@
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
import optparse
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -46,49 +46,31 @@ def find_debian_dir(depth=6):
|
||||
|
||||
def main():
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
usage = "%s [options]" % (script_name)
|
||||
epilog = "See %s(1) for more info." % (script_name)
|
||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||
parser.add_option(
|
||||
parser = argparse.ArgumentParser(epilog=epilog)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--debian-directory",
|
||||
dest="debian_directory",
|
||||
help="location of the 'debian' directory (default: %default).",
|
||||
help="location of the 'debian' directory (default: %(default)s).",
|
||||
metavar="PATH",
|
||||
default=find_debian_dir() or "./debian",
|
||||
)
|
||||
parser.add_option(
|
||||
"-r",
|
||||
"--restore",
|
||||
help="Restore the original maintainer",
|
||||
action="store_true",
|
||||
default=False,
|
||||
parser.add_argument(
|
||||
"-r", "--restore", help="Restore the original maintainer", action="store_true"
|
||||
)
|
||||
parser.add_option(
|
||||
"-q",
|
||||
"--quiet",
|
||||
help="print no informational messages",
|
||||
dest="quiet",
|
||||
action="store_true",
|
||||
default=False,
|
||||
parser.add_argument(
|
||||
"-q", "--quiet", help="print no informational messages", dest="quiet", action="store_true"
|
||||
)
|
||||
(options, args) = parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(args) != 0:
|
||||
print(
|
||||
"%s: Error: Unsupported additional parameters specified: %s"
|
||||
% (script_name, ", ".join(args)),
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
if not options.restore:
|
||||
if not args.restore:
|
||||
operation = update_maintainer
|
||||
else:
|
||||
operation = restore_maintainer
|
||||
|
||||
try:
|
||||
operation(options.debian_directory, not options.quiet)
|
||||
operation(args.debian_directory, not args.quiet)
|
||||
except MaintainerUpdateException:
|
||||
sys.exit(1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user