Files
entropy/handlers/binary-metafile-builder
2007-02-02 23:08:21 +00:00

101 lines
2.6 KiB
Python

#!/usr/bin/python
# Copyright Fabio Erculiani - Sabayon Linux 2007
# DESCRIPTION:
# this file get a .tbz2 file as input and creates the dependency binary metafile
# that another application could handle using portage and binpackages extensions directly
# Output file sample (extension *.etp)
# PackageName: mplayer-1.0_rc1-r1{-etp[0-99]}
# PackageCategory: media-video
# PackageArch: amd64
# PackageChost: x86_64-pc-linux-gnu
# PackageHomePage: http://www.mplayer.hu
# PackageUse: -alsa +alsa -3dnow etc...
# PackageLicense: GPL-2
# PackageBinUri: http://www.sabayonlinux.org/binhost/%%PackageArch%%/packages/All/%%PackageName%%.tbz2
# Dependencies: xysz-1.0-r2-etp1, asd-0.88-r1-etp2
# Notes:
# - we can use (from /var/db) "NEEDED" file to catch all the needed libraries to run the binary package
# - we can use (from /var/db) "CONTENTS" to rapidly search the NEEDED files in the file above
import os
import sys
import string
import entropyTools
from entropyVariables import *
# System functions
def print_error(msg):
print "* erro * : "+msg
def print_info(msg):
print "* info * : "+msg
def print_help():
print "* IIIII * : Sabayon Linux binary-metafile-builder - written by Fabio Erculiani (C - 2007)"
print "* usage * : binary-metafile-builder <valid gentoo .tbz2 file>"
def print_warning(msg):
print "* warn * : "+msg
# Create paths
if not os.path.isdir(pTree):
import getpass
if getpass.getuser() == "root":
os.makedirs(pTree,0755)
os.chown(pTree,0,0)
else:
print_error("you need to run this as root at least once.")
sys.exit(2)
if not os.path.isdir(pTmpDir):
import getpass
if getpass.getuser() == "root":
os.makedirs(pTmpDir,0755)
os.chown(pTmpDir,0,0)
else:
print_error("you need to run this as root at least once.")
sys.exit(2)
else:
# Clean pTmpDir
os.system("rm -rf "+pTmpDir+"/*")
options = sys.argv[1:]
# parameters test
if len(options) < 1 or string.join(options).find("--help") != -1 or string.join(options).find("-h") != -1:
print_help()
if len(options) < 1:
print_error("not enough parameters")
sys.exit(1)
if len(options) > 2:
print_help()
print_error("too many parameters")
sys.exit(1)
if not string.join(options).find(".tbz2"):
print_error("no .tbz2 file specified")
sys.exit(3)
validFile = False
for i in options:
if os.path.isfile(i) and i.endswith(".tbz2"):
validFile = True
tbz2File = i
break
if (not validFile):
print_error("no valid .tbz2 file specified")
sys.exit(4)
print_info(".tbz2 file found: "+tbz2File)
# fill all the info
pData = entropyTools.extractPkgData(tbz2File)
#os.mkdir(pTmpDir+"/")
print pData