dettus
Bicycle User
Ich habe gerade ein kleines Script gebastelt, welches die Abhaengigkeiten aus den OpenBSD ports extrahiert und als JSON speichert.
Das wuerde ich gerne mit Euch teilen
Das wuerde ich gerne mit Euch teilen
Python:
#!/usr/bin/env python3 -i
import os
import shutil
import pickle
import json
PORTS_ROOT="/usr/ports/"
ports_makefiles_dir=[]
for (dirpath,dirnames,filenames) in os.walk(PORTS_ROOT):
if filenames.count("Makefile")==1 and dirpath.find("pobj")==-1:
d=dirpath.replace(PORTS_ROOT,"")
ports_makefiles_dir.append(d)
print("Number of ports found: \x1b[1;36m"+str(len(ports_makefiles_dir))+"\x1b[0m")
cnt=0
lib_depends={}
build_depends={}
run_depends={}
for p in ports_makefiles_dir:
cnt=cnt+1
print("Processing \x1b[1;36m"+str(cnt)+"/"+str(len(ports_makefiles_dir))+"\x1b[0m")
lines=os.popen("cd "+PORTS_ROOT+" ; make -p -f "+p+"/Makefile").read().split("\n")
for l in lines:
tmp=l.split("=")
if len(tmp)==2:
key=tmp[0].replace(" ","")
value=tmp[1].split(" ")
if value.count(""):
value.remove("")
if key=="BUILD_DEPENDS":
build_depends[p]=value
if key=="LIB_DEPENDS":
lib_depends[p]=value
if key=="RUN_DEPENDS":
run_depends[p]=value
handle={
"ports_makefiles_dir":ports_makefiles_dir,
"build_depends":build_depends,
"lib_depends":lib_depends,
"run_depends":run_depends
}
with open("saved_handle.pkl","wb") as f:
pickle.dump(handle,f)
with open("saved_handle.json","w") as f:
json.dump(handle,f)