add function dependency
This commit is contained in:
@@ -41,7 +41,7 @@ def construct_depending():
|
||||
xml_dict = {}
|
||||
for n in xml_root.childNodes:
|
||||
if n.nodeType == n.ELEMENT_NODE and n.nodeName == 'package':
|
||||
xml_dict[n.attributes['name'].value] = n
|
||||
xml_dict[n.attributes['name'].value] = n
|
||||
Depending(n.attributes['name'].value)
|
||||
|
||||
for d in Depending.dict.values():
|
||||
@@ -61,7 +61,7 @@ def construct_depended():
|
||||
Depended(dep)
|
||||
Depended.dict[dep].depended_by.add(d.name)
|
||||
|
||||
def get_extra_depending():
|
||||
def get_extra_depending(pkg_list = []):
|
||||
l = []
|
||||
for g in ri_data.Group.dict.values():
|
||||
if g.install != 'no':
|
||||
@@ -71,6 +71,8 @@ def get_extra_depending():
|
||||
else:
|
||||
l.extend([ p[0] for p in g.optional ])
|
||||
|
||||
l = l + pkg_list
|
||||
|
||||
set1 = set(l)
|
||||
set2 = set(set1)
|
||||
|
||||
|
||||
100
interface/ri_func_dep.py
Normal file
100
interface/ri_func_dep.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import ri_data
|
||||
|
||||
class Pkg():
|
||||
pkg_list = []
|
||||
|
||||
@staticmethod
|
||||
def set_pkg_list ():
|
||||
for i in ri_data.Group.dict.values():
|
||||
if i.install != 'no':
|
||||
Pkg.pkg_list += i.mandatory
|
||||
if i.selection == 'all':
|
||||
Pkg.pkg_list += [ j[0] for j in i.optional ]
|
||||
else:
|
||||
Pkg.pkg_list += [ j[0] for j in i.optional if j[1] == 'yes' ]
|
||||
|
||||
class FsType():
|
||||
mp_fstype_list = []
|
||||
|
||||
@staticmethod
|
||||
def set_mp_fstype_list ():
|
||||
for fs in ri_data.MountPoint.list:
|
||||
FsType.mp_fstype_list.append(fs.filesystem)
|
||||
|
||||
class FunctionDepending:
|
||||
list = []
|
||||
def __init__(self, pkg):
|
||||
self.package = pkg
|
||||
FunctionDepending.list.append(self)
|
||||
|
||||
def check(self):
|
||||
return False
|
||||
|
||||
def error(self):
|
||||
return {}
|
||||
|
||||
|
||||
class FileSystem(FunctionDepending):
|
||||
mp_fstype_list = []
|
||||
def __init__(self, fs_type, fs_pkg):
|
||||
self.filesystem_type = fs_type
|
||||
FunctionDepending.__init__(self, fs_pkg)
|
||||
|
||||
def check(self):
|
||||
if self.filesystem_type in FsType.mp_fstype_list and self.package not in Pkg.pkg_list:
|
||||
return False
|
||||
return True
|
||||
|
||||
def error(self):
|
||||
mesg="format filesystem " + self.filesystem_type
|
||||
return {mesg:self.package}
|
||||
|
||||
class DHCP(FunctionDepending):
|
||||
def __init__(self):
|
||||
FunctionDepending.__init__(self, 'dhcpcd')
|
||||
|
||||
def check(self):
|
||||
if ri_data.Network.configuration == 'dynamic' and 'dhcpcd' not in Pkg.pkg_list:
|
||||
return False
|
||||
return True
|
||||
|
||||
def error(self):
|
||||
return {"dynamic configure network":"dhcpcd"}
|
||||
|
||||
class RAID(FunctionDepending):
|
||||
def __init__(self):
|
||||
FunctionDepending.__init__(self, 'mdadm')
|
||||
|
||||
def check(self):
|
||||
if 'mdadm' not in Pkg.pkg_list:
|
||||
for i in ri_data.Raid.list:
|
||||
if i.from_os == 'no':
|
||||
return False
|
||||
return True
|
||||
|
||||
def error(self):
|
||||
return {"make raid":"mdadm"}
|
||||
|
||||
def check_function_depending():
|
||||
|
||||
Pkg.set_pkg_list()
|
||||
FsType.set_mp_fstype_list()
|
||||
func_dep_dict = {}
|
||||
|
||||
FileSystem("xfs", "xfsprogs")
|
||||
FileSystem("jfs", "jfsutils")
|
||||
|
||||
DHCP()
|
||||
RAID()
|
||||
|
||||
for i in FunctionDepending.list:
|
||||
# if function depending package not in package list
|
||||
if not i.check():
|
||||
tmp = i.error()
|
||||
func_dep_dict.update(tmp)
|
||||
return func_dep_dict
|
||||
|
||||
#check_function_depending()
|
||||
|
||||
@@ -4,6 +4,7 @@ import ri_tk as display
|
||||
import ri_widget
|
||||
import ri_data
|
||||
import ri_dep
|
||||
import ri_func_dep
|
||||
|
||||
import re
|
||||
import copy
|
||||
@@ -193,13 +194,25 @@ def software_group_optional_quit():
|
||||
|
||||
def dependency_list_init(w=''):
|
||||
''' init function for list in dependency step '''
|
||||
func_dep_list = []
|
||||
f_dep_text = ["function dependency list"]
|
||||
func_dep_dict = ri_func_dep.check_function_depending()
|
||||
for key in func_dep_dict.keys():
|
||||
func_dep_list.append(func_dep_dict[key])
|
||||
f = [ k.ljust(30) + ': ' + func_dep_dict[k] for k in func_dep_dict.keys() ]
|
||||
|
||||
dep_text = ["package dependency list"]
|
||||
ri_dep.construct_depending()
|
||||
ri_dep.resolve_recursive_depending()
|
||||
ri_dep.construct_depended()
|
||||
dep_dict = ri_dep.get_extra_depending()
|
||||
|
||||
dep_dict = ri_dep.get_extra_depending(func_dep_list)
|
||||
l = [ k.ljust(20) + ': ' + ' '.join(dep_dict[k]) for k in dep_dict.keys()]
|
||||
|
||||
l = f_dep_text + f + dep_text + l
|
||||
display.var_dict['dependency.list'].set(value=tuple(l))
|
||||
|
||||
|
||||
def service_construct(w=''):
|
||||
''' construct service widget based on actual data
|
||||
w - Widget instance '''
|
||||
|
||||
Reference in New Issue
Block a user