# Copyright 2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 from twisted.internet import reactor from twisted.web.client import downloadPage from twisted.python.util import println import sys import os distfiles = "/usr/portage/distfiles" tmpdir = "/tmp/freedict/" ebuilds_dir = "/usr/local/portage/app-dicts/" sf_url = "http://freedict.sourceforge.net/download/linux/" languages = ["afr", "cze", "dan", "deu", "eng", "fra", "hun", "iri", "ita", "jpn", "lat", "nld", "por", "rus", "sco", "scr", "slo", "spa", "swa", "swe", "tur", "wel"] ############################################## ebuild_code = """ # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 ##### $Header: /home/cvsroot/gentoo-x86/app-dicts/freedict-eng-fra/freedict-eng-fra-1.0.ebuild,v 1.1 2003/03/18 03:51:36 seemant Exp $ FORLANG="language1" TOLANG="language2" inherit freedict """ dictd_freedicts_code = """ # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 ##### $Header: /home/cvsroot/gentoo-x86/app-dicts/dictd-dicts/dictd-dicts-1.0.ebuild,v 1.6 2003/07/16 15:05:47 pvdabeel Exp $ DESCRIPTION="A package to simplify installation of all dictd freedict dictionaries" SLOT="0" LICENSE="GPL-2" KEYWORDS="x86 ppc sparc" DEPEND="" RDEPEND= """ ################################################## def getFile(url, file): downloadPage(url, file).addCallbacks( lambda value:reactor.stop(), lambda error:(println("an error occurred",error),reactor.stop())) reactor.run() def getDictFiles(): for l1 in languages: for l2 in languages: if l1 != l2: f = l1 + "-" + l2 + ".tar.gz" getFile(sf_url + f, tmpdir + f) def makeDigests(): print "Little bash line:" print "for ebuild in $(find " + ebuilds_dir + "|grep ebuild$); do ebuild $ebuild digest; done" def makeEbuild(NP, NV, code): path = os.path.join(ebuilds_dir, NP) if not os.path.exists(path): os.mkdir(path) ebuild = os.path.join(path, NP + "-" + NV + ".ebuild") f = open(ebuild, 'w') f.write(code) f.close def makeEbuilds(): freedicts = [f[:-7] for f in os.listdir(tmpdir)] deps = 'RDEPEND="' for freedict in freedicts: NP = "freedict-" + freedict NV = "1.0" makeEbuild(NP, NV, ebuild_code) deps += "app-dicts/" + NP + "\n" print deps makeEbuild("dictd-freedicts", "1.0", dictd_freedicts_code + deps + '"') ################################################## #getDictFiles() if not os.path.exists(tmpdir): os.mkdir(tmpdir) makeEbuilds() makeDigests()