fix localUSE und add inclides overlays

pull/1/head
serkus01 3 years ago
parent 32fa5b4a43
commit b6c09dff2c

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -48,4 +48,4 @@ vim
nano nano
vscode vscode
jedit jedit
gedit gedit

@ -60,7 +60,7 @@ def create_db():
overlays = get_list_overlays() overlays = get_list_overlays()
recovers = ScanRecoverFile() recovers = ScanRecoverFile()
pkg_list ={} pkg_list ={}
listUses= dict(LocalUSE=get_local_USE(), GlobalUSE=get_global_USE()) listUses= dict(LocalUSE=get_local_USE(), GlobalUSE=get_global_USE()) #[0] LocalUSE=get_local_USE(),
InstallPkgs= sort_install_pkg() InstallPkgs= sort_install_pkg()
portage_list ={} portage_list ={}
port_dir =["/var/db/repos", "/usr/portage"] port_dir =["/var/db/repos", "/usr/portage"]
@ -86,8 +86,8 @@ def create_db():
print(e) print(e)
if not pkg_name[:-1] in all_pkgs: if not pkg_name[:-1] in all_pkgs:
portage_list[pkg_name] = search(pkg_name) #portage_list[pkg_name] = search(pkg_name)
print #print
#print(str(d.split("/")[-2] +"/" + d.split("/")[-1] +"\n")) #print(str(d.split("/")[-2] +"/" + d.split("/")[-1] +"\n"))
if str(d.split("/")[-2] +"/" + d.split("/")[-1]) in AliaseCategory: if str(d.split("/")[-2] +"/" + d.split("/")[-1]) in AliaseCategory:
@ -99,15 +99,16 @@ def create_db():
if d.split("/")[-2] not in pkg_list.keys(): if d.split("/")[-2] not in pkg_list.keys():
pkg_list[str(d.split("/")[-2])] = [] pkg_list[str(d.split("/")[-2])] = []
pkg_list[d.split("/")[-2]].append(d.split('/')[-1]) pkg_list[d.split("/")[-2]].append(d.split('/')[-1])
if search(str(d.split("/")[-2]))['Name'] != 'Package is not Found': #if search(str(d.split("/")[-2]))['Name'] != 'Package is not Found':
#portage_list[str(d.split("/")[-2] +"/" + d.split("/")[-1])] = search(str(d.split("/")[-2])) #portage_list[str(d.split("/")[-2] +"/" + d.split("/")[-1])] = search(str(d.split("/")[-2]))
print([d.split("/")[-2]]) # print([d.split("/")[-2]])
else: else:
if d.split('/')[-1] not in pkg_list[d.split('/')[-2]]: if d.split('/')[-1] not in pkg_list[d.split('/')[-2]]:
pkg_list[d.split("/")[-2]].append(d.split('/')[-1]) pkg_list[d.split("/")[-2]].append(d.split('/')[-1])
#print([d.split('/')[-1]]) #print([d.split('/')[-1]])
#"all_pkgs": all_pkgs, [0] #"all_pkgs": all_pkgs, [0]
fn.write(json.dumps({"all_pkgs": all_pkgs, "Catalog": pkg_list, "aliases": AliaseCategory, "overlays": overlays, "recovers": recovers, "usesDecription":listUses, "InstallPkgs":InstallPkgs })) fn.write(json.dumps({ "all_pkgs": all_pkgs, "Catalog": pkg_list,"overlays": overlays, "aliases": AliaseCategory, "recovers": recovers, "usesDecription":listUses, "InstallPkgs":InstallPkgs }))
#json.length "InstallPkgs":InstallPkgs
print(len(pkg_list)) print(len(pkg_list))
""" """
with open('./portage.json', 'w') as p: with open('./portage.json', 'w') as p:

@ -27,9 +27,9 @@ def get_local_USE():
if line.startswith('#'): if line.startswith('#'):
pass pass
else: else:
try: try:
ListUSE[line.split(':')[1] and line.split(' -')[0]] = str(line.replace(line.split(':')[1], "")) ListUSE[line.split(':')[1].split(' -')[0]] = str(line.replace(line.split(':')[0] + ":", ""))
except Exception (e): except Exception as e:
print(str(e)) print(str(e))
print(ListUSE) print(ListUSE)
return ListUSE return ListUSE

