From 86d6bfc99a34380e4f9576bbd4c6d332ccd15f0c Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 15 Feb 2013 16:46:35 +0200 Subject: [PATCH] kickstart: allow partitions without mount points We need to be able to create partitions without any file-system and without any mount-point. However, the KS files parser does not allow this, which this patch fixes. Change-Id: If046e8895aaa3bb95f25e317464677e019877819 Signed-off-by: Artem Bityutskiy --- mic/3rdparty/pykickstart/commands/partition.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mic/3rdparty/pykickstart/commands/partition.py b/mic/3rdparty/pykickstart/commands/partition.py index 34e5b7a..e65e012 100644 --- a/mic/3rdparty/pykickstart/commands/partition.py +++ b/mic/3rdparty/pykickstart/commands/partition.py @@ -47,7 +47,10 @@ class FC3_PartData(BaseData): self.mountpoint = kwargs.get("mountpoint", "") def __eq__(self, y): - return self.mountpoint == y.mountpoint + if self.mountpoint: + return self.mountpoint == y.mountpoint + else: + return False def _getArgsAsStr(self): retval = "" @@ -83,7 +86,11 @@ class FC3_PartData(BaseData): def __str__(self): retval = BaseData.__str__(self) - retval += "part %s%s\n" % (self.mountpoint, self._getArgsAsStr()) + if self.mountpoint: + mountpoint_str = "%s" % self.mountpoint + else: + mountpoint_str = "(No mount point)" + retval += "part %s%s\n" % (mountpoint_str, self._getArgsAsStr()) return retval class FC4_PartData(FC3_PartData): @@ -238,17 +245,15 @@ class FC3_Partition(KickstartCommand): def parse(self, args): (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "partition") - pd = self.handler.PartData() self._setToObj(self.op, opts, pd) pd.lineno = self.lineno - pd.mountpoint=extra[0] - - # Check for duplicates in the data list. - if pd in self.dataList(): - warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint) + if extra: + pd.mountpoint = extra[0] + if pd in self.dataList(): + warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint) + else: + pd.mountpoint = None return pd -- 2.7.4