diff options
author | 2011-06-13 22:39:24 +0200 | |
---|---|---|
committer | 2011-06-13 22:39:24 +0200 | |
commit | 713481409e1cb890ee8f29a01315311e132ffe44 (patch) | |
tree | 8be46033e0fe7276991ab9964ccf24db7310cc31 /ebuildgen.py | |
parent | You can now link deps to packages with the help of qfile (diff) | |
download | ebuildgen-713481409e1cb890ee8f29a01315311e132ffe44.tar.gz ebuildgen-713481409e1cb890ee8f29a01315311e132ffe44.tar.bz2 ebuildgen-713481409e1cb890ee8f29a01315311e132ffe44.zip |
Added basic ebuild output
Diffstat (limited to 'ebuildgen.py')
-rw-r--r-- | ebuildgen.py | 93 |
1 files changed, 93 insertions, 0 deletions
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 |