From cac740510b578e43849fc63b18505927feea16a2 Mon Sep 17 00:00:00 2001 From: fling Date: Wed, 20 Oct 2010 11:15:14 +0800 Subject: [PATCH] modified: ri_oper.py add check mount point method. --- interface/ri_oper.py | 50 ++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/interface/ri_oper.py b/interface/ri_oper.py index 2bb7ef3..86bcbe4 100644 --- a/interface/ri_oper.py +++ b/interface/ri_oper.py @@ -37,6 +37,21 @@ class Rate: def set(n): Rate.value = n +def check_mount_point(dev,dir): + '''check mount point be used or not. dev is a device of MountPoint.dict, + dir is a directory of MountPoint.dict''' + if dir: + keys = ri_data.MountPoint.dict.keys() + keys.sort() + index = keys.index(dev) + if index < 1: + return False + else: + for k in keys[:index-1]: + if ri_data.MountPoint.dict[k].directory == dir: + return True + return False + class Operation: ''' This is a common base class for all install operations. The instances of its derived class should have the following @@ -156,7 +171,11 @@ class Mount(Operation): def get_stdin(self): mount='' n = 0 - for instance in ri_data.MountPoint.dict.values(): + M_keys = ri_data.MountPoint.dict.keys() + M_keys.sort() + for k in M_keys : + instance = ri_data.MountPoint.dict[k] + if check_mount_point(instance.device, instance.directory): continue if instance.directory != '' and instance.filesystem !='': mount+="/dev/%s %s %s\n"%(instance.device,instance.directory,instance.filesystem) n += 1 @@ -187,10 +206,14 @@ class ConfigureFstab(Mount): def get_stdin(self): fstab='' flag=True - for d in MountPoint.dict.values(): - if d.filesystem != '' and d.directory !='': + M_keys = ri_data.MountPoint.dict.keys() + M_keys.sort() + for k in M_keys: + instance = ri_data.MountPoint.dict[k] + if check_mount_point(instance.device, instance.directory): continue + if instance.filesystem != '' and instance.directory !='': fstab += "/dev/%s %s %s\n" %(d.device, d.directory, d.filesystem) - elif d.filesystem == 'swap' and flag: + elif instance.filesystem == 'swap' and flag: fstab += "/dev/%s swap swap\n" %d.device flag=False return fstab @@ -298,7 +321,6 @@ class ConfigureBootloader(Operation): list=[] tp="grub" isboot=False - isroot=False # FIXME if tag file format is error? if os.path.isfile("/tag"): fd = open("/tag","r") @@ -307,17 +329,19 @@ class ConfigureBootloader(Operation): fd.close() bootloader=['-t',tp,'-o',list[0][5:].split('.')[0]+'.'+list[0][5:].split('.')[1]] - - for instance in ri_data.MountPoint.dict.values(): - if instance.directory == '/' and not isroot: - bootloader+=['-r',instance.device] - isroot=True - continue - if isroot and instance.directory == '/boot' and not isboot : - bootloader+=['-b',instance.device] + M_keys = ri_data.MountPoint.dict.keys() + M_keys.sort() + for k in M_keys: + instance = ri_data.MountPoint.dict[k] + if check_mount_point(instance.device,instance.directory): continue + if instance.directory == '/': + bootloader +=['-r',instance.device] isboot=True continue + if isboot and instance.directory == '/boot': + bootloader += ['-b',instance.device] + if ri_data.SerialNumber.value: bootloader+=['-k',"linx_serial=%s" %ri_data.SerialNumber.value] return bootloader