From dc5cf59136f5d9cbf6cd9f6019effebec4720061 Mon Sep 17 00:00:00 2001 From: lxnay Date: Mon, 26 Feb 2007 08:14:59 +0000 Subject: [PATCH] more work on build() added a preliminary emerge() function and added tmp files management git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@139 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- TODO | 2 +- libraries/entropyConstants.py | 20 +++++++++++++++++++- libraries/entropyTools.py | 12 +++++++++++- libraries/enzymeTools.py | 12 +++++------- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 85b8bc9d7..b17c60be6 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ TODO list (for developers only): - timestamp management across database and packages servers -- a lot more :-P +- a general option --info to print all the Entropy variables and constants diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index a7fd08fa8..c18ba5f50 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -22,6 +22,8 @@ import os import commands +import string +import random # Specifications of the content of .etp file # THIS IS THE KEY PART OF ENTROPY BINARY PACKAGES MANAGEMENT @@ -64,6 +66,8 @@ ETP_ARCH_CONST = "%ARCH%" ETP_REVISION_CONST = "%ETPREV%" ETP_DIR = "/var/lib/entropy" ETP_TMPDIR = "/tmp" +ETP_RANDOM = str(random.random())[2:7] +ETP_TMPFILE = "/.random-"+ETP_RANDOM+".tmp" ETP_REPODIR = "/repository"+"/"+ETP_ARCH_CONST ETP_PORTDIR = "/portage" ETP_DBDIR = "/database"+"/"+ETP_ARCH_CONST @@ -75,6 +79,7 @@ MAX_ETP_REVISION_COUNT = 99999 etpConst = { 'packagestmpdir': ETP_DIR+ETP_TMPDIR, # etpConst['packagestmpdir'] --> temp directory + 'packagestmpfile': ETP_DIR+ETP_TMPDIR+ETP_TMPFILE, # etpConst['packagestmpfile'] --> general purpose tmp file 'packagesbindir': ETP_DIR+ETP_REPODIR, # etpConst['packagesbindir'] --> repository where the packages will be stored # by the clients: to query if a package has been already downloaded # by the servers or rsync mirrors: to store already uploaded packages to the main rsync server @@ -83,6 +88,7 @@ etpConst = { 'packagessuploaddir': ETP_DIR+ETP_UPLOADDIR, # etpConst['packagessuploaddir'] --> directory where .tbz2 files are stored waiting for being uploaded to our main mirror 'portagetreedir': ETP_DIR+ETP_PORTDIR, # directory where is stored our local portage tree 'overlaysdir': ETP_DIR+ETP_PORTDIR+"/local/layman", # directory where overlays are stored + 'overlays': "", # variable PORTDIR_OVERLAY 'overlaysconffile': ETP_CONF_DIR+"/layman.cfg", # layman configuration file 'confdir': ETP_CONF_DIR, # directory where entropy stores its configuration 'repositoriesconf': ETP_CONF_DIR+"/repositories.conf", # repositories.conf file @@ -97,7 +103,7 @@ if not os.path.isdir(ETP_DIR): if getpass.getuser() == "root": import re for x in etpConst: - if (etpConst[x]) and (not etpConst[x].endswith(".conf")) and (not etpConst[x].endswith(".cfg")): + if (etpConst[x]) and (not etpConst[x].endswith(".conf")) and (not etpConst[x].endswith(".cfg")) and (not etpConst[x].endswith(".tmp")): if etpConst[x].find("%ARCH%") != -1: for i in ETP_ARCHS: @@ -211,6 +217,14 @@ nocheck : yes f.flush() f.close() +# fill etpConst['overlays'] +ovlst = os.listdir(etpConst['overlaysdir']) +_ovlst = [] +for i in ovlst: + if os.path.isdir(etpConst['overlaysdir']+"/"+i): + _ovlst.append(etpConst['overlaysdir']+"/"+i) +etpConst['overlays'] = string.join(_ovlst," ") + # Portage /var/db///* # you never know if gentoo devs change these things dbDESCRIPTION = "DESCRIPTION" @@ -237,3 +251,7 @@ vdbPORTDIR_OVERLAY = "PORTDIR_OVERLAY" # Portage commands cdbEMERGE = "emerge" +cdbRunEmerge = vdbPORTDIR+"='"+etpConst['portagetreedir']+"' "+vdbPORTDIR_OVERLAY+"='"+etpConst['overlays']+"' "+cdbEMERGE + +# Portage options +odbBuild = "-b" \ No newline at end of file diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index 0607b31c9..62d91f803 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -44,7 +44,11 @@ def isRoot(): return False def getPortageEnv(var): - return portage.config(clone=portage.settings).environ()[var] + try: + rc = portage.config(clone=portage.settings).environ()[var] + return rc + except KeyError: + return None def getThirdPartyMirrors(mirrorname): return portage.thirdpartymirrors[mirrorname] @@ -80,6 +84,12 @@ def getInstalledAtom(atom): else: return None +def emerge(atom,options): + outfile = etpConst['packagestmpfile'] + print outfile + #rc = spawnCommand(cdbRunEmerge+" "+options+" "+atom, ) + #return rc, outfile + # NOTE: atom must be a COMPLETE atom, with version! def isTbz2PackageAvailable(atom, verbose = False): # check if the package have been already merged diff --git a/libraries/enzymeTools.py b/libraries/enzymeTools.py index ba7c56962..9e106b500 100644 --- a/libraries/enzymeTools.py +++ b/libraries/enzymeTools.py @@ -57,12 +57,7 @@ def getSyncTime(): def listOverlays(): # NOTE: this function does not directly check if # layman is installed !!!! - lst = os.listdir(etpConst['overlaysdir']) - _lst = [] - for i in lst: - if os.path.isdir(etpConst['overlaysdir']+"/"+i): - _lst.append(i) - lst = _lst + lst = etpConst['overlays'].split() return lst # fetch the latest updates from Gentoo rsync mirrors @@ -252,7 +247,7 @@ def build(atoms): # when the compilation ends, enzyme runs reagent packagesPaths = [] - + print if PackagesDependencies != []: print yellow(" *")+" Building dependencies..." @@ -261,6 +256,8 @@ def build(atoms): # - errors # - log files # - etc update? + rc = emerge(dep,odbBuild) + print str(rc) print green(" *")+" Compiling: "+red(dep) print if toBeBuilt != []: @@ -288,6 +285,7 @@ def build(atoms): for pkg in packagesPaths: print green(" *")+red(pkg) + return packagesPaths def overlay(options): # etpConst['overlaysconffile'] --> layman.cfg