[PATCH 1/3] Raise an error if autopart is combined with partitioning commands (#886010)

Chris Lumens clumens at redhat.com
Tue Aug 13 20:49:59 UTC 2013


> diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
> index cf8a234..0a458ba 100644
> --- a/pykickstart/commands/autopart.py
> +++ b/pykickstart/commands/autopart.py
> @@ -151,6 +151,39 @@ class RHEL6_AutoPart(F12_AutoPart):
>          op.add_option("--cipher")
>          return op
>  
> +    def parse(self, args):
> +        # call the overriden command to do it's job first
> +        retval = F12_AutoPart.parse(self, args)
> +
> +        # Using autopart together with other partitioning command such as
> +        # part/partition, raid, logvol or volgroup can lead to hard to debug
> +        # behavior that might among other result into an unbootable system.
> +        #
> +        # Therefore if any of those commands is detected in the same kickstart
> +        # together with autopart, an error is raised and installation is
> +        # aborted.
> +        conflicting_command = ""
> +
> +        # seen indicates that the corresponding
> +        # command has been seen in kickstart
> +        if self.handler.partition.seen:
> +            conflicting_command = "part/partition)"

Looks like you've got an extra paren there at the end.

> +        elif self.handler.raid.seen:
> +            conflicting_command = "raid"
> +        elif self.handler.volgroup.seen:
> +            conflicting_command = "volgroup"
> +        elif self.handler.logvol.seen:
> +            conflicting_command = "logvol"
> +
> +        if conflicting_command:
> +            # allow for translation of the error message
> +            errorMsg = _("The %s and autopart commands can't be used at the same time")
> +            # set the placeholder with the offending command
> +            errorMsg = errorMsg % conflicting_command

This can just be reduced to:

errorMsg = _("...") % conflicting_command

> @@ -263,7 +296,40 @@ class F18_AutoPart(F17_AutoPart):
>          op.add_option("--cipher")
>          return op
>  
> +
>  class F20_AutoPart(F18_AutoPart):
>      def __init__(self, writePriority=100, *args, **kwargs):
>          F18_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
>          self.typeMap["thinp"] = AUTOPART_TYPE_LVM_THINP
> +
> +    def parse(self, args):
> +        # call the overriden command to do it's job first
> +        retval = F18_AutoPart.parse(self, args)
> +
> +        # Using autopart together with other partitioning command such as
> +        # part/partition, raid, logvol or volgroup can lead to hard to debug
> +        # behavior that might among other result into an unbootable system.
> +        #
> +        # Therefore if any of those commands is detected in the same kickstart
> +        # together with autopart, an error is raised and installation is
> +        # aborted.
> +        conflicting_command = ""
> +
> +        # seen indicates that the corresponding
> +        # command has been seen in kickstart
> +        if self.handler.partition.seen:
> +            conflicting_command = "part/partition)"
> +        elif self.handler.raid.seen:
> +            conflicting_command = "raid"
> +        elif self.handler.volgroup.seen:
> +            conflicting_command = "volgroup"
> +        elif self.handler.logvol.seen:
> +            conflicting_command = "logvol"
> +
> +        if conflicting_command:
> +            # allow for translation of the error message
> +            errorMsg = _("The %s and autopart commands can't be used at the same time")
> +            # set the placeholder with the offending command
> +            errorMsg = errorMsg % conflicting_command
> +            raise KickstartParseError, formatErrorMsg(self.lineno, msg=errorMsg)
> +        return retval

Same two comments as for the RHEL6 version apply here.

- Chris


More information about the anaconda-patches mailing list