overlays management added, more work on enzyme tools and on the application itself
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@92 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
5
README
5
README
@@ -9,9 +9,12 @@ DEVELOPERS:
|
||||
DEPENDENCIES:
|
||||
- >=sys-apps/portage-2.1.2
|
||||
- >=app-portage/portage-utils-0.1.23 (not mandatory)
|
||||
- >=app-portage/layman-1.0.8 (if you use overlays)
|
||||
|
||||
INSTALLATION:
|
||||
- copy entropy.conf in /etc/
|
||||
- copy all the content of conf/ to /etc/entropy/
|
||||
- copy the rest of the tree where you want and execute handlers/ apps inside their dir
|
||||
- add sabayon overlay: python enzyme overlay add sabayon
|
||||
|
||||
STRUCTURE:
|
||||
|
||||
|
||||
@@ -35,17 +35,22 @@ APPVERSION = "1.0"
|
||||
def print_help():
|
||||
print "* info * : Sabayon Linux "+APPNAME+" (C - 2007)"
|
||||
print
|
||||
print "* usage * : "+APPNAME+" <tool> <atom?>"
|
||||
print "* usage * : "+APPNAME+" <tool> <atom(s)>"
|
||||
print "* opts * : --help\t\tthis output"
|
||||
print "* opts * : --version\t\tprint version"
|
||||
print "* opts * : --verbose\t\tbe verbose"
|
||||
print
|
||||
print "* info * : tools available: "
|
||||
print "* info * : \tworld\t to build all the possible new packages"
|
||||
print "* info * : \tbuild\t to build all the packages specified in <atom?>"
|
||||
print "* info * : \tsync\t to just sync portage tree"
|
||||
print "* info * : \tdata-cleanup\t to clean all the old packages or stale files"
|
||||
print "* info * : \tdata-reset\t to remove all and start over"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("world"))+"\t\t to build all the possible new packages"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("build"))+"\t\t to build all the packages specified in <atom(s)>"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("overlay"))+"\t\t to manage overlays"
|
||||
print "* opts * : \t\t add\t to add overlays"
|
||||
print "* opts * : \t\t remove\t to remove overlays"
|
||||
print "* opts * : \t\t sync\t to sync overlays (after this you can specify which overlay)"
|
||||
print "* opts * : \t\t list\t to list overlays"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("sync"))+"\t\t to just sync portage tree"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("data-cleanup"))+"\t to clean all the old packages or stale files"
|
||||
print "* info * : \t"+entropyTools.green(entropyTools.bold("data-reset"))+"\t to remove all and start over"
|
||||
print
|
||||
|
||||
options = sys.argv[1:]
|
||||
@@ -64,7 +69,7 @@ if len(options) < 1 or string.join(options).find("--help") != -1 or string.join(
|
||||
|
||||
if (not entropyTools.isRoot()):
|
||||
entropyTools.print_error("you must be root in order to run "+APPNAME)
|
||||
sys.exit(1)
|
||||
sys.exit(2)
|
||||
|
||||
# world tool
|
||||
if (options[0] == "world"):
|
||||
@@ -75,12 +80,16 @@ if (options[0] == "world"):
|
||||
if (options[0] == "sync"):
|
||||
enzymeTools.sync(options)
|
||||
sys.exit(0)
|
||||
|
||||
# add other options here
|
||||
# ...
|
||||
# ...
|
||||
# tbz2 tool
|
||||
|
||||
# overlay tool
|
||||
if (options[0] == "overlay"):
|
||||
rc = enzymeTools.overlay(options)
|
||||
if (rc):
|
||||
sys.exit(0)
|
||||
else:
|
||||
# an error occoured
|
||||
print_help()
|
||||
sys.exit(3)
|
||||
# build tool
|
||||
if (options[0] == "build"):
|
||||
enzymeTools.build(options[1:])
|
||||
sys.exit(0)
|
||||
@@ -20,6 +20,9 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
'''
|
||||
|
||||
import os
|
||||
import commands
|
||||
|
||||
# Specifications of the content of .etp file
|
||||
# THIS IS THE KEY PART OF ENTROPY BINARY PACKAGES MANAGEMENT
|
||||
# DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU'RE DOING !!
|
||||
@@ -76,14 +79,15 @@ etpConst = {
|
||||
'packagesstoredir': ETP_DIR+ETP_DBDIR, # etpConst['packagesstoredir'] --> directory where .tbz2 files are stored waiting for being processed by entropy-specifications-generator
|
||||
'packagessuploaddir': ETP_DIR+ETP_STOREDIR, # 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
|
||||
'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
|
||||
'enzymeconf': ETP_CONF_DIR+"/enzyme.conf", # enzym.conf file
|
||||
'enzymeconf': ETP_CONF_DIR+"/enzyme.conf", # enzyme.conf file
|
||||
'digestfile': "Manifest", # file that contains md5 hashes
|
||||
'extension': ".etp", # entropy files extension
|
||||
}
|
||||
|
||||
import os
|
||||
# Create paths
|
||||
if not os.path.isdir(ETP_DIR):
|
||||
import getpass
|
||||
@@ -135,7 +139,6 @@ if os.path.isfile(etpConst['repositoriesconf']):
|
||||
if repouri.startswith("http://") or repouri.startswith("ftp://") or repouri.startswith("rsync://"):
|
||||
etpSources['databaseuri'] = repouri
|
||||
|
||||
import commands
|
||||
if (commands.getoutput("q -V").find("portage-utils") != -1):
|
||||
pFindLibrary = "qfile -qC "
|
||||
pFindLibraryXT = "qfile -qeC "
|
||||
@@ -143,6 +146,68 @@ else:
|
||||
pFindLibrary = "equery belongs -n "
|
||||
pFindLibraryXT = "equery belongs -en "
|
||||
|
||||
# configure layman.cfg properly
|
||||
if (not os.path.isfile(etpConst['overlaysconffile'])):
|
||||
laymanConf = """
|
||||
[MAIN]
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Path to the config directory
|
||||
|
||||
config_dir: /etc/layman
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Defines the directory where overlays should be installed
|
||||
|
||||
storage : """+etpConst['overlaysdir']+"""
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Remote overlay lists will be stored here
|
||||
# layman will append _md5(url).xml to each filename
|
||||
|
||||
cache : %(storage)s/cache
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# The list of locally installed overlays
|
||||
|
||||
local_list: %(storage)s/overlays.xml
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Path to the make.conf file that should be modified by
|
||||
# layman
|
||||
|
||||
make_conf : %(storage)s/make.conf
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# URLs of the remote lists of overlays (one per line) or
|
||||
# local overlay definitions
|
||||
#
|
||||
#overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt
|
||||
# http://dev.gentoo.org/~wrobel/layman/global-overlays.xml
|
||||
# http://mydomain.org/my-layman-list.xml
|
||||
# file:///usr/portage/local/layman/my-list.xml
|
||||
|
||||
overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Proxy support
|
||||
#
|
||||
#proxy : http://www.my-proxy.org:3128
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Strict checking of overlay definitions
|
||||
#
|
||||
# Set either to "yes" or "no". If "no" layman will issue
|
||||
# warnings if an overlay definition is missing either
|
||||
# description or contact information.
|
||||
#
|
||||
nocheck : yes
|
||||
"""
|
||||
f = open(etpConst['overlaysconffile'],"w")
|
||||
f.writelines(laymanConf)
|
||||
f.flush()
|
||||
f.close()
|
||||
|
||||
# Portage /var/db/<pkgcat>/<pkgname-pkgver>/*
|
||||
# you never know if gentoo devs change these things
|
||||
dbDESCRIPTION = "DESCRIPTION"
|
||||
@@ -165,6 +230,7 @@ dbKEYWORDS = "KEYWORDS"
|
||||
# Portage variables reference
|
||||
# vdbVARIABLE --> $VARIABLE
|
||||
vdbPORTDIR = "PORTDIR"
|
||||
vdbPORTDIR_OVERLAY = "PORTDIR_OVERLAY"
|
||||
|
||||
# Portage commands
|
||||
cdbEMERGE = "emerge"
|
||||
@@ -73,10 +73,12 @@ def getInstalledAtom(atom):
|
||||
return atom
|
||||
|
||||
def checkAtom(atom):
|
||||
if (isvalidatom(atom) == 1):
|
||||
if (isvalidatom(atom) == 1) or ( isjustname(atom) == 1):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def removeSpaceAtTheEnd(string):
|
||||
if string.endswith(" "):
|
||||
return string[:len(string)-1]
|
||||
|
||||
@@ -28,6 +28,8 @@ from entropyConstants import *
|
||||
from entropyTools import *
|
||||
|
||||
import sys
|
||||
import os
|
||||
import commands
|
||||
|
||||
# Stolen from Porthole 0.5.0 - thanks for your help :-)
|
||||
|
||||
@@ -52,6 +54,16 @@ def getSyncTime():
|
||||
except:
|
||||
print_warning("getSyncTime(): empty Portage tree (first run?) or no timestamp to read")
|
||||
|
||||
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
|
||||
return lst
|
||||
|
||||
# fetch the latest updates from Gentoo rsync mirrors
|
||||
def sync(options):
|
||||
@@ -66,12 +78,97 @@ def sync(options):
|
||||
sys.exit(101)
|
||||
|
||||
|
||||
def build(atoms):
|
||||
def build(atoms): # FIXME: remember to use listOverlay() as PORTDIR_OVERLAY variable
|
||||
validAtoms = []
|
||||
for i in atoms:
|
||||
print i+" is valid?: "+str(checkAtom(i))
|
||||
if (checkAtom(i)): # FIXME: add the atom resolution --> kopete ==> kde-base/kopete
|
||||
if (checkAtom(i)):
|
||||
validAtoms.append(i)
|
||||
if validAtoms == []:
|
||||
print_error(red(bold("no valid package names specified.")))
|
||||
sys.exit(102)
|
||||
|
||||
# now that we've the list of the packages that we have to build
|
||||
|
||||
def overlay(options):
|
||||
# etpConst['overlaysconffile'] --> layman.cfg
|
||||
|
||||
# check if the portage tree is configured
|
||||
if (not os.path.isfile(etpConst['portagetreedir']+"/metadata/timestamp")):
|
||||
print_error(red(bold("Entropy Portage tree is not yet prepared. Use the 'sync' tool first.")))
|
||||
return False
|
||||
|
||||
# check if layman is installed
|
||||
layman = commands.getoutput("which layman")
|
||||
if (not layman.startswith("/")):
|
||||
print_error(red(bold("app-portage/layman is not installed. Please install.")))
|
||||
return False
|
||||
|
||||
myopts = options[1:]
|
||||
|
||||
# be verbose?
|
||||
verbosity = "> /dev/null"
|
||||
for x in myopts:
|
||||
if x.startswith("--verbose") or x.startswith("-v"):
|
||||
verbosity = None
|
||||
|
||||
# filter garbage
|
||||
_myopts = []
|
||||
for x in myopts:
|
||||
# --verbose, -v
|
||||
if (x != "--verbose" ) and (x != "-v" ):
|
||||
_myopts.append(x)
|
||||
myopts = _myopts
|
||||
|
||||
if (myopts == []):
|
||||
print_error(red(bold("not enough parameters.")))
|
||||
return False
|
||||
|
||||
# starting Test Case
|
||||
if (myopts[0] == "add"):
|
||||
# add overlay
|
||||
myownopts = list(set(myopts[1:]))
|
||||
for i in myownopts:
|
||||
print_info(green("adding overlay: ")+bold(i))
|
||||
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -f -a "+i, redirect = verbosity)
|
||||
if (rc != 0):
|
||||
print_warning(red(bold("a problem occoured adding "+i+" overlay.")))
|
||||
elif (myopts[0] == "remove"):
|
||||
# remove overlay
|
||||
myownopts = list(set(myopts[1:]))
|
||||
for i in myownopts:
|
||||
print_info(green("removing overlay: ")+bold(i))
|
||||
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -d "+i, redirect = verbosity)
|
||||
if (rc != 0):
|
||||
print_warning(red(bold("a problem occoured removing "+i+" overlay.")))
|
||||
return True
|
||||
elif (myopts[0] == "sync"):
|
||||
# sync an overlay
|
||||
myownopts = list(set(myopts[1:]))
|
||||
if (myownopts == []):
|
||||
# sync all
|
||||
print_info(green("syncing all the overlays")+bold(i))
|
||||
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -S ", redirect = verbosity)
|
||||
if (rc != 0):
|
||||
print_warning(red(bold("a problem occoured syncing all the overlays.")))
|
||||
else:
|
||||
# sync each overlay
|
||||
for i in myownopts:
|
||||
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -s "+i, redirect = verbosity)
|
||||
if (rc != 0):
|
||||
print_warning(red(bold("a problem occoured syncing "+i+" overlay.")))
|
||||
return True
|
||||
elif (myopts[0] == "list"):
|
||||
# add an overlay
|
||||
listing = listOverlays()
|
||||
if (listing == []):
|
||||
print_info(green("no overlays."))
|
||||
else:
|
||||
for i in listing:
|
||||
print_info(green(i)+" overlay is added.")
|
||||
else:
|
||||
# error !
|
||||
print_error(red(bold("wrong synthax.")))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user