From 911c08a72aa3bb6bd72aa6f91f0cc39dc2ff577a Mon Sep 17 00:00:00 2001 From: PengZhihui Date: Wed, 17 Sep 2014 11:18:23 +0800 Subject: [PATCH] =?UTF-8?q?bug=202017:=E4=BF=AE=E6=94=B9=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=EF=BC=8C=E4=BD=BF6.0.42.41=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8fakeraid=E4=B8=8A=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改: main/begin-install 修改: new_partition/interface_partition.py 修改: new_partition/parted_devices.py 修改: new_partition/partition_data.py 修改: operation/install_bootloader.sh 修改: text/get_instmode.sh Signed-off-by: PengZhihui --- main/begin-install | 16 +++++++++++++++- new_partition/interface_partition.py | 9 ++++++++- new_partition/parted_devices.py | 17 ++++++++++++++--- new_partition/partition_data.py | 8 ++++---- operation/install_bootloader.sh | 12 +++++++++--- text/get_instmode.sh | 2 +- 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/main/begin-install b/main/begin-install index 2fe2a98..c778bda 100755 --- a/main/begin-install +++ b/main/begin-install @@ -10,6 +10,20 @@ work_as_net_inst_server(){ /etc/init.d/dhcp start } +activate_dmraid(){ + modprobe dm_mod + dmraid -p -ay + for i in $(dmraid -s -c);do + kpartx -a /dev/mapper/$i + done +} + +dmraid=`cat /proc/cmdline | sed 's/.*dmraid=\([^ ]*\).*/\1/'` + +if [ "$(echo $dmraid |tr '[A-Z]' '[a-z]')" = "true" ];then + activate_dmraid +fi + #instmode=`cat /proc/cmdline | sed 's/.*instmode=\([^ ]*\).*/\1/'` source /usr/lib/new_install/text/get_instmode.sh @@ -20,6 +34,7 @@ if [ -s /hdautoconf/autoinstall.xml ] ; then cd /usr/lib/new_install/text /usr/bin/python ../interface/ri_install.py fi + if [ $instmode = 'Auto' ];then mkdir -pv /var/install/ cp /usr/lib/new_install/xml/install.xml /var/install/install.xml @@ -49,4 +64,3 @@ case $instmode in echo "unknown select" ;; esac - diff --git a/new_partition/interface_partition.py b/new_partition/interface_partition.py index cb181a2..b0f606b 100755 --- a/new_partition/interface_partition.py +++ b/new_partition/interface_partition.py @@ -7,6 +7,8 @@ import partition_data as p_d sys.path.append('../interface/') import ri_data +import subprocess + global base_unit base_unit = 's' @@ -149,13 +151,18 @@ def showPartitionWindow(): if re.search('/dev/md/',dev): continue + #process = subprocess.Popen('dmraid -r -c |tr "\n" " "' ,stdout=subprocess.PIPE, shell=True) + #if dev in process.stdout.readline().strip().split(" "): + # continue + clb.append(["%s" %(dev),"","","","",""], \ "dev:%s:%s" %(dev,dev_size), [LEFT, RIGHT, RIGHT, RIGHT, LEFT, LEFT]) if partition_table == '': continue - if re.search('/cciss/', dev): + #if re.search('/cciss/', dev) or re.search('/mapper/', dev): + if dev[-1].isdigit(): pre_partition_name = dev + 'p' else: pre_partition_name = dev diff --git a/new_partition/parted_devices.py b/new_partition/parted_devices.py index 40bc040..e00f243 100755 --- a/new_partition/parted_devices.py +++ b/new_partition/parted_devices.py @@ -35,7 +35,7 @@ def is_devicemapper(path): def process_device(dev): if dev.readOnly == 1: return - if not is_cdrom(dev.path) or is_floppy(dev.path) or is_devicemapper(dev.path): + if not is_cdrom(dev.path) or is_floppy(dev.path): return if dev.path == "/dev/ramzswap" or dev.path == "/dev/zram": return @@ -45,6 +45,8 @@ def process_device(dev): def get_disks(): disk_list = [] + disk_remove_list = [] + device_list = parted.getAllDevices() for i in range(len(device_list)): @@ -52,9 +54,18 @@ def get_disks(): if item: disk_list.append(item) + for j in range(len(disk_list)): + for k in range(len(disk_list)) : + if k == j: + continue + if re.match(disk_list[k],disk_list[j]): + disk_remove_list.append(disk_list[j]) + + for k in range(len(disk_remove_list)): + disk_list.remove(disk_remove_list[k]) + return disk_list if __name__ == "__main__": - for i in get_disks(): - print i + print get_disks() diff --git a/new_partition/partition_data.py b/new_partition/partition_data.py index 7666f11..5adddb8 100755 --- a/new_partition/partition_data.py +++ b/new_partition/partition_data.py @@ -99,7 +99,9 @@ class Partition: @staticmethod def get_disks(): - return parted_devices.get_disks() + #return parted_devices.get_disks() + process = subprocess.Popen("../new_partition/parted_devices.py" ,stdout=subprocess.PIPE, shell=True) + return eval(process.stdout.readline().rstrip()) @staticmethod def check_partitions(): @@ -470,12 +472,10 @@ def init_from_xml(): if n.nodeName == 'disks': Partition.init_from_xml(n) - - if __name__ == "__main__": Partition.init_from_os(unit='s') #print Partition.get_disk_from_partition('/dev/sdc7') - get_flags('/dev/sdc1') +# get_flags('/dev/sdc1') #for d in Partition.get_raid_devices(): # print d #print Partition.dict.keys() diff --git a/operation/install_bootloader.sh b/operation/install_bootloader.sh index c97b66f..367f335 100755 --- a/operation/install_bootloader.sh +++ b/operation/install_bootloader.sh @@ -73,8 +73,16 @@ EOF # from di grub-install device_to_disk () { - echo "$1" | \ + if [ "$(echo $1 |grep '/dev/mapper')"x != x ];then + if [ "$(echo $1 |grep [0-9]p[0-9]$)"x != x ];then + echo ${1%p*} + else + echo "$1" |sed 's/\(.*[a-z]\)\(.*\)/\1/' + fi + else + echo "$1" | \ sed 's:\(/dev/\(cciss\|ida\|rs\)/c[0-9]d[0-9][0-9]*\|/dev/mmcblk[0-9]\|/dev/\(ad\|da\)[0-9]\+\|/dev/[hs]d[0-9]\+\|/dev/[a-z]\+\).*:\1:' + fi } install_grub2() @@ -91,8 +99,6 @@ install_grub2() chroot $TARGET update-grub > /dev/null 2>&1 } - - main () { if [ $# -eq 0 ];then diff --git a/text/get_instmode.sh b/text/get_instmode.sh index 0cce2e3..4f7e7eb 100755 --- a/text/get_instmode.sh +++ b/text/get_instmode.sh @@ -11,7 +11,7 @@ select_inst_mode(){ [ -z $instmode ] && instmode=`cat /proc/cmdline | sed 's/.*instmode=\([^ ]*\).*/\1/'` -if [ "$instmode" = "HdInstall" -o "$instmode" = "NetInstall" -o "$instmode" = "NoRaid" ];then +if [ "$instmode" = "HdInstall" -o "$instmode" = "NetInstall" -o "$instmode" = "NoRaid" -o "$instmode" = "Dmraid" ];then select_inst_mode fi