public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sebastian Parborg" <darkdefende@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ebuildgen:master commit in: /
Date: Tue,  9 Aug 2011 09:41:44 +0000 (UTC)	[thread overview]
Message-ID: <3c43da8b23e7037e02be445ee17b238b8e86bdfe.darkdefender@gentoo> (raw)

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"]))



             reply	other threads:[~2011-08-09  9:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09  9:41 Sebastian Parborg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-15 17:58 [gentoo-commits] proj/ebuildgen:master commit in: / Sebastian Parborg
2011-08-14 22:17 Sebastian Parborg
2011-08-09  9:41 Sebastian Parborg
2011-08-09  9:41 Sebastian Parborg
2011-08-09  9:41 Sebastian Parborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c43da8b23e7037e02be445ee17b238b8e86bdfe.darkdefender@gentoo \
    --to=darkdefende@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox