* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-09 9:41 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-09 9:41 UTC (permalink / raw
To: gentoo-commits
commit: e3e320251e15bb4a574eb4e3201d375eb897166b
Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Sun Aug 7 19:52:46 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Sun Aug 7 19:52:46 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=e3e32025
Added automatic detection of the default incpaths!
---
linkdeps.py | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/linkdeps.py b/linkdeps.py
index edf9c7a..d498a88 100644
--- a/linkdeps.py
+++ b/linkdeps.py
@@ -13,13 +13,19 @@ def qfiletopackage(dep,addpaths):
"""
print(dep)
- incpaths = ["/usr/include", "/usr/local/include"]
+ (statuscode,outstr) = getstatusoutput("`gcc -print-prog-name=cc1` -v ^C")
+ #"`gcc -print-prog-name=cc1plus` -v" for cpp
+ outlst = outstr.split("\n")
+ incpaths = []
+ for item in outlst:
+ if item[:2] == " /":
+ incpaths += [item[1:]]
incpaths += addpaths
depname = os.path.split(dep)[1]
(statuscode,packagestr) = getstatusoutput("qfile -C " + depname)
if not statuscode == 0:
- package = pfltopackage(dep,addpaths)
+ package = pfltopackage(dep,incpaths)
else:
packagelst = packagestr.split()
@@ -35,7 +41,7 @@ def qfiletopackage(dep,addpaths):
print("more than one matching package where found!")
if not package:
- package = pfltopackage(dep,addpaths)
+ package = pfltopackage(dep,incpaths)
print(package)
return package
@@ -46,8 +52,7 @@ def pfltopackage(dep,addpaths):
"""
print(dep)
- incpaths = ["/usr/include", "/usr/local/include"]
- incpaths += addpaths
+ incpaths = addpaths
url_lines = []
depname = os.path.split(dep)[1]
@@ -80,4 +85,4 @@ def pfltopackage(dep,addpaths):
return [matching_packages.pop()]
-#pfltopackage("ncurses.h",[])
+#qfiletopackage("jack/ringbuffer.h",[])
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-09 9:41 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-09 9:41 UTC (permalink / raw
To: gentoo-commits
commit: 3c43da8b23e7037e02be445ee17b238b8e86bdfe
Author: root <root <AT> MonCaso <DOT> (none)>
AuthorDate: Thu Aug 4 21:19:52 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Thu Aug 4 21:19:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=3c43da8b
Added basic autotools support
---
cli.py | 25 +++++++++++++++++++------
ebuildgen.py | 21 +++++++++++++++++----
linkdeps.py | 41 +++++++++++++++++++++++------------------
scanfiles.py | 23 +++++++++++++++--------
4 files changed, 74 insertions(+), 36 deletions(-)
diff --git a/cli.py b/cli.py
index a3eece3..bab1089 100755
--- a/cli.py
+++ b/cli.py
@@ -52,17 +52,30 @@ else:
srcdir = args.dir
dltype = "www"
-(inclst,binaries,incpaths,targets) = scanfiles.scanproject(srcdir,"makefile")
-packages = set()
-print(binaries)
+(iuse,inclst,useargs) = scanfiles.scanproject(srcdir,"autotools")
+targets = [["install"]]
+binaries = []
+gpackages = set()
for dep in inclst[0]:
- packages.add(linkdeps.deptopackage(dep,incpaths)[0])
+ gpackages.add(linkdeps.deptopackage(dep,[])[0])
+#print(gpackages)
-ebuildgen.genebuild([],packages,dltype,args.dir,targets,binaries)
+usedeps = {}
+for use in useargs:
+ packages = set()
+ for dep in useargs[use][0]:
+ newpack = linkdeps.deptopackage(dep,[])[0]
+ if not newpack in gpackages:
+ packages.add(newpack)
+ usedeps[use] = packages
+
+#print(usedeps)
+#print(iuse)
+ebuildgen.genebuild(iuse,gpackages,usedeps,dltype,args.dir,targets,binaries)
if args.ginc == args.linc == args.ifdef == args.quiet == False:
print(inclst)
- print(packages)
+ print(gpackages)
if args.ginc:
print(inclst[0])
diff --git a/ebuildgen.py b/ebuildgen.py
index 609bedb..10586e6 100644
--- a/ebuildgen.py
+++ b/ebuildgen.py
@@ -9,7 +9,7 @@ eclass = {
arch = getstatusoutput("portageq envvar ARCH")[1]
-def genebuild(iuse,deps,dltype,adress,targets,binaries):
+def genebuild(iuse,deps,usedeps,dltype,adress,targets,binaries):
"""This function starts the ebuild generation.
You have to provide the following args in order:
@@ -22,7 +22,7 @@ def genebuild(iuse,deps,dltype,adress,targets,binaries):
"""
installmethod = guessinstall(targets,binaries)
- outstr = outputebuild(iuse,deps,dltype,adress,installmethod)
+ outstr = outputebuild(iuse,deps,usedeps,dltype,adress,installmethod)
f = open("/tmp/workfile.ebuild","w")
f.write(outstr)
f.close()
@@ -47,7 +47,7 @@ def guessinstall(targets,binaries):
return returnlst
-def outputebuild(iuse,deps,dltype,adress,installmethod):
+def outputebuild(iuse,deps,usedeps,dltype,adress,installmethod):
"""Used to generate the text for the ebuild to output
Generates text with the help of the supplied variables
@@ -83,7 +83,7 @@ def outputebuild(iuse,deps,dltype,adress,installmethod):
]
iusestr = 'IUSE="'
for flag in iuse:
- iusestr += (flag + " ")
+ iusestr += (flag.split("_")[1] + " ")
iusestr += '"\n'
text.append(iusestr)
@@ -92,6 +92,19 @@ def outputebuild(iuse,deps,dltype,adress,installmethod):
for dep in deps:
depstr += (dep + "\n\t")
+ for use in usedeps:
+ #check if packagelist is empty
+ if usedeps[use]:
+ if use[0] == "!":
+ depstr += "!" + use.split("_")[1] + "? ( "
+ else:
+ depstr += use.split("_")[1] + "? ( "
+
+ for dep in usedeps[use]:
+ depstr += dep +"\n\t\t"
+ depstr = depstr[:-3]
+ depstr += " )\n\t"
+
depstr = depstr[:-2] + '"'
text.append(depstr)
diff --git a/linkdeps.py b/linkdeps.py
index 7e81e2e..edf9c7a 100644
--- a/linkdeps.py
+++ b/linkdeps.py
@@ -3,6 +3,10 @@ from subprocess import getstatusoutput
from urllib.request import urlopen
def deptopackage(dep,addpaths):
+ #return pfltopackage(dep,addpaths)
+ return qfiletopackage(dep,addpaths)
+
+def qfiletopackage(dep,addpaths):
"""Converts supplied deps with additional include paths to portage packages
This uses qfile to quess which package certain files belongs to.
@@ -15,25 +19,25 @@ def deptopackage(dep,addpaths):
(statuscode,packagestr) = getstatusoutput("qfile -C " + depname)
if not statuscode == 0:
- print("something went wrong...") #have it print a more useful error!
- return
+ package = pfltopackage(dep,addpaths)
+
+ else:
+ packagelst = packagestr.split()
+ package = []
+ n = 0
+ for depfile in packagelst[1::2]:
+ for incpath in incpaths:
+ if depfile.strip("()") == (incpath + "/" + dep):
+ package.append(packagelst[n])
+ n += 2
- packagelst = packagestr.split()
- package = []
- n = 0
- for depfile in packagelst[1::2]:
- for incpath in incpaths:
- if depfile.strip("()") == (incpath + "/" + dep):
- package.append(packagelst[n])
- n += 2
+ if len(package) > 1:
+ print("more than one matching package where found!")
- if len(package) > 1:
- print("more than one matching package where found!")
+ if not package:
+ package = pfltopackage(dep,addpaths)
print(package)
- if not package:
- print("not matching package found within the include paths!")
- package = ["dummy"]
return package
def pfltopackage(dep,addpaths):
@@ -41,6 +45,7 @@ def pfltopackage(dep,addpaths):
"""
+ print(dep)
incpaths = ["/usr/include", "/usr/local/include"]
incpaths += addpaths
@@ -61,7 +66,7 @@ def pfltopackage(dep,addpaths):
for line in url_lines:
#check if path is correct
for path in incpaths:
- if line[2] + line[3] == path + dep:
+ if line[2] + "/" + line[3] == path + "/" + dep:
matching_packages.add(line[0] + "/" + line[1])
if len(matching_packages) > 1:
@@ -71,8 +76,8 @@ def pfltopackage(dep,addpaths):
print("no 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"]
+ matching_packages = ["dummy_for_" + dep]
- print([matching_packages.pop()])
+ return [matching_packages.pop()]
#pfltopackage("ncurses.h",[])
diff --git a/scanfiles.py b/scanfiles.py
index 584158b..b0cd7aa 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -111,8 +111,9 @@ def scanautotoolsdeps(acfile,amfile):
for usearg in useargs:
useargs[usearg] = scanfilelist(useargs[usearg],src_incflag)
- print(useargs)
- print(includes)
+ #print(useargs)
+ #print(includes)
+ return useflags,includes,useargs
def scanfilelist(filelist,src_incflag):
""" Scan files in filelist for #includes
@@ -143,14 +144,23 @@ def scanproject(dir,projecttype):
autotools? makefile?
"""
if projecttype == "guess":
- filestolookfor = ["Makefile","makefile"] #add more later
+ filestolookfor = ["Makefile","makefile",
+ "configure.ac","configure.in"] #add more later
elif projecttype == "makefile":
filestolookfor = ["Makefile","makefile"]
+ elif projecttype == "autotools":
+ filestolookfor = ["configure.ac","configure.in"]
mfile = scandirfor(dir, filestolookfor)[0] #use first file found
print(mfile)
- (scanlist,binaries,incflags,targets) = scanmakefiledeps(mfile)
- return scanfilelist(scanlist),binaries,incflags,targets
+ if mfile == "Makefile" or mfile == "makefile":
+ (scanlist,binaries,incflags,targets) = scanmakefiledeps(mfile)
+ #this is broken now... rewrite
+ return scanfilelist(scanlist),binaries,incflags,targets
+
+ else:
+ amfile = os.path.split(mfile)[0] + "/" + "Makefile.am"
+ return scanautotoolsdeps(mfile,amfile)
def openfile(file):
"""Open a file and return the content as a string.
@@ -162,6 +172,3 @@ def openfile(file):
return inputfile.read()
except IOError:
print('cannot open', file)
-
-scanautotoolsdeps("/usr/portage/distfiles/svn-src/moc/trunk/configure.in","/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am")
-#print(scanfilelist(["/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/sidplay2/sidplay2.h"]))
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-09 9:41 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-09 9:41 UTC (permalink / raw
To: gentoo-commits
commit: 04f5d94fc668f1df603fe07dbf57dd995bd9cf90
Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Sat Aug 6 14:38:25 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Sat Aug 6 14:38:25 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=04f5d94f
hacked together somethings in the ebuild gen so it persumes autotools
---
ebuildgen.py | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ebuildgen.py b/ebuildgen.py
index 10586e6..fee6233 100644
--- a/ebuildgen.py
+++ b/ebuildgen.py
@@ -59,7 +59,7 @@ def outputebuild(iuse,deps,usedeps,dltype,adress,installmethod):
'# $Header: $',
''
]
- inheritstr = 'inherit ' + eclass[dltype]
+ inheritstr = 'inherit ' + eclass[dltype] + ' autotools'
text.append(inheritstr)
text += [
@@ -105,11 +105,27 @@ def outputebuild(iuse,deps,usedeps,dltype,adress,installmethod):
depstr = depstr[:-3]
depstr += " )\n\t"
- depstr = depstr[:-2] + '"'
+ depstr = depstr[:-2] + '"\nRDEPEND="${DEPEND}"'
text.append(depstr)
text += [
- 'RDEPEND="${DEPEND}"',
+ '',
+ 'src_prepare() {',
+ '\teautoreconf',
+ '}',
+ ]
+
+ if iuse:
+ text += [
+ '',
+ 'src_configure() {',
+ '\teconf \\',
+ ]
+ for use in iuse:
+ text += ['\t\t$(use_' + use.split("_")[0] + ' ' + use.split("_")[1] + ') \\']
+ text += ['}']
+
+ text += [
'',
'src_compile() {',
' emake || die "emake failed"',
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-09 9:41 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-09 9:41 UTC (permalink / raw
To: gentoo-commits
commit: 07041c6d17f33b9f006ff4d820c5390e4664c185
Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Sun Aug 7 20:46:56 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Sun Aug 7 20:46:56 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=07041c6d
Fixed some more small stuff
---
cli.py | 10 +++++++++-
ebuildgen.py | 4 +++-
linkdeps.py | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/cli.py b/cli.py
index bab1089..500c8ae 100755
--- a/cli.py
+++ b/cli.py
@@ -59,6 +59,9 @@ gpackages = set()
for dep in inclst[0]:
gpackages.add(linkdeps.deptopackage(dep,[])[0])
#print(gpackages)
+if "__cplusplus" in inclst[2]:
+ for dep in inclst[2]["__cplusplus"][0]:
+ gpackages.add(linkdeps.deptopackage(dep,[])[0])
usedeps = {}
for use in useargs:
@@ -67,10 +70,15 @@ for use in useargs:
newpack = linkdeps.deptopackage(dep,[])[0]
if not newpack in gpackages:
packages.add(newpack)
+ if "__cplusplus" in useargs[use][2]:
+ for dep in useargs[use][2]["__cplusplus"][0]:
+ newpack = linkdeps.deptopackage(dep,[])[0]
+ if not newpack in gpackages:
+ packages.add(newpack)
usedeps[use] = packages
#print(usedeps)
-#print(iuse)
+#print(iuse)
ebuildgen.genebuild(iuse,gpackages,usedeps,dltype,args.dir,targets,binaries)
if args.ginc == args.linc == args.ifdef == args.quiet == False:
diff --git a/ebuildgen.py b/ebuildgen.py
index fee6233..d25fa7c 100644
--- a/ebuildgen.py
+++ b/ebuildgen.py
@@ -123,7 +123,9 @@ def outputebuild(iuse,deps,usedeps,dltype,adress,installmethod):
]
for use in iuse:
text += ['\t\t$(use_' + use.split("_")[0] + ' ' + use.split("_")[1] + ') \\']
- text += ['}']
+
+ #add \n here because the ebuild will fail if there is no extra newline between '\' and '}'
+ text += ['\n}']
text += [
'',
diff --git a/linkdeps.py b/linkdeps.py
index d498a88..f9902c8 100644
--- a/linkdeps.py
+++ b/linkdeps.py
@@ -38,7 +38,7 @@ def qfiletopackage(dep,addpaths):
n += 2
if len(package) > 1:
- print("more than one matching package where found!")
+ print("more than one matching package were found!")
if not package:
package = pfltopackage(dep,incpaths)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-14 22:17 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-14 22:17 UTC (permalink / raw
To: gentoo-commits
commit: 5115b9321fcd84edb8808828758a6418c09079ee
Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Fri Aug 12 22:37:49 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Fri Aug 12 22:37:49 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=5115b932
Added "gentoopm" to check for already installed packages
---
cli.py | 4 +++-
linkdeps.py | 10 +++++++++-
scanfiles.py | 22 +++++++++++++---------
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/cli.py b/cli.py
index e88df84..9ed42fa 100755
--- a/cli.py
+++ b/cli.py
@@ -57,7 +57,9 @@ targets = [["install"]]
binaries = []
gpackages = set()
for dep in inclst[0]:
- gpackages.add(linkdeps.deptopackage(dep,[]))
+ newpack = linkdeps.deptopackage(dep,[])
+ if newpack:
+ gpackages.add(newpack)
#print(gpackages)
if "__cplusplus" in inclst[2]:
for dep in inclst[2]["__cplusplus"][0]:
diff --git a/linkdeps.py b/linkdeps.py
index 01b1fb9..a816596 100644
--- a/linkdeps.py
+++ b/linkdeps.py
@@ -1,6 +1,7 @@
import os
from subprocess import getstatusoutput
from urllib.request import urlopen
+import gentoopm
def deptopackage(dep,addpaths):
#return pfltopackage(dep,addpaths)
@@ -44,8 +45,15 @@ def qfiletopackage(dep,addpaths):
package = pfltopackage(dep,incpaths)
print(package)
+ #check if package exists
+ pm=gentoopm.get_package_manager()
if package:
- return package[0]
+ #does the package exist in this computers package manager?
+ if pm.stack.filter(package[0]):
+ return package[0]
+ else:
+ print("No package named: " + package[0] + " found localy, ignoring")
+ return []
else:
return package
diff --git a/scanfiles.py b/scanfiles.py
index fc701f6..b961037 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -109,17 +109,21 @@ def scanautotoolsdeps(acfile,amfile):
else:
useargs[usearg] = [src]
+ ifdef_lst = [includes[2]]
+
for usearg in useargs:
useargs[usearg] = scanfilelist(useargs[usearg],src_incflag)
-
- for ifdef in includes[2]:
- for switch in iflst:
- if ifdef in switch[1]:
- usearg = inter_useflag(switch[0])
- if usearg in useargs:
- useargs[usearg][0].update(includes[2][ifdef][0])
- else:
- useargs[usearg] = includes[2][ifdef]
+ ifdef_lst += [useargs[usearg][2]]
+
+ for ifdef in ifdef_lst:
+ for item in ifdef:
+ for switch in iflst:
+ if item in switch[1]:
+ usearg = inter_useflag(switch[0])
+ if usearg in useargs:
+ useargs[usearg][0].update(ifdef[item][0])
+ else:
+ useargs[usearg] = ifdef[item]
#print(useargs)
#print(includes)
return useflags,includes,useargs
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /
@ 2011-08-15 17:58 Sebastian Parborg
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Parborg @ 2011-08-15 17:58 UTC (permalink / raw
To: gentoo-commits
commit: f10bda21c3122f332c2cdd3e69818230d961821a
Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Mon Aug 15 17:01:58 2011 +0000
Commit: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Mon Aug 15 17:01:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=f10bda21
Added a basic setup script
---
setup.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..0249309
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+
+from distutils.core import setup
+
+
+setup(name='Ebuild generator',
+ version='0.1',
+ description='Script to generate ebuilds',
+ author='Sebasitan Parborg',
+ author_email='darkdefende@gmail.com',
+ url='https://github.com/DarkDefender/ebuildgen',
+ packages=['ebuildgen', 'ebuildgen.filetypes'],
+ scripts=['genebuild'],
+ )
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-15 17:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-14 22:17 [gentoo-commits] proj/ebuildgen:master commit in: / Sebastian Parborg
-- strict thread matches above, loose matches on Subject: below --
2011-08-15 17:58 Sebastian Parborg
2011-08-09 9:41 Sebastian Parborg
2011-08-09 9:41 Sebastian Parborg
2011-08-09 9:41 Sebastian Parborg
2011-08-09 9:41 Sebastian Parborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox