cli/build: Code style fixes

Minor string changes are also included in this commit.
This commit is contained in:
Fatih Aşıcı
2010-06-17 18:02:35 +00:00
parent a1e9643f2e
commit 80ff73f6fb
+110 -39
View File
@@ -1,6 +1,6 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
# #
# Copyright (C) 2005 - 2007, TUBITAK/UEKAE # Copyright (C) 2005-2010, TUBITAK/UEKAE
# #
# This program is free software; you can redistribute it and/or modify it under # 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 # the terms of the GNU General Public License as published by the Free
@@ -21,8 +21,8 @@ import pisi.api
import pisi.cli.command as command import pisi.cli.command as command
import pisi.context as ctx import pisi.context as ctx
class Build(command.Command):
__doc__ = _("""Build PiSi packages usage = _("""Build PiSi packages
Usage: build [<pspec.xml> | <sourcename>] ... Usage: build [<pspec.xml> | <sourcename>] ...
@@ -32,6 +32,11 @@ fetch all necessary files and build the package for you.
Alternatively, you can give the name of a source package Alternatively, you can give the name of a source package
to be downloaded from a repository containing sources. to be downloaded from a repository containing sources.
""") """)
class Build(command.Command):
__doc__ = usage
__metaclass__ = command.autocommand __metaclass__ = command.autocommand
def __init__(self, args): def __init__(self, args):
@@ -40,58 +45,122 @@ to be downloaded from a repository containing sources.
name = ("build", "bi") name = ("build", "bi")
package_formats = ('1.0', '1.1') package_formats = ("1.0", "1.1")
def options(self): def options(self):
self.add_steps_options() self.add_steps_options()
group = optparse.OptionGroup(self.parser, _("build options")) group = optparse.OptionGroup(self.parser, _("build options"))
self.add_options(group) self.add_options(group)
self.parser.add_option_group(group) self.parser.add_option_group(group)
def add_options(self, group): def add_options(self, group):
group.add_option("--ignore-build-no", action="store_true", group.add_option("--ignore-build-no",
action="store_true",
default=False, default=False,
help=_("Do not take build no into account.")) help=_("Do not take build no into account."))
group.add_option("-q", "--quiet", action="store_true", default=False,
help=_("Run pisi build operation without printing extra debug information")) group.add_option("-q", "--quiet",
group.add_option("--ignore-dependency", action="store_true", action="store_true",
default=False, default=False,
help=_("Do not take dependency information into account")) help=_("Run pisi build operation without printing "
group.add_option("-O", "--output-dir", action="store", default=None, "extra debug information"))
group.add_option("--ignore-dependency",
action="store_true",
default=False,
help=_("Do not take dependency information into "
"account"))
group.add_option("-O", "--output-dir",
action="store",
default=None,
help=_("Output directory for produced packages")) help=_("Output directory for produced packages"))
group.add_option("--ignore-action-errors", group.add_option("--ignore-action-errors",
action="store_true", default=False, action="store_true", default=False,
help=_("Bypass errors from ActionsAPI")) help=_("Bypass errors from ActionsAPI"))
group.add_option("--ignore-safety", action="store_true",
default=False, help=_("Bypass safety switch")) group.add_option("--ignore-safety",
group.add_option("--ignore-check", action="store_true", action="store_true",
default=False, help=_("Bypass testing step")) default=False,
group.add_option("--create-static", action="store_true", help=_("Bypass safety switch"))
default=False, help=_("Create a static package with ar files"))
group.add_option("-F", "--package-format", action="store", default='1.1', group.add_option("--ignore-check",
help=_("PiSi binary package formats: '1.0', '1.1' (default)")) action="store_true",
group.add_option("--use-quilt", action="store_true", default=False, default=False,
help=_("Use quilt patch management system instead of GNU patch")) help=_("Bypass testing step"))
group.add_option("--ignore-sandbox", action="store_true", default=False,
help=_("Do not constrain build process inside the build folder")) group.add_option("--create-static",
action="store_true",
default=False,
help=_("Create a static package with ar files"))
group.add_option("-F", "--package-format",
action="store",
default="1.1",
help=_("PiSi binary package formats: "
"'1.0', '1.1' (default)"))
group.add_option("--use-quilt",
action="store_true",
default=False,
help=_("Use quilt patch management system "
"instead of GNU patch"))
group.add_option("--ignore-sandbox",
action="store_true",
default=False,
help=_("Do not constrain build process inside "
"the build folder"))
def add_steps_options(self): def add_steps_options(self):
group = optparse.OptionGroup(self.parser, _("build steps")) group = optparse.OptionGroup(self.parser, _("build steps"))
group.add_option("--fetch", dest="until", action="store_const",
const="fetch", help=_("Break build after fetching the source archive")) group.add_option("--fetch",
group.add_option("--unpack", dest="until", action="store_const", dest="until",
const="unpack", help=_("Break build after unpacking the source archive, checking sha1sum and applying patches")) action="store_const",
group.add_option("--setup", dest="until", action="store_const", const="fetch",
const="setup", help=_("Break build after running configure step")) help=_("Break build after fetching the source "
group.add_option("--build", dest="until", action="store_const", "archive"))
const="build", help=_("Break build after running compile step"))
group.add_option("--check", dest="until", action="store_const", group.add_option("--unpack",
const="check", help=_("Break build after running check step")) dest="until",
group.add_option("--install", dest="until", action="store_const", action="store_const",
const="install", help=_("Break build after running install step")) const="unpack",
group.add_option("--package", dest="until", action="store_const", help=_("Break build after unpacking the source "
const="package", help=_("create PiSi package")) "archive, checking sha1sum and applying "
"patches"))
group.add_option("--setup",
dest="until",
action="store_const",
const="setup",
help=_("Break build after running configure step"))
group.add_option("--build",
dest="until",
action="store_const",
const="build",
help=_("Break build after running compile step"))
group.add_option("--check",
dest="until",
action="store_const",
const="check",
help=_("Break build after running check step"))
group.add_option("--install",
dest="until",
action="store_const",
const="install",
help=_("Break build after running install step"))
group.add_option("--package",
dest="until",
action="store_const",
const="package",
help=_("Create PiSi package"))
self.parser.add_option_group(group) self.parser.add_option_group(group)
def run(self): def run(self):
@@ -105,10 +174,12 @@ to be downloaded from a repository containing sources.
self.init() self.init()
if ctx.get_option('package_format') not in Build.package_formats: if ctx.get_option('package_format') not in Build.package_formats:
raise pisi.Error(_('package_format must be one of %s ') % pisi.util.strlist(Build.package_formats)) raise pisi.Error(_("Package format must be one of %s ")
% pisi.util.strlist(Build.package_formats))
if ctx.get_option('output_dir'): if ctx.get_option('output_dir'):
ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir) ctx.ui.info(_('Output directory: %s')
% ctx.config.options.output_dir)
else: else:
ctx.ui.info(_('Outputting packages in the working directory.')) ctx.ui.info(_('Outputting packages in the working directory.'))
ctx.config.options.output_dir = '.' ctx.config.options.output_dir = '.'