@ -38,6 +38,11 @@ def get_list_overlays():
description = "" description = ""
homepage = "" homepage = ""
feed ="" feed =""
for d, dirs, files in os.walk('/var/db/repos'):
if(d == "/var/db/repos"):
inc = dirs
else:
break
for child in root.findall('repo'): for child in root.findall('repo'):
name = child.find('name').text name = child.find('name').text
try: try:
@ -54,7 +59,7 @@ def get_list_overlays():
except AttributeError: except AttributeError:
feed = "У overlay нет ссылки и на дерево" feed = "У overlay нет ссылки и на дерево"
overlay = dict(name=name, description=description, homepage=homepage, feed=feed) overlay =dict(name=name, description=description, homepage=homepage, feed=feed)
overlays.append(overlay) overlays.append(overlay)
@ -64,7 +69,7 @@ def get_list_overlays():
f.write(json.dumps({"repositories": overlays})) f.write(json.dumps({"repositories": overlays}))
#f.close() #f.close()
return overlays return dict(all=overlays, include=inc)
def xml_element_to_dict(elem): def xml_element_to_dict(elem):
@ -104,49 +109,53 @@ def load_config():
return conf return conf
#SORT IN INTALL PAKAGES #SORT IN INTALL PAKAGES
#'/var/db/pkg/' #''
def sort_install_pkg(): def sort_install_pkg():
pkg =scan_config_portage() #pkg =scan_config_portage()
INSTALL = {} INSTALL = {}
path = '/var/db/pkg/' pkg_name =""
for d, dirs, files in os.walk(path): path = '/var/db/pkg/'
for f in files: for d, dirs, files in os.walk(path):
if f.endswith('.ebuild'): for f in files:
if f.endswith('.ebuild'):
try: try:
#ver=int(f.replace('.ebuild', '').split('-')[-1][0]) #ver=int(f.replace('.ebuild', '').split('-')[-1][0])
for pn in f.replace('.ebuild', '').split('-')[:-1]: for pn in f.replace('.ebuild', '').split('-')[:-1]:
pkg_name = pkg_name + pn + "-" pkg_name = pkg_name + pn + "-"
except TypeError: except TypeError:
for pn in f.replace('.ebuild', '').split('-')[:-2]: for pn in f.replace('.ebuild', '').split('-')[:-2]:
pkg_name = pkg_name + pn + "-" pkg_name = pkg_name + pn + "-"
except Exception as e: except Exception as e:
print(e) print(e)
print(pkg_name)
if d.replace(path, "").split('/')[0] not in INSTALL:
INSTALL[d.replace(path, "").split('/')[0]] =[]
INSTALL[d.replace(path, "").split('/')[0]].append(f.replace(".ebuild", "") )
INSTALL[d.replace(path,
"").split('/')[0]].append(f.replace(".ebuild", "")) #dict(name=pkg_name[:-1],ver=f.replace(pkg_name, "")
if d.replace(path, "").split('/')[0] not in INSTALL: #print(str(len(INSTALL)))
INSTALL[d.replace(path, "").split('/')[0]] =[] #return json.dumps({'install_pkgs':INSTALL})
#INSTALL[d.replace(path, "").split('/')[0]].append(dict("name"=pkg_name, "vers"=f.replace(pkg_name) )) return INSTALL
INSTALL[d.replace(path, "").split('/')[0]].append(dict(name=pkg_name, ver=f.replace(pkg_name) ))
#print(str(len(INSTALL)))
#return json.dumps({'install_pkgs':INSTALL})
return INSTALL
def scan_config_portage(): def scan_config_portage():
dirs_root =["/var/db/repos", "/usr/portage"] dirs_root =["/var/db/repos", "/usr/portage"]
config = {} config = {}
i = 0 i = 0
dr = {} dr = {}
data = {} data = {}
pf={} pf={}
for dir_root in dirs_root: for dir_root in dirs_root:
for d, dirs, files in os.walk(dir_root): for d, dirs, files in os.walk(dir_root):
print(str(d)) print(str(d))
i=i+1 i=i+1
for fl in files: for fl in files:
with open(d + "/" +fl) as f: with open(d + "/" + fl) as f:
pf[str(d.split('/')[-1]) + "/"+ fl]= f.read().split('\n') pf[str(d.split('/')[-1]) + "/"+ fl]= f.read().split('\n')
str(d.split('/')[-1]) str(d.split('/')[-1])
#print(dr) #print(dr)
#config = {'portage': pf} #config = {'portage': pf}
#print("config:\t" + str(config)) #print("config:\t" + str(config))
#return config #return config

Loading…
Cancel
Save