a test version which just can be run
there is sth wrong with partition-tools and making raid modified: dialog/di_main.py modified: dialog/di_newt.py modified: interface/ri_install.py modified: interface/ri_oper.py modified: new_partition/interface_partition.py modified: new_partition/partition_data.py modified: xml/config.xml modified: xml/dependency.xml
This commit is contained in:
@@ -1,22 +1,37 @@
|
||||
import os
|
||||
import sys
|
||||
import sys,time
|
||||
sys.path.append('../interface/')
|
||||
sys.path.append('../new_partition/')
|
||||
import ri_data
|
||||
import di_dialog
|
||||
import partition_data
|
||||
import interface_partition
|
||||
import di_newt
|
||||
|
||||
list=['welcome','partition','raid','mountpoint','serialnumber','network','group','service','information']
|
||||
|
||||
init_partition_from_os_flag = True
|
||||
init_flag = True
|
||||
count=0
|
||||
while True :
|
||||
if count == 1:
|
||||
s = os.system("python ../new_partition/interface_partition.py")
|
||||
if init_partition_from_os_flag:
|
||||
partition_data.Partition.init_from_os()
|
||||
init_partition_from_os_flag = False
|
||||
#s = os.system("python ../new_partition/interface_partition.py")
|
||||
s = interface_partition.main()
|
||||
|
||||
ri_data.init()
|
||||
if len(di_newt.Raid.raid_raw_init()) < 2:
|
||||
if init_flag:
|
||||
ri_data.init()
|
||||
init_flag = False
|
||||
#print 'debug'
|
||||
#print len(di_newt.Raid.init_from_internal())
|
||||
#time.sleep(10)
|
||||
if len(di_newt.Raid.init_from_internal()) < 2:
|
||||
if list[2] == 'raid':
|
||||
del list[2]
|
||||
else:
|
||||
#print 'debug'
|
||||
#time.sleep(10)
|
||||
if list[2] != 'raid':
|
||||
list.insert(2, 'raid')
|
||||
else:
|
||||
|
||||
@@ -3,6 +3,7 @@ from snack import *
|
||||
import sys
|
||||
import re
|
||||
import time
|
||||
import interface_partition
|
||||
sys.path.append('../interface/')
|
||||
sys.path.append('../new_partition/')
|
||||
|
||||
@@ -19,14 +20,16 @@ class Screen:
|
||||
def __init__(self, name='screen', title='Welcome to Rocky Security OS', helpline='', text=''):
|
||||
Screen.screen = SnackScreen()
|
||||
Screen.screen.drawRootText(0, 0, title)
|
||||
helpline='<Tab>/<Alt-Tab> between elments | <Space> selects | <F5> Next | <F12> OK/Edit/Install'
|
||||
helpline='<Tab>/<Alt-Tab> between elments | <Space> selects | <F5> Next | <F11> Cancel | <F12> OK/Edit/Install | <ESC> Quit'
|
||||
Screen.screen.pushHelpLine(helpline)
|
||||
Screen.dict[name] = self
|
||||
Screen.buttonlist1 = [('OK','ok','F12'),('Cancel','cancel')]
|
||||
Screen.buttonlist2 = [('OK','ok','F12'),('Cancel','cancel'),('Next','next','F5')]
|
||||
Screen.buttonlist3 = [('Edit','ok','F12'),('Cancel','cancel'),('Next','next','F5')]
|
||||
Screen.buttonlist4 = [('Install','ok','F12'),('Back','cancel')]
|
||||
|
||||
Screen.buttonlist0 = [('OK','ok','F12'),('Cancel','cancel','F11')]
|
||||
Screen.buttonlist1 = [('OK','ok','F12'),('Cancel','cancel','F11'),('Quit','quit','ESC')]
|
||||
Screen.buttonlist2 = [('OK','ok','F12'),('Cancel','cancel','F11'),('Next','next','F5'),('Quit','quit','ESC')]
|
||||
Screen.buttonlist3 = [('Edit','ok','F12'),('Cancel','cancel','F11'),('Next','next','F5'),('Quit','quit','ESC')]
|
||||
Screen.buttonlist4 = [('Install','ok','F12'),('Back','cancel','F11')]
|
||||
Screen.buttonlist5 = [('OK','ok','F12'),('Cancel','cancel','F11'),('Next','next','F5')]
|
||||
|
||||
@staticmethod
|
||||
def container_gridform(gridtitle, gridx, gridy):
|
||||
Screen.gridform = GridForm(Screen.screen, gridtitle, gridy, gridx)
|
||||
@@ -84,6 +87,12 @@ class Screen:
|
||||
for item in li_item:
|
||||
Screen.d_cbl[item] = Checkbox(item)
|
||||
|
||||
@staticmethod
|
||||
def widget_checkboxtree(h, li_item):
|
||||
Screen.checkboxtree = CheckboxTree(h, scroll=1)
|
||||
for item in li_item:
|
||||
Screen.checkboxtree.append(item)
|
||||
|
||||
@staticmethod
|
||||
def widget_label(string):
|
||||
Screen.label = Label(string)
|
||||
@@ -92,6 +101,10 @@ class Screen:
|
||||
def widget_entry(width, text=''):
|
||||
Screen.entry = Entry(width, text)
|
||||
|
||||
@staticmethod
|
||||
def widget_checkbox(text):
|
||||
Screen.checkbox = Checkbox(text)
|
||||
|
||||
@staticmethod
|
||||
def widget_listbox(h, *lis):
|
||||
Screen.listbox = Listbox(height=h, scroll=1)
|
||||
@@ -151,6 +164,9 @@ class Screen:
|
||||
elif i == 'Entry':
|
||||
Screen.gridform.add(Screen.entry, 0, count)
|
||||
count = count + 1
|
||||
elif i == 'Checkbox':
|
||||
Screen.gridform.add(Screen.checkbox, 0, count)
|
||||
count = count + 1
|
||||
elif i == 'eLabel':
|
||||
Screen.gridform.add(Label(""), 0, count)
|
||||
count = count + 1
|
||||
@@ -170,6 +186,9 @@ class Screen:
|
||||
for i in Screen.d_cbl:
|
||||
Screen.gridform.add(Screen.d_cbl[i], 0, count, padding=(13,0,0,0), anchorLeft=1)
|
||||
count = count + 1
|
||||
elif i == 'CheckboxTree':
|
||||
Screen.gridform.add(Screen.checkboxtree,0,count)
|
||||
count = count + 1
|
||||
elif i == 'Grid':
|
||||
Screen.gridform.add(Screen.grid, 0, count)
|
||||
count = count + 1
|
||||
@@ -189,13 +208,16 @@ class Screen:
|
||||
s = -1
|
||||
elif Screen.bb.buttonPressed(res) == "next":
|
||||
s = 'help'
|
||||
elif Screen.bb.buttonPressed(res) == "quit":
|
||||
Screen.screen.finish()
|
||||
sys.exit(-1)
|
||||
if locals().has_key('s'):
|
||||
return s
|
||||
|
||||
@staticmethod
|
||||
def pop_window(title, text):
|
||||
def pop_window(title, text, width):
|
||||
Screen.p_window = GridForm(Screen.screen, title, 1, 2)
|
||||
Screen.p_window.add(TextboxReflowed(30, text),0,0)
|
||||
Screen.p_window.add(TextboxReflowed(width, text),0,0)
|
||||
Screen.p_window.add(Button('OK'),0,1)
|
||||
Screen.p_window.runOnce()
|
||||
|
||||
@@ -209,7 +231,7 @@ class Welcome(Screen):
|
||||
|
||||
self.text = 'Welcome!\n\nThis script will guide you through the installation of RSS packages.\n\nIf you want to install the system, then please continue, else abort the installation and come back later.\n\nAre you really sure you want to continue?'
|
||||
Screen.widget_textboxreflowed(50, self.text)
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_buttonbar(Screen.buttonlist0)
|
||||
|
||||
def set_data(self):
|
||||
s = Screen.yesno('welcome', 1, 3, 'TextboxReflowed', 'eLabel', 'ButtonBar')
|
||||
@@ -241,7 +263,11 @@ class Raid(Screen):
|
||||
# get all component devices already in raid
|
||||
dev_in_raid = ri_data.Raid.dev_in_raid()
|
||||
|
||||
raw_devs = [ d for d in p_d.Partition.get_raid() and d not in dev_in_raid ]
|
||||
#raw_devs = [ d for d in p_d.Partition.get_raid_devices() and d not in dev_in_raid ]
|
||||
raw_devs = []
|
||||
for d in p_d.Partition.get_raid_devices():
|
||||
if d not in dev_in_raid:
|
||||
raw_devs.append(d)
|
||||
raw_devs.sort()
|
||||
return raw_devs
|
||||
|
||||
@@ -259,27 +285,36 @@ class Raid(Screen):
|
||||
if not list:
|
||||
return 0
|
||||
|
||||
list_cb = []
|
||||
list_ct = []
|
||||
for i in list:
|
||||
list_cb.append(i[0])
|
||||
list_ct.append(i[0])
|
||||
|
||||
Screen.widget_checkboxlist(list_cb)
|
||||
#Screen.widget_checkboxlist(list_cb)
|
||||
#if len(list_ct) <= 5:
|
||||
# h = len(list_ct)
|
||||
#else:
|
||||
# h = 5
|
||||
h = 5 if len(list_ct) > 5 else len(list_ct)
|
||||
Screen.widget_checkboxtree(h,list_ct)
|
||||
|
||||
num_widget = len(list) + 4
|
||||
#num_widget = len(list) + 4
|
||||
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_buttonbar(Screen.buttonlist0)
|
||||
Screen.widget_textboxreflowed(47, 'Please select the active fd')
|
||||
while True:
|
||||
s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
s = Screen.yesno(self.title, 1, 5, 'TextboxReflowed', 'eLabel', 'CheckboxTree', 'eLabel', 'ButtonBar')
|
||||
#s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
|
||||
if s == 0:
|
||||
actives = []
|
||||
for i in list:
|
||||
if Screen.d_cbl[i[0]].value() == 1:
|
||||
actives.append(i[0])
|
||||
for i in Screen.checkboxtree.getSelection():
|
||||
actives.append(i)
|
||||
#for i in list:
|
||||
# if Screen.d_cbl[i[0]].value() == 1:
|
||||
# actives.append(i[0])
|
||||
if int(level) < 2 and len(actives) < 2 :
|
||||
#ButtonChoiceWindow(Screen.screen, 'Warning', 'Making a raid0 or raid1 needs two or more partitions.')
|
||||
Screen.pop_window('Tips', 'Making a raid0 or raid1 needs two or more partitions.')
|
||||
Screen.pop_window('Tips', 'Making a raid0 or raid1 needs two or more partitions.',30)
|
||||
elif int(level) == 5 and len(actives) < 3:
|
||||
ButtonChoiceWindow(Screen.screen, 'Warning', 'Making a raid5 needs three or more partitions.')
|
||||
else:
|
||||
@@ -303,22 +338,37 @@ class Raid(Screen):
|
||||
if not list:
|
||||
return 0
|
||||
|
||||
Screen.d_cbl = {}
|
||||
#Screen.d_cbl = {}
|
||||
#for i in list:
|
||||
# Screen.d_cbl[i[0]] = Checkbox(i[0])
|
||||
list_ct = []
|
||||
for i in list:
|
||||
Screen.d_cbl[i[0]] = Checkbox(i[0])
|
||||
list_ct.append(i[0])
|
||||
|
||||
num_widget = len(list) + 4
|
||||
#if len(list_ct) <= 5:
|
||||
# h = len(list_ct)
|
||||
#else:
|
||||
# h = 5
|
||||
h = 5 if len(list_ct) > 5 else len(list_ct)
|
||||
|
||||
Screen.widget_checkboxtree(h, list_ct)
|
||||
|
||||
#num_widget = len(list) + 4
|
||||
|
||||
Screen.widget_textboxreflowed(47, 'Please select the spare fd')
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_buttonbar(Screen.buttonlist0)
|
||||
|
||||
s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
#s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
s = Screen.yesno(self.title, 1, 5, 'TextboxReflowed', 'eLabel', 'CheckboxTree', 'eLabel', 'ButtonBar')
|
||||
|
||||
if s == 0:
|
||||
spares = []
|
||||
for i in list:
|
||||
if Screen.d_cbl[i[0]].value() == 1:
|
||||
spares.append(i[0])
|
||||
#for i in list:
|
||||
# if Screen.d_cbl[i[0]].value() == 1:
|
||||
# spares.append(i[0])
|
||||
for i in Screen.checkboxtree.getSelection():
|
||||
spares.append(i)
|
||||
|
||||
#(dev, from_os, level, a_devs, s_devs=[]):
|
||||
if dname not in ri_data.Raid.dict.keys():
|
||||
ri_data.Raid(dname,'no',level,[],spares)
|
||||
@@ -339,7 +389,7 @@ class Raid(Screen):
|
||||
|
||||
raidx = ['raid0','raid1','raid5']
|
||||
Screen.widget_listbox(3, *raidx)
|
||||
Screen.widget_buttonbar(Screen.buttonlist2)
|
||||
Screen.widget_buttonbar(Screen.buttonlist5)
|
||||
Screen.widget_textboxreflowed(50, 'Please select make raidX\n%s\n%s' %(raid_text, fd_devices_text))
|
||||
|
||||
s = Screen.yesno(self.title, 1, 6, 'TextboxReflowed', 'eLabel', 'Listbox', 'eLabel', 'ButtonBar')
|
||||
@@ -365,11 +415,13 @@ class Raid(Screen):
|
||||
len_raid_choices = len(raid_choices)
|
||||
#Screen.widget_listbox(len_raid_choices, *raid_choices)
|
||||
|
||||
if len(raid_choices) > 5:
|
||||
h = 5
|
||||
else:
|
||||
h = len(raid_choices)
|
||||
#if len(raid_choices) > 5:
|
||||
# h = 5
|
||||
#else:
|
||||
# h = len(raid_choices)
|
||||
h = 5 if len(raid_choices) > 5 else len(raid_choices)
|
||||
|
||||
Screen.widget_buttonbar(Screen.buttonlist5)
|
||||
Screen.listbox = Listbox(height=h, scroll=1)
|
||||
for i in raid_choices:
|
||||
Screen.listbox.append(i[0],i[0])
|
||||
@@ -428,55 +480,102 @@ class MountPoint(Screen):
|
||||
def __init__(self):
|
||||
Screen.__init__(self, name='mountpoint')
|
||||
self.title = 'MountPoint Configure'
|
||||
self.disks = p_d.Partition.dict.keys()
|
||||
self.disks.sort()
|
||||
|
||||
def check_mountpoint(self,flag='one'):
|
||||
nonmount_dir = ['/dev','/etc','/lib64','/lib','/bin','/sbin','/proc','/sys']
|
||||
if flag == 'one':
|
||||
mountpoint = Screen.entry.value()
|
||||
if not mountpoint:
|
||||
return True
|
||||
for m in nonmount_dir:
|
||||
if re.match(m+'/',mountpoint) or m == mountpoint:
|
||||
return False
|
||||
if mountpoint[0] != '/':
|
||||
return False
|
||||
else:
|
||||
for i in mountpoint[1:len(mountpoint)]:
|
||||
if i == ' ':
|
||||
return False
|
||||
return True
|
||||
elif flag == 'all':
|
||||
list_mountpoint = []
|
||||
for d in self.disks:
|
||||
if p_d.Partition.dict[d]['partition_table'] == ' ':
|
||||
continue
|
||||
for p in p_d.sort_partitions(p_d.Partition.dict, d, 'partition'):
|
||||
if p_d.Partition.dict[d]['partition'][p]['mount_point'] != '':
|
||||
list_mountpoint.append(p_d.Partition.dict[d]['partition'][p]['mount_point'])
|
||||
if len(list_mountpoint) != len(list(set(list_mountpoint))) or '/' not in list_mountpoint:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def set_mountpoint(self, device):
|
||||
disk = device.split(':')[0]
|
||||
dev = device.split(':')[1]
|
||||
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_buttonbar(Screen.buttonlist0)
|
||||
Screen.widget_textboxreflowed(30, 'Please input the mountpoint and select the file system type.')
|
||||
Screen.label_mp = Label('mountpoint : ')
|
||||
Screen.label_fs = Label('File System Type : ')
|
||||
Screen.widget_label('')
|
||||
|
||||
Screen.widget_checkbox('Format the partition')
|
||||
if p_d.Partition.dict[disk]['partition'][dev]['format'] == 'yes':
|
||||
Screen.checkbox.setValue('*')
|
||||
|
||||
fs_list = ['ext2','ext3', 'ext4', 'swap', 'reiserfs', 'xfs', 'jfs']
|
||||
Screen.widget_listbox(3, *fs_list)
|
||||
Screen.listbox.setCurrent('ext3')
|
||||
Screen.widget_entry(15, text='')
|
||||
Screen.widget_entry(15, text=p_d.Partition.dict[disk]['partition'][dev]['mount_point'])
|
||||
Screen.container_grid_complex(3, 2, Screen.label_mp, Screen.entry, Screen.label, Screen.label, Screen.label_fs, Screen.listbox)
|
||||
s = Screen.yesno(self.title, 1, 6, 'TextboxReflowed', 'eLabel', 'Grid_Complex', 'eLabel', 'ButtonBar')
|
||||
if s == 0:
|
||||
p_d.Partition.dict[disk]['partition'][dev]['filesystem'] = Screen.listbox.current()
|
||||
p_d.Partition.dict[disk]['partition'][dev]['mount_point'] = Screen.entry.value()
|
||||
p_d.Partition.dict[disk]['partition'][dev]['format'] = 'yes'
|
||||
|
||||
while True:
|
||||
s = Screen.yesno(self.title, 1, 8, 'TextboxReflowed', 'eLabel', 'Grid_Complex', 'eLabel', 'Checkbox','eLabel','ButtonBar')
|
||||
if s == 0:
|
||||
if not self.check_mountpoint(flag='one'):
|
||||
Screen.pop_window('Invalid mount point','The mount point you entered is invalid.\nMount point must start with "/".They cannot contain spaces.\nMount point cannot be "/dev","/etc","/lib","lib64","/bin","/sbin","/proc","/sys".\n', 50)
|
||||
continue
|
||||
if Screen.entry.value() != '' or Screen.checkbox.value() == 1:
|
||||
p_d.Partition.dict[disk]['partition'][dev]['format'] = 'yes'
|
||||
else:
|
||||
p_d.Partition.dict[disk]['partition'][dev]['format'] = 'no'
|
||||
p_d.Partition.dict[disk]['partition'][dev]['filesystem'] = Screen.listbox.current()
|
||||
p_d.Partition.dict[disk]['partition'][dev]['mount_point'] = Screen.entry.value()
|
||||
break
|
||||
#p_d.Partition.dict[disk]['partition'][dev]['format'] = 'yes'
|
||||
else:
|
||||
break
|
||||
return s
|
||||
|
||||
def set_data(self):
|
||||
ri_data.MountPoint.init_from_internal()
|
||||
while True:
|
||||
disks = p_d.Partition.dict.keys()
|
||||
disks.sort()
|
||||
|
||||
#len_keys = len(keys)
|
||||
# 18 is length of '/dev/cciss/c0d0p1'
|
||||
list_col_widths = [18, 12, 10, 15, 10]
|
||||
list_col_labels = []
|
||||
list_col_label_align = [CENTER, CENTER, CENTER, CENTER, CENTER]
|
||||
Screen.widget_clistbox(list_col_widths, list_col_labels, list_col_label_align, h=5)
|
||||
for d in disks:
|
||||
for d in self.disks:
|
||||
if p_d.Partition.dict[d]['partition_table'] == ' ':
|
||||
continue
|
||||
partitions = p_d.sort_partitions(p_d.Partition.dict, d, 'partition')
|
||||
for p in partitions:
|
||||
# loop for nest dict to find partition
|
||||
for k in p_d.Partition.dict[d]['partition'].keys():
|
||||
if p == k:
|
||||
if p_d.Partition.dict[d]['partition'][p]['type'] == 'extended':
|
||||
continue
|
||||
size_pretty = interface_partition.pretty_unit(filter(str.isdigit, str(p_d.Partition.dict[d]['partition'][p]['size'])))
|
||||
Screen.clistbox.append(["%s" %(p),
|
||||
"%s" %(p_d.Partition.dict[d]['partition'][p]['mount_point'].ljust(10)),
|
||||
"%s" %(p_d.Partition.dict[d]['partition'][p]['filesystem'].ljust(10)),
|
||||
"%s" %(p_d.Partition.dict[d]['partition'][p]['format'].ljust(5)),
|
||||
"%s%s" %(p_d.Partition.dict[d]['partition'][p]['size'], p_d.Partition.unit)],
|
||||
"%s" %(size_pretty)],
|
||||
"%s:%s" %(d, p),
|
||||
[LEFT, LEFT, LEFT, LEFT, RIGHT])
|
||||
[LEFT, LEFT, LEFT, LEFT, CENTER])
|
||||
break
|
||||
|
||||
Screen.widget_buttonbar(Screen.buttonlist3)
|
||||
@@ -486,9 +585,12 @@ class MountPoint(Screen):
|
||||
if s == 0:
|
||||
self.set_mountpoint(Screen.clistbox.current())
|
||||
# edit mountpoint
|
||||
elif s == None:
|
||||
pass
|
||||
elif s == -1:
|
||||
break
|
||||
else:
|
||||
if not self.check_mountpoint(flag='all'):
|
||||
Screen.pop_window('Invalid mount point','Two file systems must not be assigned the same mount point.\nA root file system is needed.\nPlease correct this by changing mount points.', 50)
|
||||
continue
|
||||
break
|
||||
return (s == 'help' and '0' or s)
|
||||
|
||||
@@ -515,7 +617,6 @@ class Network(Screen):
|
||||
if t == 'dynamic':
|
||||
Screen.widget_textboxreflowed(50, 'Please enter the hostname:')
|
||||
Screen.widget_entry(20, text=getattr(ri_data.Network, 'hostname'))
|
||||
#Screen.widget_entry(30, text='linx')
|
||||
s = Screen.yesno(self.title, 1, 6, 'TextboxReflowed', 'eLabel', 'Entry', 'eLabel', 'ButtonBar')
|
||||
if s == 0:
|
||||
setattr(ri_data.Network, 'hostname', Screen.entry.value())
|
||||
@@ -543,8 +644,7 @@ class Network(Screen):
|
||||
setattr(ri_data.Network, 'primary_dns', Screen.entry_primary_dns.value())
|
||||
break
|
||||
else:
|
||||
#ButtonChoiceWindow(Screen.screen, 'Warning', 'There is something wrong with your input network address.')
|
||||
Screen.pop_window('Tips', 'There is something wrong with your input network address.')
|
||||
Screen.pop_window('Tips', 'There is something wrong with your input network address.', 30)
|
||||
elif s == -1:
|
||||
break
|
||||
else:
|
||||
@@ -574,25 +674,39 @@ class Group(Screen):
|
||||
self.title = 'Package Group Selcect'
|
||||
|
||||
def set_data(self):
|
||||
|
||||
ri_data.Group.dict['base'].install = 'yes'
|
||||
ri_data.Group.dict['base'].selection = 'all'
|
||||
g_list = []
|
||||
for g in ri_data.Group.dict.keys():
|
||||
g_list.append(g.encode('ascii'))
|
||||
if g.encode('ascii') != 'base':
|
||||
g_list.append(g.encode('ascii'))
|
||||
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_textboxreflowed(50, 'Please select the software package groups')
|
||||
Screen.widget_checkboxlist(g_list)
|
||||
#Screen.widget_checkboxlist(g_list)
|
||||
h = 5 if len(g_list) > 5 else len(g_list)
|
||||
Screen.widget_checkboxtree(h, g_list)
|
||||
|
||||
for g in g_list:
|
||||
if ri_data.Group.dict[g].install == 'yes':
|
||||
Screen.d_cbl[g].setValue('*')
|
||||
#Screen.d_cbl[g].setValue('*')
|
||||
Screen.checkboxtree.setEntryValue(g, selected=1)
|
||||
|
||||
num_widget = len(g_list) + 4
|
||||
#num_widget = len(g_list) + 4
|
||||
|
||||
s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
#s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
s = Screen.yesno(self.title, 1, 5, 'TextboxReflowed', 'eLabel', 'CheckboxTree', 'eLabel', 'ButtonBar')
|
||||
|
||||
if s == 0:
|
||||
#for g in g_list:
|
||||
# if Screen.d_cbl[g].value() == 1:
|
||||
# ri_data.Group.dict[g].install='yes'
|
||||
# ri_data.Group.dict[g].selection='all'
|
||||
# else:
|
||||
# ri_data.Group.dict[g].install='no'
|
||||
for g in g_list:
|
||||
if Screen.d_cbl[g].value() == 1:
|
||||
if g in Screen.checkboxtree.getSelection():
|
||||
ri_data.Group.dict[g].install='yes'
|
||||
ri_data.Group.dict[g].selection='all'
|
||||
else:
|
||||
@@ -610,31 +724,48 @@ class Service(Screen):
|
||||
ri_data.Service.change_state()
|
||||
|
||||
s_list = ['check all']
|
||||
#print ri_data.Service.list
|
||||
for s in ri_data.Service.list:
|
||||
if s.start != 'disable':
|
||||
s_list.append(s.name)
|
||||
|
||||
#print s_list
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
Screen.widget_textboxreflowed(50, 'Please select the start services')
|
||||
Screen.widget_checkboxlist(s_list)
|
||||
#Screen.widget_checkboxlist(s_list)
|
||||
h = 5 if len(s_list) > 5 else len(s_list)
|
||||
Screen.widget_checkboxtree(h, s_list)
|
||||
|
||||
for service in ri_data.Service.list:
|
||||
if service.start == 'yes':
|
||||
Screen.d_cbl[service.name].setValue('*')
|
||||
#Screen.d_cbl[service.name].setValue('*')
|
||||
Screen.checkboxtree.setEntryValue(service.name, selected=1)
|
||||
|
||||
num_widget = len(s_list) + 4
|
||||
#num_widget = len(s_list) + 4
|
||||
|
||||
s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
#s = Screen.yesno(self.title, 1, num_widget, 'TextboxReflowed', 'eLabel', 'CheckboxList', 'eLabel', 'ButtonBar')
|
||||
s = Screen.yesno(self.title, 1, 5, 'TextboxReflowed', 'eLabel', 'CheckboxTree', 'eLabel', 'ButtonBar')
|
||||
|
||||
if s == 0:
|
||||
if Screen.d_cbl[s_list[0]].value() == 1:
|
||||
#if Screen.d_cbl[s_list[0]].value() == 1:
|
||||
# for service in ri_data.Service.list:
|
||||
# if service.start != 'disable':
|
||||
# service.start='yes'
|
||||
#else:
|
||||
# for service in ri_data.Service.list:
|
||||
# if service.start != 'disable':
|
||||
# if Screen.d_cbl[service.name].value() == 1:
|
||||
# service.start = 'yes'
|
||||
# else:
|
||||
# service.start = 'no'
|
||||
if 'check all' in Screen.checkboxtree.getSelection():
|
||||
for service in ri_data.Service.list:
|
||||
if service.start != 'disable':
|
||||
service.start='yes'
|
||||
else:
|
||||
for service in ri_data.Service.list:
|
||||
if service.start != 'disable':
|
||||
if Screen.d_cbl[service.name].value() == 1:
|
||||
if service.name in Screen.checkboxtree.getSelection():
|
||||
service.start = 'yes'
|
||||
else:
|
||||
service.start = 'no'
|
||||
@@ -680,10 +811,3 @@ class Prepar_installation(Screen):
|
||||
#print s
|
||||
#print s
|
||||
#print Screen.dict
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ ri_oper.display_operation = display.set_task
|
||||
ri_oper.display_sub_operation = display.set_sub_task
|
||||
ri_oper.display_scale = display.set_task_scale
|
||||
|
||||
oper_list = [ri_oper.MakePartitions(5),ri_oper.MakeRaid(3),ri_oper.Format(7),ri_oper.Mount(3),ri_oper.InstallPkg(49),ri_oper.MakeRaidConfigure(2),ri_oper.ConfigureFstab(5),ri_oper.GenerateIssue(3),ri_oper.ConfigureNetwork(2),ri_oper.MakeServiceAutoBoot(5),ri_oper.CopyKernel(7),ri_oper.ConfigureBootloader(5),ri_oper.BootLoader(2),ri_oper.ExecFinishInstall(2)]
|
||||
#oper_list = [ri_oper.MakePartitions(5),ri_oper.MakeRaid(3),ri_oper.Format(7),ri_oper.Mount(3),ri_oper.InstallPkg(49),ri_oper.MakeRaidConfigure(2),ri_oper.ConfigureFstab(5),ri_oper.GenerateIssue(3),ri_oper.ConfigureNetwork(2),ri_oper.MakeServiceAutoBoot(5),ri_oper.CopyKernel(7),ri_oper.ConfigureBootloader(5),ri_oper.BootLoader(2),ri_oper.ExecFinishInstall(2)]
|
||||
oper_list = [ri_oper.MakePartitions(5),ri_oper.MakeRaid(4),ri_oper.Format(7),ri_oper.Mount(4),ri_oper.InstallPkg(49),ri_oper.MakeRaidConfigure(3),ri_oper.ConfigureFstab(5),ri_oper.GenerateIssue(4),ri_oper.ConfigureNetwork(3),ri_oper.MakeServiceAutoBoot(5),ri_oper.ConfigureBootloader(5),ri_oper.BootLoader(3),ri_oper.ExecFinishInstall(3)]
|
||||
|
||||
display.start(main)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import ri_data
|
||||
import ri_dep
|
||||
import os,sys
|
||||
import os,sys,time
|
||||
import subprocess
|
||||
import signal
|
||||
sys.path.append('../new_partition/')
|
||||
@@ -136,13 +136,20 @@ class MakePartitions(Operation):
|
||||
set_flg = ''
|
||||
if p_d.Partition.dict[d]['partition'][p]['from_os'] == 'yes':
|
||||
continue
|
||||
fs_type = p_d.Partition.dict[d]['partition'][p]['filesystem']
|
||||
start = p_d.Partition.dict[d]['partition'][p]['start']
|
||||
#fs_type = p_d.Partition.dict[d]['partition'][p]['filesystem']
|
||||
end = p_d.Partition.dict[d]['partition'][p]['end']
|
||||
start = p_d.Partition.dict[d]['partition'][p]['start']
|
||||
start = str(int(filter(str.isdigit,p_d.Partition.dict[d]['partition'][p]['start'])) + 511)+'B'
|
||||
#support 4k align
|
||||
if int(filter(str.isdigit,start)) < 2*1000*1000:
|
||||
start = '1048576B'
|
||||
if int(filter(str.isdigit,end)) < 2*1000*1000:
|
||||
end = '2000000'
|
||||
p_type = p_d.Partition.dict[d]['partition'][p]['type']
|
||||
partition = p_d.Partition.dict[d]['partition'][p]['num']
|
||||
flags = p_d.Partition.dict[d]['partition'][p]['flags']
|
||||
mkpart = "%s mkpart %s %s %s %s" %(d, p_type, fs_type, start, end)
|
||||
#mkpart = "%s mkpart %s %s %s %s" %(d, p_type, fs_type, start, end)
|
||||
mkpart = "%s mkpart %s %s %s" %(d, p_type, start, end)
|
||||
if flags.strip():
|
||||
set_flg = "set %s %s on" %(partition, flags)
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@ import gettext, sys, os, re, string, time
|
||||
|
||||
import partition_data as p_d
|
||||
|
||||
screen = SnackScreen()
|
||||
screen.drawRootText(0, 0, "Welcome to Rocky Security OS")
|
||||
screen.pushHelpLine( (" F1-New F2-Delete F3-Boot F4-Raid F12-OK "))
|
||||
|
||||
global base_unit
|
||||
base_unit = 'B'
|
||||
|
||||
@@ -80,8 +76,8 @@ def unit_to_byte(num_unit):
|
||||
def showPartitionWindow():
|
||||
global clb
|
||||
global bb
|
||||
bb = ButtonBar (screen, (("New", "new", "F1"),("Delete", "delete", "F2"),("Boot", "boot", "F3"),\
|
||||
("Raid", "raid", "F4"),("OK", "ok", "F12"),("Cancel", "cancel"),))
|
||||
bb = ButtonBar (screen, (("New", "new"),("Delete", "delete"),("Boot", "boot"),\
|
||||
("Raid", "raid"),("OK", "ok", "F12"),("Cancel", "cancel","F11"),('Quit','quit','ESC')))
|
||||
|
||||
clb = CListbox(height=10, cols=6,
|
||||
col_widths=[19,11,11,11,10,12],
|
||||
@@ -99,7 +95,7 @@ def showPartitionWindow():
|
||||
clb.append(["%s" %(dev),"","","","",""], \
|
||||
"dev:%s:%s" %(dev,dev_size), [LEFT, RIGHT, RIGHT, RIGHT, LEFT, LEFT])
|
||||
|
||||
if partition_table == None:
|
||||
if partition_table == ' ':
|
||||
continue
|
||||
|
||||
if re.search('/cciss/', dev):
|
||||
@@ -146,10 +142,7 @@ def showPartitionWindow():
|
||||
f = Form()
|
||||
f.add(bb)
|
||||
f.add(clb)
|
||||
f.addHotKey("F1")
|
||||
f.addHotKey("F2")
|
||||
f.addHotKey("F3")
|
||||
f.addHotKey("F4")
|
||||
f.addHotKey("F11")
|
||||
f.addHotKey("F12")
|
||||
|
||||
global res
|
||||
@@ -191,13 +184,13 @@ def count_primary_extended(dev):
|
||||
return (count_primary, count_extended)
|
||||
|
||||
def get_extended_start_end(dev):
|
||||
extended_start = ''
|
||||
extended_end = ''
|
||||
#extended_start = ''
|
||||
#extended_end = ''
|
||||
for p in p_d.sort_partitions(p_d.Partition.dict, dev):
|
||||
if p_d.Partition.dict[dev]['partition'][p]['type'] == 'extended':
|
||||
extended_start = p_d.Partition.dict[dev]['partition'][p]['start']
|
||||
extended_end = p_d.Partition.dict[dev]['partition'][p]['end']
|
||||
return (extended_start, extended_end)
|
||||
return (extended_start, extended_end)
|
||||
|
||||
def add_partition(ptype='', extended='', label=''):
|
||||
free_space = clb.current().split(":")[1]
|
||||
@@ -208,7 +201,7 @@ def add_partition(ptype='', extended='', label=''):
|
||||
free_space_start = filter(str.isdigit, clb.current().split(":")[4])
|
||||
free_space_end = filter(str.isdigit, clb.current().split(":")[5])
|
||||
free_space_sn = int(p_d.Partition.dict[dev]['partition'][free_space]['sn'])
|
||||
|
||||
pre_partition_name = clb.current().split(":")[8]
|
||||
size_num = filter(str.isdigit, size)
|
||||
unit = filter(str.isalpha, size_pretty)
|
||||
size_pretty_num = get_size_num(size_pretty)
|
||||
@@ -279,7 +272,7 @@ def add_partition(ptype='', extended='', label=''):
|
||||
if flags == '':
|
||||
flags = 'boot'
|
||||
else:
|
||||
flags = flags + ',boot'
|
||||
flags = 'boot,' + flags
|
||||
if fs_set == 'raid':
|
||||
if flags == '':
|
||||
flags = 'raid'
|
||||
@@ -319,7 +312,7 @@ def add_partition(ptype='', extended='', label=''):
|
||||
partition_sn = free_space_sn
|
||||
|
||||
if float(get_size_num(size_set_pretty)) == float(get_size_num(size_pretty)):
|
||||
partition_end = free_space_end
|
||||
partition_end = free_space_end + base_unit
|
||||
if len(list_free_sorted) > 1:
|
||||
for p in list_free_sorted:
|
||||
if int(p_d.Partition.dict[dev]['partition'][p]['sn']) >= int(free_space_sn):
|
||||
@@ -352,6 +345,8 @@ def add_partition(ptype='', extended='', label=''):
|
||||
p_d.Partition.dict[dev]['partition'][partition]['filesystem'] = fs_set
|
||||
p_d.Partition.dict[dev]['partition'][partition]['flags'] = flags
|
||||
p_d.Partition.dict[dev]['partition'][partition]['from_os'] = 'no'
|
||||
p_d.Partition.dict[dev]['partition'][partition]['format'] = 'no'
|
||||
p_d.Partition.dict[dev]['partition'][partition]['mount_point'] = ''
|
||||
|
||||
if ptype == 'extended':
|
||||
list_partition_all_sorted = p_d.sort_partitions(p_d.Partition.dict,dev, 'all')
|
||||
@@ -377,8 +372,8 @@ def add_partition(ptype='', extended='', label=''):
|
||||
p_d.Partition.dict[dev]['partition'][p]['end']
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num+1)]['size'] =\
|
||||
p_d.Partition.dict[dev]['partition'][p]['size']
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num+1)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num+1)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num+1)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num+1)]['flags'] = ''
|
||||
else:
|
||||
p_d.Partition.dict[dev]['partition'][p]['sn'] = p_d.Partition.dict[dev]['partition'][p]['sn']+1
|
||||
|
||||
@@ -395,8 +390,18 @@ def add_partition(ptype='', extended='', label=''):
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['size'] = size_set
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['flags'] = ''
|
||||
|
||||
if label == 'msdos' and re.search('boot', p_d.Partition.dict[dev]['partition'][partition]['flags']):
|
||||
for p in p_d.sort_partitions(p_d.Partition.dict,dev,'partition'):
|
||||
if p != partition and re.search('boot', p_d.Partition.dict[dev]['partition'][p]['flags']):
|
||||
if p_d.Partition.dict[dev]['partition'][p]['flags'] == 'boot':
|
||||
p_d.Partition.dict[dev]['partition'][p]['flags'] = ''
|
||||
else:
|
||||
p_d.Partition.dict[dev]['partition'][p]['flags'] = \
|
||||
p_d.Partition.dict[dev]['partition'][p]['flags'].split(',')[1].strip()
|
||||
|
||||
|
||||
def del_msdos_partition(partition,dev):
|
||||
bb3 = ButtonBar(screen, (("Cancel", "cancel"), ("Delete", "delete")))
|
||||
@@ -447,8 +452,8 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['start'] = p_start
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['end'] = p_end
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['size'] = p_size
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(p_num-del_free_count)]['flags'] = ''
|
||||
|
||||
list_partition_all_sorted = p_d.sort_partitions(p_d.Partition.dict, dev, "all")
|
||||
for p in list_partition_all_sorted:
|
||||
@@ -634,8 +639,8 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num)]['flags'] = ''
|
||||
|
||||
else:
|
||||
free_num_max = 1
|
||||
@@ -747,8 +752,8 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ''
|
||||
else:
|
||||
p_d.Partition.dict[dev]['partition'][pre_partition]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition'][pre_partition]['size'] = \
|
||||
@@ -834,8 +839,8 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ''
|
||||
|
||||
#for p in p_d.sort_partitions(p_d.Partition.dict, dev, "partition"):
|
||||
# p_num = p_d.Partition.dict[dev]['partition'][p]['num']
|
||||
@@ -883,9 +888,9 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['size']\
|
||||
= partition_size
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['type']\
|
||||
= ' '
|
||||
= ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['flags']\
|
||||
= ' '
|
||||
= ''
|
||||
|
||||
elif not locals().has_key('pre_partition') and locals().has_key('next_partition'):
|
||||
if re.search('free', next_partition):
|
||||
@@ -919,8 +924,8 @@ def del_msdos_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['flags'] = ''
|
||||
|
||||
else:
|
||||
p_d.delete_all_partitions(p_d.Partition.dict, dev)
|
||||
@@ -1028,8 +1033,8 @@ def del_gpt_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition'] ['free '+str(free_num_mid+1)]['flags'] = ''
|
||||
|
||||
elif locals().has_key('pre_partition') and not locals().has_key('next_partition'):
|
||||
if re.search('free', pre_partition):
|
||||
@@ -1054,9 +1059,9 @@ def del_gpt_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['size']\
|
||||
= partition_size
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['type']\
|
||||
= ' '
|
||||
= ''
|
||||
p_d.Partition.dict[dev]['partition']['free '+str(free_num_max+1)]['flags']\
|
||||
= ' '
|
||||
= ''
|
||||
|
||||
elif not locals().has_key('pre_partition') and locals().has_key('next_partition'):
|
||||
if re.search('free', next_partition):
|
||||
@@ -1090,96 +1095,99 @@ def del_gpt_partition(partition,dev):
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['start'] = partition_start
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['end'] = partition_end
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['size'] = partition_size
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['type'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['flags'] = ' '
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['type'] = ''
|
||||
p_d.Partition.dict[dev]['partition']['free 1']['flags'] = ''
|
||||
|
||||
else:
|
||||
p_d.delete_all_partitions(p_d.Partition.dict, dev)
|
||||
|
||||
p_d.Partition.init_from_os()
|
||||
def main():
|
||||
global screen
|
||||
screen = SnackScreen()
|
||||
screen.drawRootText(0, 0, "Welcome to Rocky Security OS")
|
||||
screen.pushHelpLine( ("<Tab>/<Alt-Tab> between elments | <Space> selects | <F11> Cancel | <F12> OK | <ESC> Quit"))
|
||||
|
||||
while(1):
|
||||
global ret
|
||||
showPartitionWindow()
|
||||
if bb.buttonPressed(res) == "cancel":
|
||||
ret = 1
|
||||
break
|
||||
if bb.buttonPressed(res) == "ok":
|
||||
ret = 0
|
||||
break
|
||||
if bb.buttonPressed(res) == "quit":
|
||||
screen.finish()
|
||||
sys.exit(-1)
|
||||
# assign label(msdos or gpt) of dev
|
||||
if re.search("dev:", clb.current()) and bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[1]
|
||||
dev_size = clb.current().split(":")[2]
|
||||
rb = RadioBar(screen, (("gpt", "gpt", 0),("msdos", "msdos", 1)))
|
||||
bb1 = ButtonBar(screen, (("Cancel", "cancel"), ("OK", "ok")))
|
||||
g = GridForm(screen, "Partition table", 1, 4)
|
||||
g.add(TextboxReflowed(25, 'Warning! A new partition table will be created on "%s" and the data on it will be cleared.' \
|
||||
%(dev)), 0, 0)
|
||||
g.add(Label(""),0,1)
|
||||
g.add(rb,0,2,(0,0,0,1))
|
||||
g.add(bb1, 0, 3)
|
||||
res1 = g.runOnce()
|
||||
if bb1.buttonPressed(res1) == "ok":
|
||||
label = rb.getSelection()
|
||||
p_d.Partition.dict[dev]['partition_table'] = label
|
||||
p_d.delete_all_partitions(p_d.Partition.dict, dev)
|
||||
|
||||
while(1):
|
||||
global ret
|
||||
showPartitionWindow()
|
||||
if bb.buttonPressed(res) == "cancel":
|
||||
ret = 1
|
||||
break
|
||||
if bb.buttonPressed(res) == "ok":
|
||||
ret = 0
|
||||
break
|
||||
# assign label(msdos or gpt) of dev
|
||||
if re.search("dev:", clb.current()) and bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[1]
|
||||
dev_size = clb.current().split(":")[2]
|
||||
rb = RadioBar(screen, (("gpt", "gpt", 0),("msdos", "msdos", 1)))
|
||||
bb1 = ButtonBar(screen, (("Cancel", "cancel"), ("OK", "ok")))
|
||||
g = GridForm(screen, "Partition table", 1, 4)
|
||||
g.add(TextboxReflowed(25, 'Warning! A new partition table will be created on "%s" and the data on it will be cleared.' \
|
||||
%(dev)), 0, 0)
|
||||
g.add(Label(""),0,1)
|
||||
g.add(rb,0,2,(0,0,0,1))
|
||||
g.add(bb1, 0, 3)
|
||||
res1 = g.runOnce()
|
||||
if bb1.buttonPressed(res1) == "ok":
|
||||
label = rb.getSelection()
|
||||
p_d.Partition.dict[dev]['partition_table'] = label
|
||||
p_d.delete_all_partitions(p_d.Partition.dict, dev)
|
||||
|
||||
# add partition when dev's label is msdos
|
||||
elif re.search("partition:free", clb.current()) and \
|
||||
clb.current().split(':')[6] == 'msdos'and \
|
||||
bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[2]
|
||||
dev_name = dev.split("/dev/")[1]
|
||||
free_space_start = clb.current().split(":")[4]
|
||||
free_space_end = clb.current().split(":")[5]
|
||||
free_space_size = clb.current().split(":")[3]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
(count_primary, count_extended) = count_primary_extended(dev)
|
||||
# add logical partition when an extended partition exists
|
||||
if re.search('extended', str(p_d.Partition.dict[dev])):
|
||||
(extended_start, extended_end) = get_extended_start_end(dev)
|
||||
if int(filter(str.isdigit,free_space_start)) >= int(filter(str.isdigit,extended_start)) \
|
||||
and int(filter(str.isdigit,free_space_end)) <= int(filter(str.isdigit,extended_end)):
|
||||
ptype = 'logical'
|
||||
add_partition(ptype, 'extended', 'msdos')
|
||||
elif int(filter(str.isdigit,free_space_start)) >= int(filter(str.isdigit,extended_end)):
|
||||
show_error("Bad partition scheme ! This free space can't be used any more !")
|
||||
else:
|
||||
if count_primary == 3:
|
||||
show_error('You can not add new primary or extended partition any more !')
|
||||
else:
|
||||
ptype = 'primary'
|
||||
add_partition(ptype, 'extended', 'msdos')
|
||||
else:
|
||||
if count_primary == 4:
|
||||
show_error("You can't add partitions any more !")
|
||||
else:
|
||||
add_partition(ptype='', extended='', label='msdos')
|
||||
elif re.search("partition:free", clb.current()) and \
|
||||
clb.current().split(':')[6] == 'gpt'and \
|
||||
bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[2]
|
||||
free_space_start = clb.current().split(":")[4]
|
||||
free_space_end = clb.current().split(":")[5]
|
||||
free_space_size = clb.current().split(":")[3]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
add_partition(ptype='primary', extended='', label='gpt')
|
||||
elif re.search("partition:free", clb.current()) == None and \
|
||||
re.search("dev:", clb.current()) == None and \
|
||||
bb.buttonPressed(res) == "delete":
|
||||
msdos_or_gpt = clb.current().split(':')[6]
|
||||
dev = clb.current().split(":")[2]
|
||||
partition = clb.current().split(":")[1]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
if msdos_or_gpt == 'msdos':
|
||||
del_msdos_partition(partition, dev)
|
||||
elif msdos_or_gpt == 'gpt':
|
||||
del_gpt_partition(partition, dev)
|
||||
|
||||
|
||||
|
||||
screen.finish()
|
||||
#p_d.pretty(p_d.Partition.dict)
|
||||
p_d.write_to_xml_file()
|
||||
# add partition when dev's label is msdos
|
||||
elif re.search("partition:free", clb.current()) and \
|
||||
clb.current().split(':')[6] == 'msdos'and \
|
||||
bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[2]
|
||||
dev_name = dev.split("/dev/")[1]
|
||||
free_space_start = clb.current().split(":")[4]
|
||||
free_space_end = clb.current().split(":")[5]
|
||||
free_space_size = clb.current().split(":")[3]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
(count_primary, count_extended) = count_primary_extended(dev)
|
||||
# add logical partition when an extended partition exists
|
||||
if re.search('extended', str(p_d.Partition.dict[dev])):
|
||||
(extended_start, extended_end) = get_extended_start_end(dev)
|
||||
if int(filter(str.isdigit,free_space_start)) >= int(filter(str.isdigit,extended_start)) \
|
||||
and int(filter(str.isdigit,free_space_end)) <= int(filter(str.isdigit,extended_end)):
|
||||
ptype = 'logical'
|
||||
add_partition(ptype, 'extended', 'msdos')
|
||||
elif int(filter(str.isdigit,free_space_start)) >= int(filter(str.isdigit,extended_end)):
|
||||
show_error("Bad partition scheme ! This free space can't be used any more !")
|
||||
else:
|
||||
if count_primary == 3:
|
||||
show_error('You can not add new primary or extended partition any more !')
|
||||
else:
|
||||
ptype = 'primary'
|
||||
add_partition(ptype, 'extended', 'msdos')
|
||||
else:
|
||||
if count_primary == 4:
|
||||
show_error("You can't add partitions any more !")
|
||||
else:
|
||||
add_partition(ptype='', extended='', label='msdos')
|
||||
elif re.search("partition:free", clb.current()) and \
|
||||
clb.current().split(':')[6] == 'gpt'and \
|
||||
bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[2]
|
||||
free_space_start = clb.current().split(":")[4]
|
||||
free_space_end = clb.current().split(":")[5]
|
||||
free_space_size = clb.current().split(":")[3]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
add_partition(ptype='primary', extended='', label='gpt')
|
||||
elif re.search("partition:free", clb.current()) == None and \
|
||||
re.search("dev:", clb.current()) == None and \
|
||||
bb.buttonPressed(res) == "delete":
|
||||
msdos_or_gpt = clb.current().split(':')[6]
|
||||
dev = clb.current().split(":")[2]
|
||||
partition = clb.current().split(":")[1]
|
||||
pre_partition_name = clb.current().split(':')[8]
|
||||
if msdos_or_gpt == 'msdos':
|
||||
del_msdos_partition(partition, dev)
|
||||
elif msdos_or_gpt == 'gpt':
|
||||
del_gpt_partition(partition, dev)
|
||||
|
||||
screen.finish()
|
||||
return ret
|
||||
|
||||
@@ -143,20 +143,20 @@ class Partition:
|
||||
if m_p.match(str(message)):
|
||||
Partition(dev, # device name
|
||||
disk_size, # disk size
|
||||
' ', # partition_table
|
||||
'', # partition_table
|
||||
'yes', # disk from os
|
||||
' ', # partition sequence number
|
||||
' ', # partition
|
||||
' ', # num
|
||||
' ', # start
|
||||
' ', # end
|
||||
' ', # size
|
||||
' ', # type
|
||||
' ', # file system
|
||||
' ', # flags
|
||||
'', # partition sequence number
|
||||
'', # partition
|
||||
'', # num
|
||||
'', # start
|
||||
'', # end
|
||||
'', # size
|
||||
'', # type
|
||||
'', # file system
|
||||
'', # flags
|
||||
'yes', # partition from os
|
||||
' ', # whether format
|
||||
' ' # mount point
|
||||
'', # whether format
|
||||
'' # mount point
|
||||
)
|
||||
|
||||
continue
|
||||
@@ -235,8 +235,8 @@ type_name:%s, fs: %s, flags: %s" %(sn, num, partition, start, end, size, \
|
||||
fs, # file system
|
||||
flags, # flags
|
||||
'yes', # partition from os
|
||||
' ', # whether format
|
||||
' ' # mount point
|
||||
'', # whether format
|
||||
'' # mount point
|
||||
)
|
||||
|
||||
''' next partition '''
|
||||
@@ -378,12 +378,13 @@ def pretty(d, indent=0):
|
||||
print '\t' * (indent+1) + str(value)
|
||||
|
||||
def delete_all_partitions(d, k):
|
||||
d[k]['from_os'] = 'no'
|
||||
for key in d[k]['partition'].keys():
|
||||
d[k]['partition'].pop(key, None)
|
||||
|
||||
_device = _ped.device_get(k)
|
||||
_disk = _ped.Disk(_device)
|
||||
'''find the end !meta parititon end as disks end '''
|
||||
'''find the end !meta partition end as disks end '''
|
||||
_part = _disk.next_partition()
|
||||
while _part:
|
||||
if _part.type & 8:
|
||||
|
||||
@@ -326,6 +326,8 @@
|
||||
|
||||
<package name='kernel-header'/>
|
||||
|
||||
<package name='kernel-img'/>
|
||||
|
||||
<package name='kernel_source'/>
|
||||
|
||||
<package name='killproc'/>
|
||||
@@ -856,6 +858,7 @@
|
||||
<including install='optional' package='jfsutils'/>
|
||||
<including install='mandatory' package='kbd'/>
|
||||
<including install='mandatory' package='kernel-header'/>
|
||||
<including install='mandatory' package='kernel-img'/>
|
||||
<including install='mandatory' package='killproc'/>
|
||||
<including install='mandatory' package='less'/>
|
||||
<including install='optional' package='libaio'/>
|
||||
|
||||
@@ -1844,6 +1844,7 @@
|
||||
</runtime>
|
||||
</package>
|
||||
<package name='kernel-header'/>
|
||||
<package name='kernel-img'/>
|
||||
<package name='kernel_source'/>
|
||||
<package name='killproc'>
|
||||
<runtime>
|
||||
|
||||
Reference in New Issue
Block a user