diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2011-07-21 21:53:40 +0200 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2011-07-21 21:53:40 +0200 |
commit | 662df0bb4a4629c1b0d99b8dd114520b1e231d7a (patch) | |
tree | 114f763ea701e922d33b4242c64f7f702b14b293 | |
parent | More work on autotools (diff) | |
download | ebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.tar.gz ebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.tar.bz2 ebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.zip |
Added pfl support! And basic automake support.
-rw-r--r-- | filetypes/autoconf.py | 12 | ||||
-rw-r--r-- | filetypes/automake.py | 40 | ||||
-rw-r--r-- | linkdeps.py | 43 |
3 files changed, 83 insertions, 12 deletions
diff --git a/filetypes/autoconf.py b/filetypes/autoconf.py index 98555ce..9405e24 100644 --- a/filetypes/autoconf.py +++ b/filetypes/autoconf.py @@ -364,7 +364,7 @@ def output(inputlst): if item[0] == "AC_ARG_ENABLE": name = convnames(item[1][0]) if len(item[1]) == 2: - variables["enable_" + name] = [[],[]] + variables["enable_" + name] = {"AC_ARG_ENABLE" : ""} elif len(item[1]) == 3: variables["enable_" + name] = [item[1][2],[]] else: @@ -373,10 +373,10 @@ def output(inputlst): #remember to convert chars in the name of "item[1]" that is not #alfanumeric char to underscores _ - if item[0] == "AC_ARG_WITH": + elif item[0] == "AC_ARG_WITH": name = convnames(item[1][0]) if len(item[1]) == 2: - variables["with_" + name] = [[],[]] + variables["with_" + name] = {"AC_ARG_WITH" : ""} elif len(item[1]) == 3: variables["with_" + name] = [item[1][2],[]] else: @@ -386,14 +386,12 @@ def output(inputlst): for pattern in item[0][1]: if variable in pattern: ifs += [parseif(item[0][1])] - elif "=" in item: - #print(item) - b = 0 + print(item) #for variable in variables: #print(variable) #print(variables[variable]) - print(ifs) + #print(ifs) import re def convnames(string): #strip none alfanumeric chars and replace them with "_" diff --git a/filetypes/automake.py b/filetypes/automake.py index 1eaa765..f7e6a91 100644 --- a/filetypes/automake.py +++ b/filetypes/automake.py @@ -1,6 +1,7 @@ from ply import lex from ply import yacc import glob +import os def scanamfile(amfile): """Scan automake (.am) file @@ -249,9 +250,40 @@ def scanamfile(amfile): yacc.yacc() variables = yacc.parse(amfile) - print(variables) + return variables -file="/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/Makefile.am" -with open(file, encoding="utf-8", errors="replace") as inputfile: - scanamfile(inputfile.read()) +def scan(amfile): + curdir = os.path.split(amfile)[0] + "/" + amlist = scanamfile(openfile(amfile)) + print(amfile) + return sources_to_scan(amlist,curdir) + +def sources_to_scan(amlist,curdir): + sources = [] + #perhaps use set() here to eliminate the possibilty of duplicates? + for variable in amlist[0]: + if variable.split("_")[-1] == "SOURCES": + sources += amlist[0][variable] + + if "SUBDIRS" in amlist[0]: + for dir in amlist[0]["SUBDIRS"]: + sources += scan(curdir + dir + "/Makefile.am") + + for lst in amlist[1]: + if lst[0] == "SUBDIRS": + for dir in lst[1]: + sources += scan(curdir + dir + "/Makefile.am") + + for ifstatement in amlist[2]: + #don't care about if statements ATM! + sources += sources_to_scan(amlist[2][ifstatement],curdir) + + return sources + +def openfile(ofile): + with open(ofile, encoding="utf-8", errors="replace") as inputfile: + return inputfile.read() + +scan("/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am") + diff --git a/linkdeps.py b/linkdeps.py index ec8766a..c89869e 100644 --- a/linkdeps.py +++ b/linkdeps.py @@ -1,5 +1,6 @@ import os from subprocess import getstatusoutput +from urllib.request import urlopen def deptopackage(dep,addpaths): """Converts supplied deps with additional include paths to portage packages @@ -31,7 +32,47 @@ def deptopackage(dep,addpaths): print(package) if not package: - print("not matching package found withing the include paths!") + print("not matching package found within the include paths!") package = ["dummy"] return package +def pfltopackage(dep,addpaths): + """This uses the online ply database to guess packages + + """ + + incpaths = ["/usr/include", "/usr/local/include"] + incpaths += addpaths + + url_lines = [] + depname = os.path.split(dep)[1] + matching_packages = set() + + url = urlopen("http://www.portagefilelist.de/index.php/Special:PFLQuery2?file=" + + depname + "&searchfile=lookup&lookup=file&txt") + + for line in url: + url_lines += [line.decode("utf-8").split()] + + #First line does not contain any useful information, skip it + url_lines = url_lines[1:] + #structure of lines: [portage_category, package, path, file, misc, version] + + for line in url_lines: + #check if path is correct + for path in incpaths: + if line[2] + line[3] == path + dep: + matching_packages.add(line[0] + "/" + line[1]) + + if len(matching_packages) > 1: + print("More than one matching package for dep found!\nPicking the last one...") + + if not matching_packages: + print("not matching package found within the include paths!") + print("file not found was:" + dep) + print("a dummy dep will be placed in the ebuild, fix it!") + package = ["dummy"] + + print([matching_packages.pop()]) + +#pfltopackage("ncurses.h",[]) |