示例#1
0
    def handle_header(self, args, line_number=None):
        # Create the argument parser.
        op = KSOptionParser(prog="%addon my_test_1",
                            version=F30,
                            description="My addon test 1.")

        op.add_argument("--foo",
                        type=int,
                        default=None,
                        version=F30,
                        help="Specify foo.")

        op.add_argument("--bar",
                        action="store_true",
                        default=False,
                        version=F30,
                        help="Specify bar.")

        # Parse the arguments.
        ns = op.parse_args(args=args, lineno=line_number)

        # Store the result of the parsing.
        self.seen = True
        self.foo = ns.foo
        self.bar = ns.bar
    def handle_header(self, lineno, args):
        """
        The handle_header method is called to parse additional arguments in the
        %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:

            %addon org_fedora_hello_world --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param lineno: the current line number in the kickstart file
        :type lineno: int
        :param args: the list of arguments from the %addon line
        :type args: list
        """
        op = KSOptionParser(prog="addon org_fedora_hello_world",
                            version=F30,
                            description="Configure the Hello World Addon.")

        op.add_argument("--reverse",
                        action="store_true",
                        default=False,
                        version=F30,
                        dest="reverse",
                        help="Reverse the display of the addon text.")

        # Parse the arguments.
        ns = op.parse_args(args=args, lineno=lineno)

        # Store the result of the parsing.
        self.reverse = ns.reverse
    def handle_header(self, lineno, args):
        """
        The handle_header method is called to parse additional arguments in the
        %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:
        
            %addon org_fedora_hello_world --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param lineno: the current line number in the kickstart file
        :type lineno: int
        :param args: the list of arguments from the %addon line
        :type args: list
        """

        op = KSOptionParser()
        op.add_option("--reverse", action="store_true", default=False,
                dest="reverse", help="Reverse the display of the addon text")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)
        
        # Reject any additional arguments. Since AddonData.handle_header
        # rejects any arguments, we can use it to create an error message
        # and raise an exception.
        if extra:
            AddonData.handle_header(self, lineno, args)

        # Store the result of the option parsing
        self.reverse = opts.reverse
示例#4
0
    def handle_header(self, lineno, args):
        """ Handle the kickstart addon header

        :param lineno: Line number
        :param args: arguments from %addon line
        """
        # This gets called after __init__, very early in the installation.
        op = KSOptionParser()
        op.add_option("--vgname", required=True,
                      help="Name of the VG that contains a thinpool named docker-pool")
        op.add_option("--fstype", required=True,
                      help="Type of filesystem to use for docker to use with docker-pool")
        op.add_option("--save-args", action="store_true", default=False,
                      help="Save all extra args to the OPTIONS variable in /etc/sysconfig/docker")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        fmt = blivet.formats.getFormat(opts.fstype)
        if not fmt or fmt.type is None:
            raise KickstartValueError(formatErrorMsg(lineno,
                                      msg=_("%%addon com_redhat_docker fstype of %s is invalid.")) % opts.fstype)

        self.vgname = opts.vgname
        self.fstype = opts.fstype
        self.enabled = True
        self.extra_args = extra
        self.save_args = opts.save_args
示例#5
0
    def handle_header(self, lineno, args):
        """
        The handle_header method is called to parse additional arguments in the
        %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:

            %addon org_fedora_hello_world --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param lineno: the current line number in the kickstart file
        :type lineno: int
        :param args: the list of arguments from the %addon line
        :type args: list
        """

        op = KSOptionParser()
        op.add_option("--reverse", action="store_true", default=False,
                dest="reverse", help="Reverse the display of the addon text")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        # Reject any additional arguments.
        if extra:
            msg = "Unhandled arguments on %%addon line for %s" % self.name
            if lineno != None:
                raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
            else:
                raise KickstartParseError(msg)

        # Store the result of the option parsing
        self.reverse = opts.reverse
示例#6
0
    def handle_header(self, lineno, args):
        """
        The handle_header method is called to parse additional arguments in the
        %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:

            %addon org_fedora_hello_world --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param lineno: the current line number in the kickstart file
        :type lineno: int
        :param args: the list of arguments from the %addon line
        :type args: list
        """

        op = KSOptionParser()
        op.add_option("--reverse", action="store_true", default=False,
                dest="reverse", help="Reverse the display of the addon text")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        # Reject any additional arguments.
        if extra:
            msg = "Unhandled arguments on %%addon line for %s" % self.name
            if lineno != None:
                raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
            else:
                raise KickstartParseError(msg)

        # Store the result of the option parsing
        self.reverse = opts.reverse
