entropy handlers are starting to do something more than printing garbage

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@43 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2007-02-02 23:08:21 +00:00
parent f1b87522c2
commit fd429e8a68
3 changed files with 83 additions and 27 deletions

View File

@@ -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

View File

@@ -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
# 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

View File

@@ -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/<pkgcat>/<pkgname-pkgver>/*
# you never know if gentoo devs change these things
dbDESCRIPTION = "DESCRIPTION"
dbHOMEPAGE = "HOMEPAGE"
dbCHOST = "CHOST"