diff --git a/handlers/binary-metafile-builder b/handlers/binary-metafile-builder index 231ee537c..4c04f3988 100644 --- a/handlers/binary-metafile-builder +++ b/handlers/binary-metafile-builder @@ -25,26 +25,7 @@ import os import sys import string import entropyTools - -# variables -# should we import these into make.conf ? -pTree = "/var/lib/entropy/packages" -pTmpDir = pTree+"/tmp" -# dictionary info -pData = { - 'name': "", - 'version': "", - 'description': "", - 'category': "", - 'arch': "", - 'chost': "", - 'homepage': "", - 'useflags': "", - 'license': "", - 'uri': "", - 'dependencies': "", - 'conflicts': "", -} +from entropyVariables import * # System functions @@ -114,10 +95,7 @@ if (not validFile): print_info(".tbz2 file found: "+tbz2File) -# xpak files support -import xpak - -# Extract .xpak file from .tbz2 -tbz2 = xpak.tbz2(tbz2File) -print entropyTools.extractPkgData(tbz2File) +# fill all the info +pData = entropyTools.extractPkgData(tbz2File) #os.mkdir(pTmpDir+"/") +print pData \ No newline at end of file diff --git a/handlers/entropyTools.py b/handlers/entropyTools.py index 1f77aa660..2e5d73f14 100644 --- a/handlers/entropyTools.py +++ b/handlers/entropyTools.py @@ -4,7 +4,13 @@ # DESCRIPTION: # generic tools for all the handlers applications +from entropyVariables import * + +# This function extracts all the info from a .tbz2 file and returns them def extractPkgData(package): + + tbz2File = package + package = package.split(".tbz2") package = package[0].split("-") pkgname = "" @@ -21,4 +27,30 @@ def extractPkgData(package): else: pkgname += package[i]+"-" pkgname = pkgname.split("/")[len(pkgname.split("/"))-1] - return pkgname, pkgver \ No newline at end of file + + # Fill Package name and version + pData['name'] = pkgname + pData['version'] = pkgver + + import xpak + tbz2 = xpak.tbz2(tbz2File) + tbz2TmpDir = pTmpDir+"/"+pData['name']+"-"+pData['version'] + tbz2.decompose(tbz2TmpDir) + + # Fill description + f = open(tbz2TmpDir+"/"+dbDESCRIPTION,"r") + pData['description'] = f.readline().strip() + f.close() + + # Fill homepage + f = open(tbz2TmpDir+"/"+dbHOMEPAGE,"r") + pData['homepage'] = f.readline().strip() + f.close() + + # Fill chost + f = open(tbz2TmpDir+"/"+dbCHOST,"r") + pData['chost'] = f.readline().strip() + f.close() + + # return all the collected info + return pData \ No newline at end of file diff --git a/handlers/entropyVariables.py b/handlers/entropyVariables.py new file mode 100644 index 000000000..aed2000b8 --- /dev/null +++ b/handlers/entropyVariables.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# Copyright Fabio Erculiani - Sabayon Linux 2007 + +# DESCRIPTION: +# Variables container + +# Specifications of the content of .etp file go here +pData = { + 'name': "", + 'version': "", + 'description': "", + 'category': "", + 'arch': "", + 'chost': "", + 'homepage': "", + 'useflags': "", + 'license': "", + 'download': "", # get this info from make.conf + 'dependencies': "", + 'conflicts': "", +} + +# variables +# should we import these into make.conf ? +pTree = "/var/lib/entropy/packages" +pTmpDir = pTree+"/tmp" +# fetch PORTAGE_BINHOST +f = open("/etc/make.conf","r") +makeConf = f.readlines() +pBinHost = "" +for line in makeConf: + line = line.strip() + if line.startswith("PORTAGE_BINHOST"): + pBinHost = line.split('"')[1] + break +if (pBinHost == ""): + # force PORTAGE_BINHOST to our defaults + pBinHost = "http://www.sabayonlinux.org/binhost/All/" +if not pBinHost.endswith("/"): + pBinHost += "/" + +# Portage /var/db///* +# you never know if gentoo devs change these things +dbDESCRIPTION = "DESCRIPTION" +dbHOMEPAGE = "HOMEPAGE" +dbCHOST = "CHOST"