示例#7
0
    def handle_header(self, lineno, args):
        op = KSOptionParser()
        op.add_option("--enable", action="store_true", default=True,
                dest="enabled", help="Enable kdump")
        op.add_option("--disable", action="store_false",
                dest="enabled", help="Disable kdump")
        op.add_option("--reserve-mb", type="string", dest="reserveMB",
                default="auto", help="Amount of memory in MB to reserve for kdump, or auto")

        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        # Reject any additional arguments
        if extra:
            AddonData.handle_header(self, lineno, extra)

        # Validate the reserve-mb argument
        if opts.reserveMB != "auto":
            # Allow a final 'M' for consistency with the crashkernel kernel
            # parameter. Strip it if found.
            if opts.reserveMB and opts.reserveMB[-1] == 'M':
                opts.reserveMB = opts.reserveMB[:-1]

            try:
                _test = int(opts.reserveMB)
            except ValueError:
                msg = _("Invalid value %s for --reserve-mb") % opts.reserveMB
                if lineno != None:
                    raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
                else:
                    raise KickstartParseError(msg)

        # Store the parsed arguments
        self.enabled = opts.enabled
        self.reserveMB =opts.reserveMB
    def handle_header(self, lineno, args):

        op = KSOptionParser()
        op.add_option("--enable", "-e", action="store_true", default=False,
                      dest="state", help="Enable Cloud Support")
        op.add_option("--disable", "-d", action="store_false",
                      dest="state", help="(Default) Disable Cloud Support")
        op.add_option("--allinone", "-a", action="store_true", default=False,
                      dest="mode", help="Specify the mode of Packstack Installation")
        op.add_option("--answer-file", "-f", action="store", type="string",
                      dest="file", help="Specify URL of answers file")
        (options, extra) = op.parse_args(args=args, lineno=lineno)

        # Error Handling
        if str(options.state) == "True":
            self.state = str(options.state)
            if options.file and options.mode:
                msg = "options --allinone and --answer-file are mutually exclusive"
                raise KickstartParseError(msg)
            elif options.file:
                try:
                    response = urllib2.urlopen(options.file)
                    for line in response:
                        self.lines += line
                except urllib2.HTTPError, e:
                    msg = "Kickstart Error:: HTTPError: " + str(e.code)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except urllib2.URLError, e:
                    msg = "Kickstart Error: HTTPError: " + str(e.reason)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except:
示例#9
0
文件: homer.py 项目: biddyweb/homer
	def handle_header(self, lineno, args):

		op = KSOptionParser()
		op.add_option("--homer-user", action="store_true", default=False,
		dest="homer_user", help="Homer database user name")
		op.add_option("--homer-password", action="store_true", default=False,
		dest="homer_password", help="Homer database user password")
		op.add_option("--homer-database-name", action="store_true", default=False,
		dest="homer_database_name", help="Homer database name")
		op.add_option("--homer-database-host", action="store_true", default=False,
		dest="homer_database_host", help="Homer database host")
		op.add_option("--homer-timezone", action="store_true", default=False,
		dest="homer_timezone", help="Homer database timezone")
		op.add_option("--web-server-type", action="store_true", default=False,
		dest="homer_webserver_type", help="Homer web-server type: httpd or nginx")


		(opts, extra) = op.parse_args(args=args, lineno=lineno)
#
#		# Reject any additoinal arguments. Since AddonData.handle_header
#		# rejects any arguments, we can use it to create an error message
#		# and raise an exception.
		if extra:
			AddonData.handle_header(self, lineno, extra)
		# Store the result of the option parsing
		self.homer_user = opts.homer_user
		self.homer_password = opts.homer_password
		self.homer_database_name = opts.homer_database_name
		self.homer_database_host = opts.homer_database_host
		self.homer_timezone = opts.homer_timezone
		self.homer_webserver_type = opts.homer_webserver_type
