From c6fc50e0e0ea2b76113bb9b2968447f03b49a074 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Fri, 22 Jul 2011 12:08:04 +0400 Subject: [PATCH] Add detect type of partition (primary,logical and etc) --- pym/cl_fill_install.py | 4 +++- pym/cl_install.py | 9 +++++---- pym/cl_install_cmd.py | 27 +++++++-------------------- scripts/cl-install | 2 +- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 0d94d1a..dff0e80 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -26,7 +26,8 @@ from cl_utils import isMount,typeFile,getTupleVersion,pathJoin,isFstabMount,\ listDirectory, getAvailableVideo, getUUIDDict, \ getUdevDeviceInfo, getPartitionDevice, getPartitionSize, \ isPkgInstalled, process, checkUtils, readLinesFile, \ - FStab, lspci, getInstalledVideo,getDeviceType + FStab, lspci, getInstalledVideo,getDeviceType, \ + getPartitionType from cl_distr import DistributiveRepository,PartitionDistributive from cl_fill import clLocale from operator import itemgetter @@ -305,6 +306,7 @@ class fillVars(object, glob_attr): dev_hash['id'] =props.get('ID_PART_ENTRY_TYPE','').partition("x")[2] devParent = getPartitionDevice(disk) dev_hash['parent'] = devParent + dev_hash['part'] = getPartitionType(props) dev_hash['options'] = fstab.getBy(what=fstab.OPTS,eq=devName) or "" dev_hash['size'] = getPartitionSize(disk) if devParent in devicesHash and 'ID_PART_ENTRY_NUMBER' in props: diff --git a/pym/cl_install.py b/pym/cl_install.py index 4e2aaff..07e4f19 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -1371,10 +1371,11 @@ class cl_install(color_print, SignalInterrupt): builderMode = self.clVars.Get('os_install_scratch') == "on" clearBuilder = lambda data,isswap: "" if builderMode and isswap != "swap" else data # get hash from current variables - devMount = dict(map(lambda x:(x[0], - {'mountPoint':clearParam(x[1],x[1]), - 'fileSystem':x[2], - 'options':clearParam(x[3],x[1]), + DEV,MOUNT,FS,OPTS = 0,1,2,3 + devMount = dict(map(lambda x:(x[DEV], + {'mountPoint':clearParam(x[MOUNT],x[MOUNT]), + 'fileSystem':x[FS], + 'options':clearParam(x[OPTS],x[MOUNT]), 'isFormat':""}), zip(self.clVars.Get('os_disk_dev'), self.clVars.Get('os_install_disk_mount'), diff --git a/pym/cl_install_cmd.py b/pym/cl_install_cmd.py index 0f89160..b98a927 100644 --- a/pym/cl_install_cmd.py +++ b/pym/cl_install_cmd.py @@ -36,14 +36,9 @@ CMD_OPTIONS = [{'shortOption':"d", 'optVal':"DISK[:[DIR:FILESYSTEM:OPTIONS]]", 'action':'append', 'help':_("the DISK for installation, which mounted to DIR") + - ". " - +_("DIR with value 'none' will cancels the mount point transfer") - }, - {'shortOption':"b", - 'longOption':"bind", - 'optVal':"SRC_DIR:DEST_DIR", - 'action':'append', - 'help':_("bind mount point for instalation") + ". " + + _("DIR with value 'none' will cancels the mount point transfer") + + ". " +_("For creating bind mount point need specify source directory as DISK") }, {'shortOption':"w", 'longOption':"swap", @@ -266,15 +261,6 @@ class install_cmd(share_cmd): self.optobj.error(_("option %s:") %"d" +\ " " + _("disk specifing error: '%s'")\ %", ".join(wrongValue)) - # check syntax SRC_DIR:DEST_DIR - if values.b: - reTrueBind = re.compile("^[^:]+:[^:]+$") - wrongValue = filter(lambda x: not reTrueBind.match(x),values.b) - if wrongValue: - self.optobj.error(_("option %s:") %"b" +\ - " " + _("mount bind specifing error: '%s'")\ - %", ".join(wrongValue)) - # check syntax SWAP_DISK if values.w: reTrueBind = re.compile("^[^:]+$") @@ -364,7 +350,7 @@ class install_cmd(share_cmd): self.logicObj.clVars.Set('cl_action', "merge" if live else "system",True) - def checkAndSetInstallOptions(self,diskOptions, swapOptions, bindOptions, + def checkAndSetInstallOptions(self,diskOptions, swapOptions, usersOptions): """Check and set disk, swap and bind cmd options""" if self.optobj.values.s: @@ -389,8 +375,7 @@ class install_cmd(share_cmd): listDiskOptions = self._parseOptDisk(diskOptions) if listDiskOptions is False: return False - if bindOptions: - listBindOptions = self._parseOptBind(bindOptions) + listBindOptions = self._parseOptBind(diskOptions) if listBindOptions is False: return False if swapOptions: @@ -423,6 +408,7 @@ class install_cmd(share_cmd): def _parseOptBind(self, listOpt): """Parse value cmd option --bind""" + listOpt = filter(lambda x:not x.startswith('/dev/'),listOpt) listNameOptions = ["srcMountPoint", "destMountPoint"] lenOptions = len(listNameOptions) itemOptions = map(lambda x: (x,''), listNameOptions) @@ -445,6 +431,7 @@ class install_cmd(share_cmd): def _parseOptDisk(self, listOpt): """Parse value cmd option --disk""" + listOpt = filter(lambda x:x.startswith('/dev/'),listOpt) listNameOptions = ["dev","mountPoint","fileSystem","options"] lenOptions = len(listNameOptions) itemOptions = map(lambda x: (x,''), listNameOptions) diff --git a/scripts/cl-install b/scripts/cl-install index ce0cdac..012d30e 100644 --- a/scripts/cl-install +++ b/scripts/cl-install @@ -52,7 +52,7 @@ if __name__ == "__main__": # check and set installed options install.setAction(options.live) if not (options.live or options.install or options.uninstall): - if not install.checkAndSetInstallOptions(options.d,options.w,options.b, + if not install.checkAndSetInstallOptions(options.d,options.w, options.u): sys.exit(1) # print variables