kickstart: allow partitions without mount points
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 15 Feb 2013 14:46:35 +0000 (16:46 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 19 Feb 2013 06:47:30 +0000 (08:47 +0200)
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 <artem.bityutskiy@intel.com>
mic/3rdparty/pykickstart/commands/partition.py

index 34e5b7a..e65e012 100644 (file)
@@ -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