diff --git a/TODO b/TODO index db67b1814..768d5300f 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,7 @@ TODO list (for developers only): - activator should care about the removal of the old packages - build() and world(), on enzyme, add the support for whitelist+cron - build(), on enzyme, add license blacklist (packages that cannot be shipped in a binary form) +- enzyme, add search module? - Sabayon Linux USE flags: remove all server related use flags Project Status: @@ -15,4 +16,5 @@ Project Status: Features plan: -- distcc support to enzyme \ No newline at end of file +- enzyme: distcc support +- activator: add stable/ repository and the cron-aware module that moves files from the unstable/default repo to the stable one. \ No newline at end of file diff --git a/handlers/enzyme b/handlers/enzyme index f478980b7..6bd5ec4fc 100644 --- a/handlers/enzyme +++ b/handlers/enzyme @@ -74,6 +74,7 @@ def print_help(): entropyTools.print_info(" \t\t "+entropyTools.red("--sync-back")+"\t\t sync between Entropy Portage Tree and the official one") entropyTools.print_info(" \t\t "+entropyTools.red("--only-sync-back")+"\t only sync between Entropy Portage Tree and the official one") entropyTools.print_info(" \t\t "+entropyTools.red("--no-overlay-sync")+"\t disable automatic overlays sync") + entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("search"))+entropyTools.yellow("\t\t to search a package inside the Entropy Portage repository")) entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("cleanup"))+entropyTools.yellow("\t\t to clean temporary files")) options = sys.argv[1:] @@ -128,6 +129,10 @@ if (options[0] == "build"): if (options[0] == "uninstall"): enzymeTools.uninstall(options[1:]) sys.exit(0) +# search tool +if (options[0] == "search"): + enzymeTools.search(options[1:]) + sys.exit(0) # cleanup tool if (options[0] == "cleanup"): entropyTools.cleanup(options[1:]) diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index b1dc7752d..54f8f9015 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -70,6 +70,7 @@ ETP_RANDOM = str(random.random())[2:7] ETP_TMPFILE = "/.random-"+ETP_RANDOM+".tmp" ETP_REPODIR = "/repository"+"/"+ETP_ARCH_CONST ETP_PORTDIR = "/portage" +ETP_DISTFILESDIR = "/distfiles" ETP_DBDIR = "/database"+"/"+ETP_ARCH_CONST ETP_UPLOADDIR = "/upload"+"/"+ETP_ARCH_CONST ETP_STOREDIR = "/store"+"/"+ETP_ARCH_CONST @@ -90,6 +91,7 @@ etpConst = { 'packagesstoredir': ETP_DIR+ETP_STOREDIR, # etpConst['packagesstoredir'] --> directory where .tbz2 files are stored waiting for being processed by reagent '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 + 'distfilesdir': ETP_DIR+ETP_PORTDIR+ETP_DISTFILESDIR, # directory where our sources are downloaded '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 diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index dca998d77..73e69ce2f 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -23,6 +23,7 @@ def initializePortageTree(): portage.settings.unlock() portage.settings['PORTDIR'] = etpConst['portagetreedir'] + portage.settings['DISTDIR'] = etpConst['distfilesdir'] portage.settings['PORTDIR_OVERLAY'] = etpConst['overlays'] portage.settings.lock() portage.portdb.__init__(etpConst['portagetreedir']) @@ -32,6 +33,7 @@ import os from entropyConstants import * os.environ['PORTDIR'] = etpConst['portagetreedir'] os.environ['PORTDIR_OVERLAY'] = etpConst['overlays'] +os.environ['DISTDIR'] = etpConst['distfilesdir'] import portage import portage_const from portage_dep import isvalidatom, isspecific, isjustname, dep_getkey, dep_getcpv @@ -74,6 +76,13 @@ def getBestAtom(atom): except ValueError: return "!!conflicts" +# same as above but includes masked ebuilds +def getBestMaskedAtom(atom): + atoms = portage.portdb.xmatch("match-all",str(atom)) + # find the best + from portage_versions import best + return best(atoms) + # I need a valid complete atom... def calculateFullAtomsDependencies(atoms, deep = False, extraopts = ""): # in order... thanks emerge :-) @@ -255,6 +264,40 @@ def collectBinaryFilesForInstalledPackage(atom): def getEbuildDbPath(atom): return portage.db['/']['vartree'].getebuildpath(atom) +def getEbuildTreePath(atom): + if atom.startswith("="): + atom = atom[1:] + rc = portage.portdb.findname(atom) + if rc != "": + return rc + else: + return None + +def getPackageDownloadSize(atom): + if atom.startswith("="): + atom = atom[1:] + + ebuild = getEbuildTreePath(atom) + if (ebuild is not None): + import portage_manifest + dirname = os.path.dirname(ebuild) + manifest = portage_manifest.Manifest(dirname, portage.settings["DISTDIR"]) + fetchlist = portage.portdb.getfetchlist(atom, portage.settings, all=True)[1] + summary = [0,0] + try: + summary[0] = manifest.getDistfilesSize(fetchlist) + counter = str(summary[0]/1024) + filler=len(counter) + while (filler > 3): + filler-=3 + counter=counter[:filler]+","+counter[filler:] + summary[0]=counter+" kB" + except KeyError, e: + return "N/A" + return summary[0] + else: + return "N/A" + def getInstalledAtoms(atom): rc = portage.db['/']['vartree'].dep_match(str(atom)) if (rc != []): @@ -787,11 +830,47 @@ class activatorFTP: def closeFTPConnection(self): self.ftpconn.quit() - - # FIXME: add upload/delete/mv commands - # ------ END: activator tools ------ +def packageSearch(keyword): + + SearchDirs = [] + # search in etpConst['portagetreedir'] + # and in overlays after etpConst['overlays'] + # fill the list + portageRootDir = etpConst['portagetreedir'] + if not portageRootDir.endswith("/"): + portageRootDir = portageRootDir+"/" + ScanningDirectories = [] + ScanningDirectories.append(portageRootDir) + for dir in etpConst['overlays'].split(): + if (not dir.endswith("/")): + dir = dir+"/" + if os.path.isdir(dir): + ScanningDirectories.append(dir) + + for directoryTree in ScanningDirectories: + treeList = os.listdir(directoryTree) + _treeList = [] + # filter unwanted dirs + for dir in treeList: + if (dir.find("-") != -1) and os.path.isdir(directoryTree+dir): + _treeList.append(directoryTree+dir) + treeList = _treeList + + for dir in treeList: + subdirs = os.listdir(dir) + for sub in subdirs: + if (not sub.startswith(".")) and (sub.find(keyword) != -1): + if os.path.isdir(dir+"/"+sub): + reldir = re.subn(directoryTree,"", dir+"/"+sub)[0] + SearchDirs.append(reldir) + + # filter dupies + SearchDirs = list(set(SearchDirs)) + + return SearchDirs + # get a list, returns a sorted list def alphaSorter(seq): def stripter(s, goodchrs): diff --git a/libraries/enzymeTools.py b/libraries/enzymeTools.py index 774dab5c9..69c994044 100644 --- a/libraries/enzymeTools.py +++ b/libraries/enzymeTools.py @@ -132,9 +132,6 @@ def sync(options): def build(atoms): - # FIXME: add USE flags management: - # packages with new USE flags must be pulled in - # unless --ignore-new-use-flags is specified enzymeRequestVerbose = False enzymeRequestForceRepackage = False @@ -842,3 +839,41 @@ def uninstall(options): print_warning(yellow(" *** ")+red("Please use --verbose and retry to see what was wrong. Continuing...")) else: print_info(green(" * ")+bold(atom)+" worked out successfully.") + +def search(atoms): + + # filter any --starting package + _atoms = [] + for atom in atoms: + if (not atom.startswith("--")): + _atoms.append(atom) + keywords = _atoms + + print + for keyword in keywords: + results = packageSearch(keyword) + for result in results: + # get latest version available + masked = "" + latestVersion = getBestAtom(result) + if (latestVersion == ""): + latestVersion = getBestMaskedAtom(result) + masked = " "+bold("[")+red("MASKED")+bold("]") + # get installed version + installedVer = getInstalledAtom(result) + # get Homepage + pkgHomepage = getPackageVar(latestVersion,'HOMEPAGE') + # get Description + pkgDescription = getPackageVar(latestVersion,'DESCRIPTION') + # get License + pkgLicense = getPackageVar(latestVersion,'LICENSE') + + # format the output string + print_info(green(" * ")+bold(result)) + print_info(red("\t Latest version available: ")+blue(latestVersion)+masked) + print_info(red("\t Latest version installed: ")+green(str(installedVer))) + print_info(red("\t Download size: ")+yellow(getPackageDownloadSize(latestVersion))) + print_info(red("\t Homepage: ")+darkred(pkgHomepage)) + print_info(red("\t Description: ")+pkgDescription) + print_info(red("\t License: ")+bold(pkgLicense)) + print \ No newline at end of file