示例#10
0
文件: addons.py 项目: mairin/anaconda
    def handleHeader(self, lineno, args):
        """Process the arguments to the %addon header."""
        Section.handleHeader(self, lineno, args)
        op = KSOptionParser(version=self.version)
        (_opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
        self.addon_id = extra[0]

        # if the addon is not registered, create dummy placeholder for it
        if self.addon_id and not hasattr(self.handler.addons, self.addon_id):
            setattr(self.handler.addons, self.addon_id, AddonData(self.addon_id))
示例#11
0
    def handleHeader(self, lineno, args):
        """Process the arguments to the %packages header and set attributes
           on the Version's Packages instance appropriate.  This method may be
           overridden in a subclass if necessary.
        """
        Section.handleHeader(self, lineno, args)
        op = KSOptionParser(version=self.version)
        op.add_option("--excludedocs", dest="excludedocs", action="store_true",
                      default=False)
        op.add_option("--ignoremissing", dest="ignoremissing",
                      action="store_true", default=False)
        op.add_option("--nobase", dest="nobase", action="store_true",
                      default=False, deprecated=F18)
        op.add_option("--nocore", dest="nocore", action="store_true",
                      default=False, introduced=F21)
        op.add_option("--ignoredeps", dest="resolveDeps", action="store_false",
                      deprecated=FC4, removed=F9)
        op.add_option("--resolvedeps", dest="resolveDeps", action="store_true",
                      deprecated=FC4, removed=F9)
        op.add_option("--default", dest="defaultPackages", action="store_true",
                      default=False, introduced=F7)
        op.add_option("--instLangs", dest="instLangs", type="string",
                      default="", introduced=F9)
        op.add_option("--multilib", dest="multiLib", action="store_true",
                      default=False, introduced=F18)
        op.add_option("--timeout", dest="timeout", type="int",
                      default=None, introduced=RHEL7)
        op.add_option("--retries", dest="retries", type="int",
                      default=None, introduced=RHEL7)

        (opts, _extra) = op.parse_args(args=args[1:], lineno=lineno)

        if opts.defaultPackages and opts.nobase:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nobase cannot be used together")))
        elif opts.defaultPackages and opts.nocore:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nocore cannot be used together")))

        self.handler.packages.excludeDocs = opts.excludedocs
        self.handler.packages.addBase = not opts.nobase
        if opts.ignoremissing:
            self.handler.packages.handleMissing = KS_MISSING_IGNORE
        else:
            self.handler.packages.handleMissing = KS_MISSING_PROMPT

        if opts.defaultPackages:
            self.handler.packages.default = True

        if opts.instLangs:
            self.handler.packages.instLangs = opts.instLangs

        self.handler.packages.nocore = opts.nocore
        self.handler.packages.multiLib = opts.multiLib
        self.handler.packages.timeout = opts.timeout
        self.handler.packages.retries = opts.retries
        self.handler.packages.seen = True
示例#12
0
    def handleHeader(self, lineno, args):
        """Process the arguments to the %addon header."""
        Section.handleHeader(self, lineno, args)
        op = KSOptionParser(version=self.version)
        (_opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
        self.addon_id = extra[0]

        # if the addon is not registered, create dummy placeholder for it
        if self.addon_id and not hasattr(self.handler.addons, self.addon_id):
            setattr(self.handler.addons, self.addon_id,
                    AddonData(self.addon_id))
示例#13
0
    def handle_header(self, args, line_number=None):
        """Handle the arguments of the %addon line.

        :param args: a list of additional arguments
        :param line_number: a line number
        :raise: KickstartParseError for invalid arguments
        """
        op = KSOptionParser(prog="addon com_redhat_kdump",
                            version=F27,
                            description="Configure the Kdump Addon.")
        op.add_argument("--enable",
                        action="store_true",
                        default=True,
                        version=F27,
                        dest="enabled",
                        help="Enable kdump")
        op.add_argument("--enablefadump",
                        action="store_true",
                        default=False,
                        version=F27,
                        dest="enablefadump",
                        help="Enable dump mode fadump")
        op.add_argument("--disable",
                        action="store_false",
                        version=F27,
                        dest="enabled",
                        help="Disable kdump")
        op.add_argument("--reserve-mb",
                        type=str,
                        dest="reserve_mb",
                        version=F27,
                        default="128",
                        help="Amount of memory in MB to reserve for kdump.")

        opts = op.parse_args(args=args, lineno=line_number)

        # Validate the reserve-mb argument
        # Allow a final 'M' for consistency with the crashkernel kernel
        # parameter. Strip it if found. And strip quotes.
        opts.reserve_mb = opts.reserve_mb.strip("'\"")

        if opts.reserve_mb and opts.reserve_mb[-1] == 'M':
            opts.reserve_mb = opts.reserve_mb[:-1]

        try:
            _test = int(opts.reserve_mb)
        except ValueError:
            msg = _("Invalid value '%s' for --reserve-mb") % opts.reserve_mb
            raise KickstartParseError(msg, lineno=line_number)

        # Store the parsed arguments
        self.enabled = opts.enabled
        self.reserve_mb = opts.reserve_mb
        self.enablefadump = opts.enablefadump
示例#14
0
    def handleHeader(self, lineno, args):
        """Process the arguments to the %packages header and set attributes
           on the Version's Packages instance appropriate.  This method may be
           overridden in a subclass if necessary.
        """
        Section.handleHeader(self, lineno, args)
        op = KSOptionParser(version=self.version)
        op.add_option("--excludedocs", dest="excludedocs", action="store_true",
                      default=False)
        op.add_option("--ignoremissing", dest="ignoremissing",
                      action="store_true", default=False)
        op.add_option("--nobase", dest="nobase", action="store_true",
                      default=False, deprecated=F18, removed=F22)
        op.add_option("--nocore", dest="nocore", action="store_true",
                      default=False, introduced=F21)
        op.add_option("--ignoredeps", dest="resolveDeps", action="store_false",
                      deprecated=FC4, removed=F9)
        op.add_option("--resolvedeps", dest="resolveDeps", action="store_true",
                      deprecated=FC4, removed=F9)
        op.add_option("--default", dest="defaultPackages", action="store_true",
                      default=False, introduced=F7)
        op.add_option("--instLangs", dest="instLangs", type="string",
                      default=None, introduced=F9)
        op.add_option("--multilib", dest="multiLib", action="store_true",
                      default=False, introduced=F18)

        (opts, _extra) = op.parse_args(args=args[1:], lineno=lineno)

        if opts.defaultPackages and opts.nobase:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nobase cannot be used together")))
        elif opts.defaultPackages and opts.nocore:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nocore cannot be used together")))

        self.handler.packages.excludeDocs = opts.excludedocs
        self.handler.packages.addBase = not opts.nobase
        if opts.ignoremissing:
            self.handler.packages.handleMissing = KS_MISSING_IGNORE
        else:
            self.handler.packages.handleMissing = KS_MISSING_PROMPT

        if opts.defaultPackages:
            self.handler.packages.default = True

        if opts.instLangs is not None:
            self.handler.packages.instLangs = opts.instLangs

        self.handler.packages.nocore = opts.nocore
        self.handler.packages.multiLib = opts.multiLib
        self.handler.packages.seen = True
示例#15
0
 def handle_header(self, lineno, args):
     op = KSOptionParser()
     op.add_option("--yubikey",
                   action="store_true",
                   default=False,
                   dest="yubikey",
                   help="")
     op.add_option("--passphrase",
                   action="store_true",
                   default="",
                   dest="passphrase",
                   help="")
     (opts, extra) = op.parse_args(args=args, lineno=lineno)
     self.yubikey = opts.yubikey
     self.passphrase = opts.passphrase
示例#16
0
    def handle_header(self, lineno, args):

        op = KSOptionParser()
        op.add_option("--homer-user",
                      action="store_true",
                      default=False,
                      dest="homer_user",
                      help="Homer database user name")
        op.add_option("--homer-password",
                      action="store_true",
                      default=False,
                      dest="homer_password",
                      help="Homer database user password")
        op.add_option("--homer-database-name",
                      action="store_true",
                      default=False,
                      dest="homer_database_name",
                      help="Homer database name")
        op.add_option("--homer-database-host",
                      action="store_true",
                      default=False,
                      dest="homer_database_host",
                      help="Homer database host")
        op.add_option("--homer-timezone",
                      action="store_true",
                      default=False,
                      dest="homer_timezone",
                      help="Homer database timezone")
        op.add_option("--web-server-type",
                      action="store_true",
                      default=False,
                      dest="homer_webserver_type",
                      help="Homer web-server type: httpd or nginx")

        (opts, extra) = op.parse_args(args=args, lineno=lineno)
        #
        #		# Reject any additoinal arguments. Since AddonData.handle_header
        #		# rejects any arguments, we can use it to create an error message
        #		# and raise an exception.
        if extra:
            AddonData.handle_header(self, lineno, extra)
        # Store the result of the option parsing
        self.homer_user = opts.homer_user
        self.homer_password = opts.homer_password
        self.homer_database_name = opts.homer_database_name
        self.homer_database_host = opts.homer_database_host
        self.homer_timezone = opts.homer_timezone
        self.homer_webserver_type = opts.homer_webserver_type
示例#17
0
    def handle_header(self, lineno, args):
        op = KSOptionParser()
        op.add_option("--enable",
                      action="store_true",
                      default=True,
                      dest="enabled",
                      help="Enable kdump")
        op.add_option("--enablefadump",
                      action="store_true",
                      default=False,
                      dest="enablefadump",
                      help="Enable dump mode fadump")
        op.add_option("--disable",
                      action="store_false",
                      dest="enabled",
                      help="Disable kdump")
        op.add_option("--reserve-mb",
                      type="string",
                      dest="reserveMB",
                      default="128",
                      help="Amount of memory in MB to reserve for kdump.")

        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        # Reject any additional arguments
        if extra:
            AddonData.handle_header(self, lineno, extra)

        # Validate the reserve-mb argument
        # Allow a final 'M' for consistency with the crashkernel kernel
        # parameter. Strip it if found.
        if opts.reserveMB and opts.reserveMB[-1] == 'M':
            opts.reserveMB = opts.reserveMB[:-1]

        try:
            _test = int(opts.reserveMB)
        except ValueError:
            msg = _("Invalid value %s for --reserve-mb") % opts.reserveMB
            if lineno != None:
                raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
            else:
                raise KickstartParseError(msg)

        # Store the parsed arguments
        self.enabled = opts.enabled
        self.reserveMB = opts.reserveMB
        self.enablefadump = opts.enablefadump
示例#18
0
    def handle_header(self, lineno, args):

        op = KSOptionParser()
        op.add_option("--enable",
                      "-e",
                      action="store_true",
                      default=False,
                      dest="state",
                      help="Enable Cloud Support")
        op.add_option("--disable",
                      "-d",
                      action="store_false",
                      dest="state",
                      help="(Default) Disable Cloud Support")
        op.add_option("--allinone",
                      "-a",
                      action="store_true",
                      default=False,
                      dest="mode",
                      help="Specify the mode of Packstack Installation")
        op.add_option("--answer-file",
                      "-f",
                      action="store",
                      type="string",
                      dest="file",
                      help="Specify URL of answers file")
        (options, extra) = op.parse_args(args=args, lineno=lineno)

        # Error Handling
        if str(options.state) == "True":
            self.state = str(options.state)
            if options.file and options.mode:
                msg = "options --allinone and --answer-file are mutually exclusive"
                raise KickstartParseError(msg)
            elif options.file:
                try:
                    response = urllib2.urlopen(options.file)
                    for line in response:
                        self.lines += line
                except urllib2.HTTPError, e:
                    msg = "Kickstart Error:: HTTPError: " + str(e.code)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except urllib2.URLError, e:
                    msg = "Kickstart Error: HTTPError: " + str(e.reason)
                    raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
                except:
示例#19
0
    def handle_header(self, lineno, args):
        op = KSOptionParser(prog=self.name, version=RHEL8, description="")
        op.add_argument("--yubikey",
                        action="store_true",
                        default=False,
                        dest="yubikey",
                        help="",
                        version=RHEL8)
        op.add_argument("--passphrase",
                        action="store_true",
                        default="",
                        dest="passphrase",
                        help="",
                        version=RHEL8)
        opts = op.parse_args(args=args, lineno=lineno)

        self.yubikey = opts.yubikey
        self.passphrase = opts.passphrase
示例#20
0
    def handle_header(self, lineno, args):
        """ Handle the kickstart addon header

        :param lineno: Line number
        :param args: arguments from %addon line
        """
        # This gets called after __init__, very early in the installation.
        op = KSOptionParser()
        op.add_option("--vgname",
                      help="Name of the VG that contains a thinpool named docker-pool")
        op.add_option("--fstype",
                      help="Type of filesystem for docker to use with the docker-pool")
        op.add_option("--overlay", action="store_true",
                      help="Use the overlay driver")
        op.add_option("--btrfs", action="store_true",
                      help="Use the BTRFS driver")
        op.add_option("--save-args", action="store_true", default=False,
                      help="Save all extra args to the OPTIONS variable in /etc/sysconfig/docker")
        (opts, extra) = op.parse_args(args=args, lineno=lineno)

        if sum(1 for v in [opts.overlay, opts.btrfs, opts.vgname] if bool(v)) != 1:
            raise KickstartParseError(formatErrorMsg(lineno,
                                                     msg=_("%%addon com_redhat_docker must choose one of --overlay, --btrfs, or --vgname")))

        self.enabled = True
        self.extra_args = extra
        self.save_args = opts.save_args

        if opts.overlay:
            self.storage = OverlayStorage(self)
        elif opts.btrfs:
            self.storage = BTRFSStorage(self)
        elif opts.vgname:
            fmt = blivet.formats.get_format(opts.fstype)
            if not fmt or fmt.type is None:
                raise KickstartParseError(formatErrorMsg(lineno,
                                                         msg=_("%%addon com_redhat_docker fstype of %s is invalid.")) % opts.fstype)

            self.vgname = opts.vgname
            self.fstype = opts.fstype
            self.storage = LVMStorage(self)
示例#21
0
    def handle_header(self, args, line_number=None):
        """The handle_header method is called to parse additional arguments
        in the %addon section line.

        args is a list of all the arguments following the addon ID. For
        example, for the line:

            %addon org_fedoraproject_package_remove --reverse --arg2="example"

        handle_header will be called with args=['--reverse', '--arg2="example"']

        :param line_number: the current line number in the kickstart file
        :type line_number: int
        :param args: the list of arguments from the %addon line
        :type args: List[Str]
        """
        # Create the argument parser.
        op = KSOptionParser(
            prog="%addon org_fedoraproject_package_remove",
            version=VERSION,
            description="Configure the Package Remove Addon."
        )

        op.add_argument(
            "--reverse",
            action="store_true",
            default=False,
            version=VERSION,
            dest="reverse",
            help="Reverse the display of the addon text."
        )

        # Parse the arguments.
        ns = op.parse_args(args=args, lineno=line_number)

        # Store the result of the parsing.
        self.reverse = ns.reverse
示例#22
0
    def handleHeader(self, lineno, args):
        """Process the arguments to the %packages header and set attributes
           on the Version's Packages instance appropriate.  This method may be
           overridden in a subclass if necessary.
        """
        Section.handleHeader(self, lineno, args)
        op = KSOptionParser(prog=self.sectionOpen, description="""
                            Use the %packages command to begin a kickstart file
                            section that lists the packages you would like to
                            install.

                            Packages can be specified by group or by individual
                            package name. The installation program defines
                            several groups that contain related packages. Refer
                            to the repodata/*comps.xml file on the first CD-ROM
                            for a list of groups. Each group has an id, user
                            visibility value, name, description, and package
                            list. In the package list, the packages marked as
                            mandatory are always installed if the group is
                            selected, the packages marked default are selected
                            by default if the group is selected, and the packages
                            marked optional must be specifically selected even
                            if the group is selected to be installed.

                            In most cases, it is only necessary to list the
                            desired groups and not individual packages. Note
                            that the Core group is always selected by default,
                            so it is not necessary to specify it in the
                            %packages section.

                            The %packages section is required to be closed with
                            %end. Also, multiple %packages sections may be given.
                            This may be handy if the kickstart file is used as a
                            template and pulls in various other files with the
                            %include mechanism.

                            Here is an example %packages selection::

                                %packages
                                @X Window System
                                @GNOME Desktop Environment
                                @Graphical Internet
                                @Sound and Video
                                dhcp
                                %end

                            As you can see, groups are specified, one to a line,
                            starting with an ``@`` symbol followed by the full
                            group name as given in the comps.xml file. Groups
                            can also be specified using the id for the group,
                            such as gnome-desktop. Specify individual packages
                            with no additional characters (the dhcp line in the
                            example above is an individual package).

                            You can also specify environments using the ``@^``
                            prefix followed by full environment name as given in
                            the comps.xml file.  If multiple environments are
                            specified, only the last one specified will be used.
                            Environments can be mixed with both group
                            specifications (even if the given group is not part
                            of the specified environment) and package
                            specifications.

                            Here is an example of requesting the GNOME Desktop
                            environment to be selected for installation::

                                %packages
                                @^gnome-desktop-environment
                                %end

                            Additionally, individual packages may be specified
                            using globs. For instance::

                                %packages
                                vim*
                                kde-i18n-*
                                %end

                            This would install all packages whose names start
                            with "vim" or "kde-i18n-".

                            You can also specify which packages or groups not to
                            install from the default package list::

                                %packages
                                -autofs
                                -@Sound and Video
                                %end
                            """, epilog="""
                            Group-level options
                            -------------------

                            In addition, group lines in the %packages section
                            can take the following options:

                            ``--nodefaults``

                                Only install the group's mandatory packages, not
                                the default selections.

                            ``--optional``

                                In addition to the mandatory and default packages,
                                also install the optional packages. This means all
                                packages in the group will be installed.
                            """, version=self.version)
        op.add_argument("--excludedocs", action="store_true", default=False,
                        help="""
                        Do not install any of the documentation from any packages.
                        For the most part, this means files in /usr/share/doc*
                        will not get installed though it could mean other files
                        as well, depending on how the package was built.""",
                        introduced=FC4)
        op.add_argument("--ignoremissing", action="store_true", default=False,
                        help="""
                        Ignore any packages or groups specified in the packages
                        section that are not found in any configured repository.
                        The default behavior is to halt the installation and ask
                        the user if the installation should be aborted or
                        continued. This option allows fully automated
                        installation even in the error case.""",
                        introduced=FC4)
        op.add_argument("--nobase", action="store_true", default=False,
                        deprecated=F18, removed=F22, help="""
                        Do not install the @base group (installed by default,
                        otherwise).""")
        op.add_argument("--nocore", action="store_true", default=False,
                        introduced=F21, help="""
                        Do not install the @core group (installed by default,
                        otherwise).

                        **Omitting the core group can produce a system that is
                        not bootable or that cannot finish the install. Use
                        with caution.**""")
        op.add_argument("--ignoredeps", dest="resolveDeps", action="store_false",
                        deprecated=FC4, removed=F9, help="")
        op.add_argument("--resolvedeps", dest="resolveDeps", action="store_true",
                        deprecated=FC4, removed=F9, help="")
        op.add_argument("--default", dest="defaultPackages", action="store_true",
                        default=False, introduced=F7, help="""
                        Install the default package set. This corresponds to the
                        package set that would be installed if no other
                        selections were made on the package customization screen
                        during an interactive install.""")
        op.add_argument("--instLangs", default=None, introduced=F9, help="""
                        Specify the list of languages that should be installed.
                        This is different from the package group level
                        selections, though. This option does not specify what
                        package groups should be installed. Instead, it controls
                        which translation files from individual packages should
                        be installed by setting RPM macros.""")
        op.add_argument("--multilib", dest="multiLib", action="store_true",
                        default=False, introduced=F18, help="""
                        Enable yum's "all" multilib_policy as opposed to the
                        default of "best".""")
        op.add_argument("--excludeWeakdeps", dest="excludeWeakdeps",
                        action="store_true", default=False, introduced=F24,
                        help="""
                        Do not install packages from weak dependencies. These
                        are packages linked to the selected package set by
                        Recommends and Supplements flags. By default weak
                        dependencies will be installed.""")

        ns = op.parse_args(args=args[1:], lineno=lineno)

        if ns.defaultPackages and ns.nobase:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nobase cannot be used together")))
        elif ns.defaultPackages and ns.nocore:
            raise KickstartParseError(formatErrorMsg(lineno, msg=_("--default and --nocore cannot be used together")))

        self.handler.packages.excludeDocs = ns.excludedocs
        self.handler.packages.addBase = not ns.nobase
        if ns.ignoremissing:
            self.handler.packages.handleMissing = KS_MISSING_IGNORE
        else:
            self.handler.packages.handleMissing = KS_MISSING_PROMPT

        if ns.defaultPackages:
            self.handler.packages.default = True

        if ns.instLangs is not None:
            self.handler.packages.instLangs = ns.instLangs

        self.handler.packages.nocore = ns.nocore
        self.handler.packages.multiLib = ns.multiLib
        self.handler.packages.excludeWeakdeps = ns.excludeWeakdeps
        self.handler.packages.seen = True