aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rwxr-xr-xcli.py14
-rw-r--r--ebuildgen.py93
-rw-r--r--filetypes/ctypefiles.py2
-rw-r--r--scanfiles.py8
5 files changed, 111 insertions, 7 deletions
diff --git a/TODO b/TODO
index 0db9fc7..fe08631 100644
--- a/TODO
+++ b/TODO
@@ -8,3 +8,4 @@ Clean up the code so that stuff is more organized
Perhaps multithread some stuff so the rest of the program doesn't have to wait for the parser to finish
Handle deptopackage conversion where the dep is defined at root lever IE dep = /usr/map/file
Handle ../map/%.type : %.type2 makefile targets
+Handle zip,tar for unpacking
diff --git a/cli.py b/cli.py
index 8880550..732680d 100755
--- a/cli.py
+++ b/cli.py
@@ -3,6 +3,7 @@
import argparse
import scanfiles
import linkdeps
+import ebuildgen
parser = argparse.ArgumentParser(
description="Scan a dir for files and output includes",
@@ -18,6 +19,8 @@ parser.add_argument("-l", "--linc", action="store_true",
help="print local includes")
parser.add_argument("-d", "--ifdef", action="store_true",
help="print includes the depends on ifdefs")
+parser.add_argument("-q", "--quiet", action="store_true",
+ help="don't print anything") #this needs work...
args = parser.parse_args()
@@ -26,12 +29,15 @@ args = parser.parse_args()
#inclst is a list of includes. First in it is global then local.
-inclst = scanfiles.scanproject(args.dir,"makefile")
-packages = []
+(inclst,binaries,targets) = scanfiles.scanproject(args.dir,"makefile")
+packages = set()
+print(binaries)
for dep in inclst[0]:
- packages += linkdeps.deptopackage(dep)
+ packages.add(linkdeps.deptopackage(dep)[0])
-if args.ginc == args.linc == args.ifdef == False:
+ebuildgen.genebuild([],packages,"svn","http://doneyet.googlecode.com/svn/trunk",targets,binaries)
+
+if args.ginc == args.linc == args.ifdef == args.quiet == False:
print(inclst)
print(packages)
diff --git a/ebuildgen.py b/ebuildgen.py
new file mode 100644
index 0000000..26a9d87
--- /dev/null
+++ b/ebuildgen.py
@@ -0,0 +1,93 @@
+from time import strftime
+
+eclass = {
+ "git" : "git",
+ "svn" : "subversion",
+ "hg" : "mercurial",
+ }
+
+def genebuild(iuse,deps,dltype,adress,targets,binaries):
+ installmethod = guessinstall(targets,binaries)
+ outstr = outputebuild(iuse,deps,dltype,adress,installmethod)
+ f = open("/tmp/workfile.ebuild","w")
+ f.write(outstr)
+ f.close()
+
+def guessinstall(targets,binaries):
+ targetlst = []
+ returnlst = []
+ for target in targets:
+ targetlst.append(target[0])
+
+ if "install" in targetlst:
+ returnlst = [' emake DESTDIR="${D}" install || die "emake install failed"']
+ else:
+ for binary in binaries:
+ returnlst += [' dobin ' + binary + ' || die "bin install failed"']
+
+ return returnlst
+
+def outputebuild(iuse,deps,dltype,adress,installmethod):
+ text = [
+ '# Copyright 1999-' + strftime("%Y") + ' Gentoo Foundation',
+ '# Distributed under the terms of the GNU General Public License v2',
+ '# $Header: $',
+ ''
+ ]
+ inheritstr = 'inherit ' + eclass[dltype]
+ text.append(inheritstr)
+
+ text += [
+ '',
+ 'EAPI=3',
+ '',
+ 'DESCRIPTION=""',
+ 'HOMEPAGE=""'
+ ]
+ if dltype == "www":
+ srcstr = 'SRC_URI="' + adress + '"'
+ else:
+ srcstr = 'E' + dltype.upper() + '_REPO_URI="' + adress + '"'
+ text.append(srcstr)
+
+ text += [
+ '',
+ 'LICENSE=""',
+ 'SLOT="0"',
+ 'KEYWORDS=""'
+ ]
+ iusestr = 'IUSE="'
+ for flag in iuse:
+ iusestr += (flag + " ")
+ iusestr += '"\n'
+
+ text.append(iusestr)
+
+ depstr = 'DEPEND="'
+ for dep in deps:
+ depstr += (dep + "\n\t")
+
+ depstr = depstr[:-2] + '"'
+ text.append(depstr)
+
+ text += [
+ 'RDEPEND="${DEPEND}"',
+ '',
+ 'src_compile() {',
+ ' emake || die "emake failed"',
+ '}'
+ ]
+
+ text += [
+ '',
+ 'src_install() {',
+ ]
+ text += installmethod
+
+ text += ['}']
+
+ outputstr = ""
+ for line in text:
+ outputstr += line + "\n"
+
+ return outputstr
diff --git a/filetypes/ctypefiles.py b/filetypes/ctypefiles.py
index ad62d44..efa4d7e 100644
--- a/filetypes/ctypefiles.py
+++ b/filetypes/ctypefiles.py
@@ -8,7 +8,7 @@ def scanincludes(string,inclst,curdir):
tokens = (
"GINCLUDE",
"LINCLUDE",
- "BUNDLEINC",
+ #"BUNDLEINC",
"IFDEF",
"ENDIF",
)
diff --git a/scanfiles.py b/scanfiles.py
index 081458f..f673e0f 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -16,6 +16,7 @@ def scandirfor(dir, filetypes):
def scanmakefiledeps(makefile):
curdir = os.path.split(makefile)[0] + "/"
makefile = openfile(makefile)
+ binaries = set() #the binaries that the .o file create
filestoscan = []
impfiles = [] #look for these files
targets = scanmakefile(makefile)
@@ -28,13 +29,15 @@ def scanmakefiledeps(makefile):
newdeps += target[1]
if ".o" in dep or dep in impfiles:
impfiles += target[1]
+ elif ".o" in target[1][0]:
+ binaries.add(target[0])
deps = newdeps
#impfiles.sort()
for impfile in impfiles:
filestoscan.append(curdir + impfile)
#print(filestoscan)
- return filestoscan
+ return filestoscan,binaries,targets
def scanfilelist(filelist):
global_hfiles = set()
@@ -56,7 +59,8 @@ def scanproject(dir,projecttype):
mfile = scandirfor(dir, filestolookfor)[0] #use first file found
print(mfile)
- return scanfilelist(scanmakefiledeps(mfile))
+ (scanlist,binaries,targets) = scanmakefiledeps(mfile)
+ return scanfilelist(scanlist),binaries,targets
def openfile(file):
try: