code review done

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@861 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
(no author)
2007-12-13 19:37:17 +00:00
parent bf72d20b83
commit 64040fdb46
18 changed files with 287 additions and 333 deletions
+14 -14
View File
@@ -283,9 +283,9 @@ def scanfs(dcache = True):
if (dcache):
# can we load cache?
try:
c = loadcache()
if c != None:
return c
z = loadcache()
if z != None:
return z
except:
pass
@@ -305,22 +305,22 @@ def scanfs(dcache = True):
scanfile = True
for currentdir,subdirs,files in os.walk(path):
for file in files:
for item in files:
if (scanfile):
if path != file:
if path != item:
continue
filepath = currentdir+"/"+file
if file.startswith("._cfg"):
filepath = currentdir+"/"+item
if item.startswith("._cfg"):
# further check then
number = file[5:9]
number = item[5:9]
try:
int(number)
except:
continue # not a valid etc-update file
if file[9] != "_": # no valid format provided
if item[9] != "_": # no valid format provided
continue
mydict = generatedict(filepath)
@@ -370,10 +370,10 @@ def loadcache():
def generatedict(filepath):
file = os.path.basename(filepath)
item = os.path.basename(filepath)
currentdir = os.path.dirname(filepath)
tofile = file[10:]
number = file[5:9]
tofile = item[10:]
number = item[5:9]
try:
int(number)
except:
@@ -461,9 +461,9 @@ def confinfo():
print_info(yellow(" @@ ")+darkgreen("These are the files that would be updated:"))
data = scanfs(dcache = False)
counter = 0
for file in data:
for item in data:
counter += 1
print_info(" ("+blue(str(counter))+") "+"[auto:"+str(data[file]['automerge'])+"]"+red(" file: ")+file)
print_info(" ("+blue(str(counter))+") "+"[auto:"+str(data[item]['automerge'])+"]"+red(" file: ")+item)
print_info(red(" @@ ")+brown("Unique files that would be update:\t\t")+red(str(len(data))))
automerge = 0
for x in data:
+36 -34
View File
@@ -32,7 +32,6 @@ from databaseTools import openRepositoryDatabase, openClientDatabase, openGeneri
import triggerTools
import confTools
import dumpTools
import repositoriesTools
# Logging initialization
import logTools
@@ -123,13 +122,11 @@ def atomMatch(atom, caseSentitive = True, matchSlot = None, matchBranches = (),
return cached['result']
repoResults = {}
exitstatus = 0
exitErrors = {}
for repo in etpRepositories:
# sync database if not available
rc = fetchRepositoryIfNotAvailable(repo)
if (rc != 0):
exitstatus = -1
exitErrors[repo] = -1
continue
# open database
@@ -534,6 +531,7 @@ def generateDependencyTree(atomInfo, emptydeps = False, deepdeps = False, usefil
# check if atom has been already pulled in
matchdb = openRepositoryDatabase(match[1])
matchatom = matchdb.retrieveAtom(match[0])
matchslot = matchdb.retrieveSlot(match[0]) # used later
matchdb.closeDB()
del matchdb
if matchatom in treecache:
@@ -570,14 +568,14 @@ def generateDependencyTree(atomInfo, emptydeps = False, deepdeps = False, usefil
mybuffer.push((treedepth,x))
# handle possible library breakage
action = filterSatisfiedDependenciesCmpResults.get(mydep)
action = filterSatisfiedDependenciesCmpResults.get(mydep[1])
if action and ((action < 0) or (action > 0)): # do not use != 0 since action can be "None"
i = clientDbconn.atomMatch(mydep)
i = clientDbconn.atomMatch(dep_getkey(mydep[1]), matchSlot = matchslot)
if i[0] != -1:
oldneeded = clientDbconn.retrieveNeeded(i[0])
if oldneeded: # if there are needed
ndbconn = openRepositoryDatabase(atom[1])
needed = ndbconn.retrieveNeeded(atom[0])
ndbconn = openRepositoryDatabase(match[1])
needed = ndbconn.retrieveNeeded(match[0])
ndbconn.closeDB()
del ndbconn
oldneeded.difference_update(needed)
@@ -596,7 +594,7 @@ def generateDependencyTree(atomInfo, emptydeps = False, deepdeps = False, usefil
mynewatom = mydbconn.retrieveAtom(mymatch[0])
mydbconn.closeDB()
del mydbconn
if (mymatch not in matchcache) and (mynewatom not in treecache):
if (mymatch not in matchcache) and (mynewatom not in treecache) and (mymatch not in matchFilter):
mybuffer.push((treedepth,mynewatom))
else:
# we bastardly ignore the missing library for now
@@ -864,7 +862,7 @@ def fetchFileOnMirrors(repository, filename, digest = False):
# check if uri is sane
if getFailingMirrorStatus(uri) >= 30:
# ohohoh!
etpRemoteFailures[mirrorname] = 30 # set to 30 for convenience
etpRemoteFailures[uri] = 30 # set to 30 for convenience
print_warning(red(" ## ")+mirrorCountText+blue(" Mirror: ")+red(spliturl(url)[1])+" - maximum failure threshold reached.")
if getFailingMirrorStatus(uri) == 30:
addFailingMirror(uri,45) # put to 75 then decrement by 4 so we won't reach 30 anytime soon ahahaha
@@ -874,7 +872,7 @@ def fetchFileOnMirrors(repository, filename, digest = False):
addFailingMirror(uri,-4)
else:
# put to 0 - reenable mirror, welcome back uri!
etpRemoteFailures[mirrorname] = 0
etpRemoteFailures[uri] = 0
remaining.remove(uri)
continue
@@ -908,7 +906,7 @@ def fetchFileOnMirrors(repository, filename, digest = False):
@input package: url -> HTTP/FTP url, digest -> md5 hash of the file
@output: -1 = download error (cannot find the file), -2 = digest error, 0 = all fine
'''
def fetchFile(url, digest = False):
def fetchFile(url, digest = None):
# remove old
filename = os.path.basename(url)
filepath = etpConst['packagesbindir']+"/"+etpConst['branch']+"/"+filename
@@ -928,7 +926,7 @@ def fetchFile(url, digest = False):
return -1
if fetchChecksum == "-3":
return -3
if (digest != False):
if (digest):
#print digest+" <--> "+fetchChecksum
if (fetchChecksum != digest):
# not properly downloaded
@@ -989,31 +987,31 @@ def removePackage(infoDict):
# remove files from system
directories = set()
for file in content:
for item in content:
# collision check
if etpConst['collisionprotect'] > 0:
if clientDbconn.isFileAvailable(file) and os.path.isfile(etpConst['systemroot']+file): # in this way we filter out directories
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("Collision found during remove of ")+etpConst['systemroot']+file+red(" - cannot overwrite"))
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Collision found during remove of "+etpConst['systemroot']+file+" - cannot overwrite")
if clientDbconn.isFileAvailable(item) and os.path.isfile(etpConst['systemroot']+item): # in this way we filter out directories
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("Collision found during remove of ")+etpConst['systemroot']+item+red(" - cannot overwrite"))
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Collision found during remove of "+etpConst['systemroot']+item+" - cannot overwrite")
continue
protected = False
if (not infoDict['removeconfig']) and (not infoDict['diffremoval']):
try:
# -- CONFIGURATION FILE PROTECTION --
if os.access(etpConst['systemroot']+file,os.R_OK):
if os.access(etpConst['systemroot']+item,os.R_OK):
for x in protect:
if etpConst['systemroot']+file.startswith(x):
if etpConst['systemroot']+item.startswith(x):
protected = True
break
if (protected):
for x in mask:
if etpConst['systemroot']+file.startswith(x):
if etpConst['systemroot']+item.startswith(x):
protected = False
break
if (protected) and os.path.isfile(etpConst['systemroot']+file):
protected = istextfile(etpConst['systemroot']+file)
if (protected) and os.path.isfile(etpConst['systemroot']+item):
protected = istextfile(etpConst['systemroot']+item)
else:
protected = False # it's not a file
# -- CONFIGURATION FILE PROTECTION --
@@ -1022,32 +1020,32 @@ def removePackage(infoDict):
if (protected):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"[remove] Protecting config file: "+etpConst['systemroot']+file)
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("[remove] Protecting config file: ")+etpConst['systemroot']+file)
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"[remove] Protecting config file: "+etpConst['systemroot']+item)
if not etpUi['quiet']: print_warning(darkred(" ## ")+red("[remove] Protecting config file: ")+etpConst['systemroot']+item)
else:
try:
os.lstat(etpConst['systemroot']+file)
os.lstat(etpConst['systemroot']+item)
except OSError:
continue # skip file, does not exist
except UnicodeEncodeError:
print_warning(darkred(" ## ")+red("QA: ")+brown("this package contains a badly encoded file"))
continue # file has a really bad encoding
if os.path.isdir(etpConst['systemroot']+file) and os.path.islink(etpConst['systemroot']+file): # S_ISDIR returns False for directory symlinks, so using os.path.isdir
if os.path.isdir(etpConst['systemroot']+item) and os.path.islink(etpConst['systemroot']+item): # S_ISDIR returns False for directory symlinks, so using os.path.isdir
# valid directory symlink
#print "symlink dir",file
directories.add((etpConst['systemroot']+file,"link"))
elif os.path.isdir(etpConst['systemroot']+file):
directories.add((etpConst['systemroot']+item,"link"))
elif os.path.isdir(etpConst['systemroot']+item):
# plain directory
#print "plain dir",file
directories.add((etpConst['systemroot']+file,"dir"))
directories.add((etpConst['systemroot']+item,"dir"))
else: # files, symlinks or not
# just a file or symlink or broken directory symlink (remove now)
try:
#print "plain file",file
os.remove(etpConst['systemroot']+file)
os.remove(etpConst['systemroot']+item)
# add its parent directory
dirfile = os.path.dirname(etpConst['systemroot']+file)
dirfile = os.path.dirname(etpConst['systemroot']+item)
if os.path.isdir(dirfile) and os.path.islink(dirfile):
#print "symlink dir2",dirfile
directories.add((dirfile,"link"))
@@ -1180,9 +1178,9 @@ def moveImageToSystem(imageDir, protect, mask):
# merge data into system
for currentdir,subdirs,files in os.walk(imageDir):
# create subdirs
for dir in subdirs:
for subdir in subdirs:
imagepathDir = currentdir + "/" + dir
imagepathDir = currentdir + "/" + subdir
rootdir = etpConst['systemroot']+imagepathDir[len(imageDir):]
#print rootdir
@@ -1214,8 +1212,8 @@ def moveImageToSystem(imageDir, protect, mask):
os.chown(rootdir,user,group)
shutil.copystat(imagepathDir,rootdir)
for file in files:
fromfile = currentdir+"/"+file
for item in files:
fromfile = currentdir+"/"+item
tofile = etpConst['systemroot']+fromfile[len(imageDir):]
#print tofile
@@ -1593,6 +1591,7 @@ def stepExecutor(step, infoDict, loopString = None):
for trigger in triggers: # code reuse, we'll fetch triggers list on the GUI client and run each trigger by itself
if trigger not in etpUi['postinstall_triggers_disable']:
eval("triggerTools."+trigger)(pkgdata)
del pkgdata
elif step == "preinstall":
# analyze atom
@@ -1602,6 +1601,7 @@ def stepExecutor(step, infoDict, loopString = None):
for trigger in triggers: # code reuse, we'll fetch triggers list on the GUI client and run each trigger by itself
if trigger not in etpUi['preinstall_triggers_disable']:
eval("triggerTools."+trigger)(pkgdata)
del pkgdata
elif step == "preremove":
# analyze atom
@@ -1618,6 +1618,7 @@ def stepExecutor(step, infoDict, loopString = None):
for trigger in triggers: # code reuse, we'll fetch triggers list on the GUI client and run each trigger by itself
if trigger not in etpUi['preremove_triggers_disable']:
eval("triggerTools."+trigger)(remdata)
del remdata
elif step == "postremove":
# analyze atom
@@ -1634,6 +1635,7 @@ def stepExecutor(step, infoDict, loopString = None):
for trigger in triggers: # code reuse, we'll fetch triggers list on the GUI client and run each trigger by itself
if trigger not in etpUi['postremove_triggers_disable']:
eval("triggerTools."+trigger)(remdata)
del remdata
clientDbconn.closeDB()
del clientDbconn
+4 -4
View File
@@ -112,7 +112,7 @@ def getRepositoryRevision(reponame):
def getOnlineRepositoryRevision(reponame):
url = etpRepositories[reponame]['database']+"/"+etpConst['etpdatabaserevisionfile']
status = getOnlineContent(url)
if (status != False):
if (status):
status = status[0].strip()
return int(status)
else:
@@ -147,7 +147,7 @@ def syncRepositories(reponames = [], forceUpdate = False):
repoNumber = 0
syncErrors = False
if (reponames == []):
if (not reponames):
for x in etpRepositories:
reponames.append(x)
@@ -155,7 +155,7 @@ def syncRepositories(reponames = [], forceUpdate = False):
# Test network connectivity
conntest = getOnlineContent("http://svn.sabayonlinux.org")
if conntest == False:
if not conntest:
print_info(darkred(" @@ ")+darkgreen("You are not connected to the Internet. You should."))
return 2
@@ -172,7 +172,7 @@ def syncRepositories(reponames = [], forceUpdate = False):
onlinestatus = getOnlineRepositoryRevision(repo)
if (onlinestatus != -1):
localstatus = getRepositoryRevision(repo)
if (localstatus == onlinestatus) and (forceUpdate == False):
if (localstatus == onlinestatus) and (not forceUpdate):
if (not etpUi['quiet']):
print_info(bold("\tAttention: ")+red("database is already up to date."))
continue
+6 -9
View File
@@ -104,8 +104,6 @@ def database(options):
portagePackages = portageTools.getInstalledPackages()
portagePackages = portagePackages[0]
appdb = portageTools.getPortageAppDbPath()
# do for each database
maxcount = str(len(portagePackages))
count = 0
@@ -209,10 +207,10 @@ def database(options):
f = open(etpConst['packagestmpfile'],"r")
# creating list of files
filelist = set()
file = f.readline().strip()
while file:
filelist.add(file)
file = f.readline().strip()
item = f.readline().strip()
while item:
filelist.add(item)
item = f.readline().strip()
f.close()
entries = len(filelist)
@@ -233,8 +231,8 @@ def database(options):
print_info(" ("+str(cnt)+"/"+count+")"+red(" Matching files from packages..."), back = True)
# content
content = dbconn.retrieveContent(idpackage)
for file in content:
if etpConst['systemroot']+file in filelist:
for item in content:
if etpConst['systemroot']+item in filelist:
pkgsfound.add((idpackage,repo))
atoms[(idpackage,repo)] = idpackageatom
filelist.difference_update(set([etpConst['systemroot']+x for x in content]))
@@ -308,7 +306,6 @@ def database(options):
installedPackages = getInstalledPackagesCounters()
print_info(red(" Collecting Entropy packages..."), back = True)
installedCounters = set()
databasePackages = clientDbconn.listAllPackages()
toBeAdded = set()
toBeRemoved = set()
+52 -49
View File
@@ -27,6 +27,7 @@ from entropyConstants import *
import entropyTools
# Logging initialization
import logTools
import shutil
equoLog = logTools.LogFile(level = etpConst['equologlevel'],filename = etpConst['equologfile'], header = "[Equo]")
'''
@@ -248,6 +249,8 @@ def call_ext_generic(pkgdata, stage):
f.write(x)
f.close()
my_ext_status = 0
execfile(triggerfile)
os.remove(triggerfile)
@@ -287,28 +290,28 @@ def gccswitch(pkgdata):
def iconscache(pkgdata):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Updating icons cache...")
print_info(red(" ##")+brown(" Updating icons cache..."))
for file in pkgdata['content']:
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/usr/share/icons") and file.endswith("index.theme"):
cachedir = os.path.dirname(file)
for item in pkgdata['content']:
item = etpConst['systemroot']+item
if item.startswith(etpConst['systemroot']+"/usr/share/icons") and item.endswith("index.theme"):
cachedir = os.path.dirname(item)
generate_icons_cache(cachedir)
def mimeupdate(pkgdata):
def mimeupdate(pkgdata = None):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Updating shared mime info database...")
print_info(red(" ##")+brown(" Updating shared mime info database..."))
update_mime_db()
def mimedesktopupdate(pkgdata):
def mimedesktopupdate(pkgdata = None):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Updating desktop mime database...")
print_info(red(" ##")+brown(" Updating desktop mime database..."))
update_mime_desktop_db()
def scrollkeeper(pkgdata):
def scrollkeeper(pkgdata = None):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Updating scrollkeeper database...")
print_info(red(" ##")+brown(" Updating scrollkeeper database..."))
update_scrollkeeper_db()
def gconfreload(pkgdata):
def gconfreload(pkgdata = None):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Reloading GConf2 database...")
print_info(red(" ##")+brown(" Reloading GConf2 database..."))
reload_gconf_db()
@@ -330,10 +333,10 @@ def kernelmod(pkgdata):
print_info(red(" ##")+brown(" Running depmod..."))
# get kernel modules dir name
name = ''
for file in pkgdata['content']:
file = etpConst['systemroot']+file
for item in pkgdata['content']:
item = etpConst['systemroot']+item
if file.startswith(etpConst['systemroot']+"/lib/modules/"):
name = file[len(etpConst['systemroot']):]
name = item[len(etpConst['systemroot']):]
name = name.split("/")[3]
break
if name:
@@ -350,37 +353,37 @@ def sqliteinst(pkgdata):
sqlite_update_symlink()
def initdisable(pkgdata):
for file in pkgdata['removecontent']:
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(file):
for item in pkgdata['removecontent']:
item = etpConst['systemroot']+item
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(item):
# running?
running = os.path.isfile(etpConst['systemroot']+INITSERVICES_DIR+'/started/'+os.path.basename(file))
running = os.path.isfile(etpConst['systemroot']+INITSERVICES_DIR+'/started/'+os.path.basename(item))
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
scheduled = not os.system('ROOT="'+myroot+'" rc-update show | grep '+os.path.basename(file)+'&> /dev/null')
initdeactivate(file, running, scheduled)
scheduled = not os.system('ROOT="'+myroot+'" rc-update show | grep '+os.path.basename(item)+'&> /dev/null')
initdeactivate(item, running, scheduled)
def initinform(pkgdata):
for file in pkgdata['content']:
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and not os.path.isfile(etpConst['systemroot']+file):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[PRE] A new service will be installed: "+file)
print_info(red(" ##")+brown(" A new service will be installed: ")+file)
for item in pkgdata['content']:
item = etpConst['systemroot']+item
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and not os.path.isfile(etpConst['systemroot']+item):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[PRE] A new service will be installed: "+item)
print_info(red(" ##")+brown(" A new service will be installed: ")+item)
def removeinit(pkgdata):
for file in pkgdata['removecontent']:
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(file):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Removing boot service: "+os.path.basename(file))
print_info(red(" ##")+brown(" Removing boot service: ")+os.path.basename(file))
for item in pkgdata['removecontent']:
item = etpConst['systemroot']+item
if file.startswith(etpConst['systemroot']+"/etc/init.d/") and os.path.isfile(item):
equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"[POST] Removing boot service: "+os.path.basename(item))
print_info(red(" ##")+brown(" Removing boot service: ")+os.path.basename(item))
if not etpConst['systemroot']:
myroot = "/"
else:
myroot = etpConst['systemroot']+"/"
try:
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(file)+' &> /dev/null')
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(item)+' &> /dev/null')
except:
pass
@@ -512,11 +515,11 @@ def gconfinstallschemas(pkgdata):
def pygtksetup(pkgdata):
python_sym_files = [x for x in pkgdata['content'] if x.endswith("pygtk.py-2.0") or x.endswith("pygtk.pth-2.0")]
for file in python_sym_files:
file = etpConst['systemroot']+file
for item in python_sym_files:
item = etpConst['systemroot']+item
filepath = file[:-4]
sympath = os.path.basename(file)
if os.path.isfile(file):
sympath = os.path.basename(item)
if os.path.isfile(item):
try:
if os.path.lexists(filepath):
os.remove(filepath)
@@ -526,10 +529,10 @@ def pygtksetup(pkgdata):
def pygtkremove(pkgdata):
python_sym_files = [x for x in pkgdata['content'] if x.startswith("/usr/lib/python") and (x.endswith("pygtk.py-2.0") or x.endswith("pygtk.pth-2.0"))]
for file in python_sym_files:
file = etpConst['systemroot']+file
if os.path.isfile(file[:-4]):
os.remove(file[:-4])
for item in python_sym_files:
item = etpConst['systemroot']+item
if os.path.isfile(item[:-4]):
os.remove(item[:-4])
def susetuid(pkgdata):
if os.path.isfile(etpConst['systemroot']+"/bin/su"):
@@ -540,22 +543,22 @@ def susetuid(pkgdata):
def cleanpy(pkgdata):
pyfiles = [x for x in pkgdata['content'] if x.endswith(".py")]
for file in pyfiles:
file = etpConst['systemroot']+file
if os.path.isfile(file+"o"):
try: os.remove(file+"o")
for item in pyfiles:
item = etpConst['systemroot']+item
if os.path.isfile(item+"o"):
try: os.remove(item+"o")
except OSError: pass
if os.path.isfile(file+"c"):
try: os.remove(file+"c")
if os.path.isfile(item+"c"):
try: os.remove(item+"c")
except OSError: pass
def createkernelsym(pkgdata):
for file in pkgdata['content']:
file = etpConst['systemroot']+file
if file.startswith(etpConst['systemroot']+"/usr/src/"):
for item in pkgdata['content']:
item = etpConst['systemroot']+item
if item.startswith(etpConst['systemroot']+"/usr/src/"):
# extract directory
try:
todir = file[len(etpConst['systemroot']):]
todir = item[len(etpConst['systemroot']):]
todir = todir.split("/")[3]
except:
continue
@@ -834,17 +837,17 @@ def sqlite_update_symlink():
@description: shuts down selected init script, and remove from runlevel
@output: returns int() as exit status
'''
def initdeactivate(file, running, scheduled):
def initdeactivate(item, running, scheduled):
if not etpConst['systemroot']:
myroot = "/"
if (running):
os.system(file+' stop --quiet')
os.system(item+' stop --quiet')
else:
myroot = etpConst['systemroot']+"/"
if (scheduled):
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(file))
os.system('ROOT="'+myroot+'" rc-update del '+os.path.basename(item))
return 0
+11 -16
View File
@@ -29,7 +29,6 @@ from entropyConstants import *
from clientConstants import *
from outputTools import *
import equoTools
import repositoriesTools
from databaseTools import openRepositoryDatabase, openClientDatabase, openGenericDatabase, listAllAvailableBranches
import entropyTools
import dumpTools
@@ -45,7 +44,6 @@ def package(options):
# Options available for all the packages submodules
myopts = options[1:]
equoRequestPackagesCheck = False
equoRequestDeps = True
equoRequestEmptyDeps = False
equoRequestOnlyFetch = False
@@ -365,7 +363,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
# read all idpackages
try:
myidpackages = mydbconn.listAllIdpackages() # all branches admitted from external files
except DatabaseError:
except:
if not (etpUi['quiet'] or returnQueue): print_warning(red("## ATTENTION:")+bold(" "+basefile+" ")+red(" is not a valid Entropy package. Skipping..."))
del etpRepositories[basefile]
if returnQueue:
@@ -437,13 +435,13 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
if installedVer == "Not installed":
installedVer = "0"
if installedTag == "NoTag":
installedTag == ''
installedTag = ''
if installedRev == "NoRev":
installedRev == 0
cmp = entropyTools.entropyCompareVersions((pkgver,pkgtag,pkgrev),(installedVer,installedTag,installedRev))
if (cmp == 0):
installedRev = 0
pkgcmp = entropyTools.entropyCompareVersions((pkgver,pkgtag,pkgrev),(installedVer,installedTag,installedRev))
if (pkgcmp == 0):
action = darkgreen("No update needed")
elif (cmp > 0):
elif (pkgcmp > 0):
if (installedVer == "0"):
action = darkgreen("Install")
else:
@@ -545,8 +543,6 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
pkgrev = mydata[18]
pkgslot = mydata[14]
pkgfile = mydata[12]
pkgcat = mydata[5]
pkgname = mydata[1]
onDiskUsedSize += dbconn.retrieveOnDiskSize(packageInfo[0]) # still new
@@ -580,13 +576,13 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
action = 0
flags = " ["
cmp = entropyTools.entropyCompareVersions((pkgver,pkgtag,pkgrev),(installedVer,installedTag,installedRev))
if (cmp == 0):
pkgcmp = entropyTools.entropyCompareVersions((pkgver,pkgtag,pkgrev),(installedVer,installedTag,installedRev))
if (pkgcmp == 0):
pkgsToReinstall += 1
actionQueue[pkgatom]['removeidpackage'] = -1 # disable removal, not needed
flags += red("R")
action = 1
elif (cmp > 0):
elif (pkgcmp > 0):
if (installedVer == "0"):
pkgsToInstall += 1
actionQueue[pkgatom]['removeidpackage'] = -1 # disable removal, not needed
@@ -1173,7 +1169,6 @@ def dependenciesTest(clientDbconn = None, reagent = False):
# get all the installed packages
installedPackages = clientDbconn.listAllIdpackages()
depsNotFound = {}
depsNotSatisfied = {}
# now look
length = str((len(installedPackages)))
@@ -1301,8 +1296,8 @@ def librariesTest(clientDbconn = None, reagent = False, listfiles = False):
if not etpUi['quiet']: print_info(" ["+str((round(float(count)/total*100,1)))+"%] "+blue("Tree: ")+red(etpConst['systemroot']+ldpath), back = True)
ldpath = ldpath.encode(sys.getfilesystemencoding())
for currentdir,subdirs,files in os.walk(etpConst['systemroot']+ldpath):
for file in files:
filepath = currentdir+"/"+file
for item in files:
filepath = currentdir+"/"+item
if os.access(filepath,os.X_OK):
executables.add(filepath[len(etpConst['systemroot']):])
+31 -47
View File
@@ -270,8 +270,10 @@ class etpDatabase:
print_info(red(" * ")+bold("WARNING")+red(": online database is already locked. Waiting up to 2 minutes..."), back = True)
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"etpDatabase: online database already locked. Waiting 2 minutes")
unlocked = False
for x in range(120):
count = 120
while count:
time.sleep(1)
count -= 1
if (not ftp.isFileAvailable(etpConst['etpdatabaselockfile'])):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"etpDatabase: online database has been unlocked !")
print_info(red(" * ")+bold("HOORAY")+red(": online database has been unlocked. Locking back and syncing..."))
@@ -319,7 +321,6 @@ class etpDatabase:
#self.connection.rollback()
self.cursor.close()
self.connection.close()
del self
return
# if it's equo that's calling the function, just save changes and quit
@@ -328,7 +329,6 @@ class etpDatabase:
self.commitChanges()
self.cursor.close()
self.connection.close()
del self
return
# Cleanups if at least one package has been removed
@@ -364,7 +364,6 @@ class etpDatabase:
self.cursor.close()
self.connection.close()
del self
def commitChanges(self):
if (not self.readOnly):
@@ -600,14 +599,14 @@ class etpDatabase:
)
# content, a list
for file in etpData['content']:
contenttype = etpData['content'][file]
for xfile in etpData['content']:
contenttype = etpData['content'][xfile]
try:
self.cursor.execute(
'INSERT into content VALUES '
'(?,?,?)'
, ( idpackage,
file,
xfile,
contenttype,
)
)
@@ -617,7 +616,7 @@ class etpDatabase:
'INSERT into content VALUES '
'(?,?,?)'
, ( idpackage,
file,
xfile,
contenttype,
)
)
@@ -1250,16 +1249,16 @@ class etpDatabase:
return myneeded
raise Exception, "I tried to insert a needed library but then, fetching it returned -1. There's something broken."
def addLicense(self,license):
if not license:
license = ' ' # workaround for broken license entries
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addLicense: adding License -> "+str(license))
def addLicense(self,pkglicense):
if not pkglicense:
pkglicense = ' ' # workaround for broken license entries
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addLicense: adding License -> "+str(pkglicense))
self.cursor.execute(
'INSERT into licenses VALUES '
'(NULL,?)', (license,)
'(NULL,?)', (pkglicense,)
)
# get info about inserted value and return
lic = self.isLicenseAvailable(license)
lic = self.isLicenseAvailable(pkglicense)
if lic != -1:
return lic
raise Exception, "I tried to insert a license but then, fetching it returned -1. There's something broken."
@@ -1330,9 +1329,6 @@ class etpDatabase:
for idflag in orphanedFlags:
self.cursor.execute('DELETE FROM useflagsreference WHERE idflag ='+str(idflag))
# empty cursor
x = self.cursor.fetchall()
def cleanupSources(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupSources: called.")
@@ -1365,9 +1361,6 @@ class etpDatabase:
for idsource in orphanedSources:
self.cursor.execute('DELETE FROM sourcesreference WHERE idsource = '+str(idsource))
# empty cursor
x = self.cursor.fetchall()
def cleanupEclasses(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupEclasses: called.")
@@ -1400,9 +1393,6 @@ class etpDatabase:
for idclass in orphanedClasses:
self.cursor.execute('DELETE FROM eclassesreference WHERE idclass = '+str(idclass))
# empty cursor
x = self.cursor.fetchall()
def cleanupNeeded(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupNeeded: called.")
@@ -1435,8 +1425,7 @@ class etpDatabase:
for idneeded in orphanedNeededs:
self.cursor.execute('DELETE FROM neededreference WHERE idneeded = '+str(idneeded))
# empty cursor
x = self.cursor.fetchall()
def cleanupDependencies(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupDependencies: called.")
@@ -1469,8 +1458,6 @@ class etpDatabase:
for iddep in orphanedDeps:
self.cursor.execute('DELETE FROM dependenciesreference WHERE iddependency = '+str(iddep))
# empty cursor
x = self.cursor.fetchall()
def getIDPackage(self, atom, branch = etpConst['branch']):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getIDPackage: retrieving package ID for "+atom+" | branch: "+branch)
@@ -1514,7 +1501,7 @@ class etpDatabase:
return idcat
def getIDPackageFromBinaryPackage(self,packageName):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getIDPackageFromBinaryPackage: retrieving package ID for "+atom+" | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getIDPackageFromBinaryPackage: retrieving package ID for "+packageName)
self.cursor.execute('SELECT "IDPACKAGE" FROM baseinfo WHERE download = "'+etpConst['binaryurirelativepath']+packageName+'"')
idpackage = -1
for row in self.cursor:
@@ -2385,16 +2372,16 @@ class etpDatabase:
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isCounterAvailable: "+str(counter)+" not available.")
return result
def isLicenseAvailable(self,license):
def isLicenseAvailable(self,pkglicense):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isLicenseAvailable: called.")
if not license: # workaround for packages without a license but just garbage
license = ' '
self.cursor.execute('SELECT idlicense FROM licenses WHERE license = (?)', (license,))
if not pkglicense: # workaround for packages without a license but just garbage
pkglicense = ' '
self.cursor.execute('SELECT idlicense FROM licenses WHERE license = (?)', (pkglicense,))
result = self.cursor.fetchone()
if not result:
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"isLicenseAvailable: "+license+" not available.")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"isLicenseAvailable: "+pkglicense+" not available.")
return -1
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isLicenseAvailable: "+license+" available.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isLicenseAvailable: "+pkglicense+" available.")
return result[0]
def isSystemPackage(self,idpackage):
@@ -2903,9 +2890,7 @@ class etpDatabase:
self.cursor.execute('UPDATE baseinfo SET branch = (?) WHERE idpackage = (?)', (tobranch,idpackage,))
self.cursor.execute('UPDATE extrainfo SET download = (?) WHERE idpackage = (?)', (newdownload,idpackage,))
self.commitChanges()
# clean cursor - NEEDED?
for row in self.cursor:
x = row
########################################################
@@ -2980,15 +2965,14 @@ class etpDatabase:
self.commitChanges()
def isDependsTableSane(self):
sane = True
try:
self.cursor.execute('SELECT iddependency FROM dependstable WHERE iddependency = -1')
except:
return False # table does not exist, please regenerate and re-run
for row in self.cursor:
sane = False
break
return sane
status = self.cursor.fetchone()[0]
if status:
return False
return True
def createXpakTable(self):
self.cursor.execute('CREATE TABLE xpakdata ( idpackage INTEGER PRIMARY KEY, data BLOB );')
@@ -3543,21 +3527,21 @@ class etpDatabase:
for data in foundIDs:
idpackage = data[1]
dbver = self.retrieveVersion(idpackage)
cmp = entropyTools.compareVersions(pkgversion,dbver)
pkgcmp = entropyTools.compareVersions(pkgversion,dbver)
if direction == ">": # the --deep mode should really act on this
if (cmp < 0):
if (pkgcmp < 0):
# found
dbpkginfo.append([idpackage,dbver])
elif direction == "<":
if (cmp > 0):
if (pkgcmp > 0):
# found
dbpkginfo.append([idpackage,dbver])
elif direction == ">=": # the --deep mode should really act on this
if (cmp <= 0):
if (pkgcmp <= 0):
# found
dbpkginfo.append([idpackage,dbver])
elif direction == "<=":
if (cmp >= 0):
if (pkgcmp >= 0):
# found
dbpkginfo.append([idpackage,dbver])
+71 -73
View File
@@ -25,7 +25,7 @@ from outputTools import *
from entropyConstants import *
import os
import re
from sys import exit, stdout, getfilesystemencoding
import sys
import threading, time, tarfile
# Logging initialization
@@ -35,7 +35,6 @@ entropyLog = logTools.LogFile(level=etpConst['entropyloglevel'],filename = etpCo
global __etp_debug
__etp_debug = False
def enableDebug():
__etp_debug = True
import pdb
pdb.set_trace()
@@ -68,7 +67,7 @@ def applicationLockCheck(option = None, gentle = False):
print_error(red("Another instance of Equo is running. Action: ")+bold(str(option))+red(" denied."))
print_error(red("If I am lying (maybe). Please remove ")+bold(etpConst['pidfile']))
if (not gentle):
exit(10)
sys.exit(10)
else:
return True
return False
@@ -80,12 +79,12 @@ def getRandomNumber():
def countdown(secs=5,what="Counting...", back = False):
if secs:
if back:
stdout.write(red(">> ")+what)
sys.stdout.write(red(">> ")+what)
else:
print what
for i in range(secs)[::-1]:
stdout.write(red(str(i+1)+" "))
stdout.flush()
sys.stdout.write(red(str(i+1)+" "))
sys.stdout.flush()
time.sleep(1)
def spinner(rotations, interval, message=''):
@@ -109,26 +108,26 @@ def md5sum(filepath):
def unpackGzip(gzipfilepath):
import gzip
filepath = gzipfilepath[:-3] # remove .gz
file = open(filepath,"wb")
item = open(filepath,"wb")
filegz = gzip.GzipFile(gzipfilepath,"rb")
filecont = filegz.readlines()
filegz.close()
file.writelines(filecont)
file.flush()
file.close()
item.writelines(filecont)
item.flush()
item.close()
del filecont
return filepath
def unpackBzip2(bzip2filepath):
import bz2
filepath = bzip2filepath[:-4] # remove .gz
file = open(filepath,"wb")
item = open(filepath,"wb")
filebz2 = bz2.BZ2File(bzip2filepath,"rb")
filecont = filebz2.readlines()
filebz2.close()
file.writelines(filecont)
file.flush()
file.close()
item.writelines(filecont)
item.flush()
item.close()
del filecont
return filepath
@@ -633,7 +632,6 @@ def dep_getcpv(mydep):
if cached != None:
return cached
mydep_orig = mydep
if mydep and mydep[0] == "*":
mydep = mydep[1:]
if mydep and mydep[-1] == "*":
@@ -756,7 +754,7 @@ ver_regexp = re.compile("^(cvs\\.)?(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alph
suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
def compareVersions(ver1, ver2, silent=1):
def compareVersions(ver1, ver2):
cached = compareVersionsCache.get(tuple([ver1,ver2]))
if cached != None:
@@ -765,7 +763,7 @@ def compareVersions(ver1, ver2, silent=1):
if ver1 == ver2:
compareVersionsCache[tuple([ver1,ver2])] = 0
return 0
mykey=ver1+":"+ver2
#mykey=ver1+":"+ver2
match1 = ver_regexp.match(ver1)
match2 = ver_regexp.match(ver2)
@@ -930,6 +928,7 @@ def getNewerVersionTag(InputVersionlist):
def isnumber(x):
try:
t = int(x)
del t
return True
except:
return False
@@ -963,8 +962,8 @@ def istext(s):
# nameslist: a list that contains duplicated names
# @returns filtered list
def filterDuplicatedEntries(alist):
set = {}
return [set.setdefault(e,e) for e in alist if e not in set]
mydata = {}
return [mydata.setdefault(e,e) for e in alist if e not in mydata]
# Escapeing functions
@@ -987,18 +986,18 @@ def escape_single(x):
return escape(x)
if type(x)==type(""):
tmpstr=''
for c in range(len(x)):
if x[c] in mappings.keys():
if x[c] in ("'", '"'):
if c+1<len(x):
if x[c+1]!=x[c]:
tmpstr+=mappings[x[c]]
for d in range(len(x)):
if x[d] in mappings.keys():
if x[d] in ("'", '"'):
if d+1<len(x):
if x[d+1]!=x[d]:
tmpstr+=mappings[x[d]]
else:
tmpstr+=mappings[x[c]]
tmpstr+=mappings[x[d]]
else:
tmpstr+=mappings[x[c]]
tmpstr+=mappings[x[d]]
else:
tmpstr+=x[c]
tmpstr+=x[d]
else:
tmpstr=x
return tmpstr
@@ -1024,8 +1023,8 @@ def extractDuplicatedEntries(inputlist):
mycache = {}
newlist = set()
for x in inputlist:
c = mycache.get(x)
if c:
z = mycache.get(x)
if z:
newlist.add(x)
continue
mycache[x] = 1
@@ -1084,14 +1083,14 @@ def uncompressTarBz2(filepath, extractPath = None, catchEmpty = False):
directories.append(tarinfo)
else:
try:
tarinfo.name = tarinfo.name.encode(getfilesystemencoding())
tarinfo.name = tarinfo.name.encode(sys.getfilesystemencoding())
except: # default encoding failed
try:
tarinfo.name = tarinfo.name.decode("latin1") # try to convert to latin1 and then back to sys.getfilesystemencoding()
tarinfo.name = tarinfo.name.encode(getfilesystemencoding())
tarinfo.name = tarinfo.name.encode(sys.getfilesystemencoding())
except:
raise
tar.extract(tarinfo, extractPath.encode(getfilesystemencoding()))
tar.extract(tarinfo, extractPath.encode(sys.getfilesystemencoding()))
# Reverse sort directories.
directories.sort(lambda a, b: cmp(a.name, b.name))
@@ -1105,7 +1104,7 @@ def uncompressTarBz2(filepath, extractPath = None, catchEmpty = False):
tar.chown(tarinfo, extractPath)
tar.utime(tarinfo, extractPath)
tar.chmod(tarinfo, extractPath)
except tarfile.ExtractError, e:
except tarfile.ExtractError:
if tar.errorlevel > 1:
raise
@@ -1155,18 +1154,18 @@ def getFileTimeStamp(path):
# format properly
humantime = str(humantime)
outputtime = ""
for chr in humantime:
if chr != "-" and chr != " " and chr != ":":
outputtime += chr
for char in humantime:
if char != "-" and char != " " and char != ":":
outputtime += char
return outputtime
def convertUnixTimeToMtime(unixtime):
from datetime import datetime
humantime = str(datetime.fromtimestamp(unixtime))
outputtime = ""
for chr in humantime:
if chr != "-" and chr != " " and chr != ":":
outputtime += chr
for char in humantime:
if char != "-" and char != " " and char != ":":
outputtime += char
return outputtime
def convertUnixTimeToHumanTime(unixtime):
@@ -1178,19 +1177,19 @@ def convertUnixTimeToHumanTime(unixtime):
def alphaSorter(seq):
def stripter(s, goodchrs):
badchrs = set(s)
for c in goodchrs:
if c in badchrs:
badchrs.remove(c)
for d in goodchrs:
if d in badchrs:
badchrs.remove(d)
badchrs = ''.join(badchrs)
return s.strip(badchrs)
def chr_index(value, sortorder):
result = []
for c in stripter(value, order):
cindex = sortorder.find(c)
if cindex == -1:
cindex = len(sortorder)+ord(c)
result.append(cindex)
for d in stripter(value, order):
dindex = sortorder.find(d)
if dindex == -1:
dindex = len(sortorder)+ord(d)
result.append(dindex)
return result
order = ( '0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz' )
@@ -1255,7 +1254,7 @@ def askquestion(prompt):
except (EOFError, KeyboardInterrupt):
print "Interrupted."
xtermTitleReset()
exit(100)
sys.exit(100)
xtermTitleReset()
class lifobuffer:
@@ -1315,7 +1314,7 @@ def quickpkg(pkgdata, dirpath, edb = True, portdbPath = None, fake = False, comp
if pkgdata['versiontag']: pkgtag = "#"+pkgdata['versiontag']
pkgname = pkgdata['name']+"-"+pkgdata['version']+pkgrev+pkgtag # + version + tag
pkgcat = pkgdata['category']
pkgfile = pkgname+".tbz2"
#pkgfile = pkgname+".tbz2"
dirpath += "/"+pkgname+".tbz2"
if os.path.isfile(dirpath):
os.remove(dirpath)
@@ -1569,10 +1568,10 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
i = list(i)
datatype = i[1]
try:
i[0] = i[0].encode(getfilesystemencoding())
i[0] = i[0].encode(sys.getfilesystemencoding())
except: # default encoding failed
try:
i[0] = i[0].decode("latin1").decode("iso-8859-1").encode(getfilesystemencoding()) # try to convert to latin1 and then back to sys.getfilesystemencoding()
i[0] = i[0].decode("latin1").decode("iso-8859-1").encode(sys.getfilesystemencoding()) # try to convert to latin1 and then back to sys.getfilesystemencoding()
except:
print "DEBUG: cannot encode into filesystem encoding -> "+str(i[0])
continue
@@ -1582,7 +1581,7 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
for i in outcontent:
data['content'][str(i[0])] = i[1]
except IOError, e:
except IOError:
if inject: # CONTENTS is not generated when a package is emerged with portage and the option -B
# we have to unpack the tbz2 and generate content dict
import shutil
@@ -1591,25 +1590,25 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
shutil.rmtree(mytempdir)
if not os.path.isdir(mytempdir):
os.makedirs(mytempdir)
mytempdir = mytempdir.encode(getfilesystemencoding())
mytempdir = mytempdir.encode(sys.getfilesystemencoding())
uncompressTarBz2(filepath, extractPath = mytempdir, catchEmpty = True)
for currentdir, subdirs, files in os.walk(mytempdir):
data['content'][currentdir[len(mytempdir):]] = "dir"
for file in files:
for item in files:
try:
file = file.encode(getfilesystemencoding())
item = item.encode(sys.getfilesystemencoding())
except:
try:
file = file.decode("latin1").decode("iso-8859-1").encode(getfilesystemencoding())
item = item.decode("latin1").decode("iso-8859-1").encode(sys.getfilesystemencoding())
except:
print "DEBUG: cannot encode into filesystem encoding -> "+str(file)
print "DEBUG: cannot encode into filesystem encoding -> "+str(item)
continue
file = currentdir+"/"+file
if os.path.islink(file):
data['content'][file[len(mytempdir):]] = "sym"
item = currentdir+"/"+item
if os.path.islink(item):
data['content'][item[len(mytempdir):]] = "sym"
else:
data['content'][file[len(mytempdir):]] = "obj"
data['content'][item[len(mytempdir):]] = "obj"
# now remove
shutil.rmtree(mytempdir,True)
@@ -1622,9 +1621,9 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
# files size on disk
if (data['content']):
data['disksize'] = 0
for file in data['content']:
for item in data['content']:
try:
size = os.stat(file)[6]
size = os.stat(item)[6]
data['disksize'] += size
except:
pass
@@ -1635,11 +1634,11 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
data['versiontag'] = ''
kernelDependentModule = False
kernelItself = False
for file in data['content']:
if file.find("/lib/modules/") != -1:
for item in data['content']:
if item.find("/lib/modules/") != -1:
kernelDependentModule = True
# get the version of the modules
kmodver = file.split("/lib/modules/")[1]
kmodver = item.split("/lib/modules/")[1]
kmodver = kmodver.split("/")[0]
lp = kmodver.split("-")[len(kmodver.split("-"))-1]
@@ -1784,7 +1783,6 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
f = open(tbz2TmpDir+dbSRC_URI,"r")
sources = f.readline().strip().split()
f.close()
tmpData = []
cnt = -1
skip = False
data['sources'] = []
@@ -1938,16 +1936,16 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje
elogfiles = os.listdir(etpConst['logdir']+"/elog")
myelogfile = data['category']+":"+data['name']+"-"+data['version']
foundfiles = []
for file in elogfiles:
if file.startswith(myelogfile):
foundfiles.append(file)
for item in elogfiles:
if item.startswith(myelogfile):
foundfiles.append(item)
if foundfiles:
elogfile = foundfiles[0]
if len(foundfiles) > 1:
# get the latest
mtimes = []
for file in foundfiles:
mtimes.append((getFileUnixMtime(etpConst['logdir']+"/elog/"+file),file))
for item in foundfiles:
mtimes.append((getFileUnixMtime(etpConst['logdir']+"/elog/"+item),item))
mtimes.sort()
elogfile = mtimes[len(mtimes)-1][1]
messages = extractElog(etpConst['logdir']+"/elog/"+elogfile)
+7 -7
View File
@@ -16,7 +16,7 @@
# (integer) == encodeint(integer) ===> 4 characters (big-endian copy)
# '+' means concatenate the fields ===> All chunks are strings
import sys,os,shutil,errno
import os,shutil,errno
from stat import *
def addtolist(mylist,curdir):
@@ -56,7 +56,7 @@ def xpak(rootdir,outfile=None):
xpak segment."""
try:
origdir=os.getcwd()
except SystemExit, e:
except SystemExit:
raise
except:
os.chdir("/")
@@ -126,7 +126,7 @@ def xsplit_mem(mydat):
if mydat[-8:]!="XPAKSTOP":
return None
indexsize=decodeint(mydat[8:12])
datasize=decodeint(mydat[12:16])
#datasize=decodeint(mydat[12:16]) not used
return (mydat[16:indexsize+16], mydat[indexsize+16:-8])
def getindex(infile):
@@ -201,7 +201,7 @@ def xpand(myid,mydest):
mydata=myid[1]
try:
origdir=os.getcwd()
except SystemExit, e:
except SystemExit:
raise
except:
os.chdir("/")
@@ -251,7 +251,7 @@ class tbz2:
return self.unpackinfo(datadir)
def compose(self,datadir,cleanup=0):
"""Alias for recompose()."""
return recompose(datadir,cleanup)
return self.recompose(datadir,cleanup)
def recompose(self,datadir,cleanup=0):
"""Creates an xpak segment from the datadir provided, truncates the tbz2
to the end of regular data if an xpak segment already exists, and adds
@@ -324,7 +324,7 @@ class tbz2:
self.datapos=a.tell()
a.close()
return 2
except SystemExit, e:
except SystemExit:
raise
except:
return 0
@@ -361,7 +361,7 @@ class tbz2:
return 0
try:
origdir=os.getcwd()
except SystemExit, e:
except SystemExit:
raise
except:
os.chdir("/")
+4 -4
View File
@@ -82,7 +82,7 @@ class parser:
print ">> "+line+" << is invalid!!"
continue
# atom? is it worth it? it would take a little bit to parse uhm... >50 entries...!?
kinfo = keywordinfo[0]
#kinfo = keywordinfo[0]
if keywordinfo[0] == "**": keywordinfo[0] = "" # convert into entropy format
data['universal'].add(keywordinfo[0])
continue # needed?
@@ -160,9 +160,9 @@ class parser:
def __removeRepoCache(self):
if os.path.isdir(self.etpConst['dumpstoragedir']):
content = os.listdir(self.etpConst['dumpstoragedir'])
for file in content:
if file.startswith(self.etpCache['dbMatch']+self.etpConst['dbnamerepoprefix']) and file.endswith(".dmp"):
os.remove(self.etpConst['dumpstoragedir']+"/"+file)
for item in content:
if item.startswith(self.etpCache['dbMatch']+self.etpConst['dbnamerepoprefix']) and item.endswith(".dmp"):
os.remove(self.etpConst['dumpstoragedir']+"/"+item)
else:
os.makedirs(self.etpConst['dumpstoragedir'])
+11 -12
View File
@@ -58,7 +58,6 @@ class handlerFTP:
else:
self.ftppassword = ftpuri.split("@")[:len(ftpuri.split("@"))-1]
if len(self.ftppassword) > 1:
import string
self.ftppassword = '@'.join(self.ftppassword)
self.ftppassword = self.ftppassword.split(":")[len(self.ftppassword.split(":"))-1]
if (self.ftppassword == ""):
@@ -217,7 +216,7 @@ class handlerFTP:
self.ftpconn.mkd(directory)
# this function also supports callback, because storbinary doesn't
def advancedStorBinary(self, cmd, fp, callback=None, blocksize=8192):
def advancedStorBinary(self, cmd, fp, callback=None):
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.advancedStorBinary: called with -> "+str(cmd))
''' Store a file in binary mode. Our version supports a callback function'''
self.ftpconn.voidcmd('TYPE I')
@@ -322,12 +321,12 @@ class handlerFTP:
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: called for -> "+str(filepath)+" | download directory: "+str(downloaddir)+" | ascii? "+str(ascii))
file = filepath.split("/")[len(filepath.split("/"))-1]
item = filepath.split("/")[len(filepath.split("/"))-1]
# look if the file exist
if self.isFileAvailable(file):
if self.isFileAvailable(item):
self.mykByteCount = 0
# get the file size
self.myFileSize = self.getFileSizeCompat(file)
self.myFileSize = self.getFileSizeCompat(item)
if (self.myFileSize):
self.myFileSize = round(float(int(self.myFileSize))/1024,1)
if (self.myFileSize == 0):
@@ -335,11 +334,11 @@ class handlerFTP:
else:
self.myFileSize = 0
if (not ascii):
f = open(downloaddir+"/"+file,"wb")
rc = self.ftpconn.retrbinary('RETR '+file, downloadFileStoreAndUpdateProgress, 1024)
f = open(downloaddir+"/"+item,"wb")
rc = self.ftpconn.retrbinary('RETR '+item, downloadFileStoreAndUpdateProgress, 1024)
else:
f = open(downloaddir+"/"+file,"w")
rc = self.ftpconn.retrlines('RETR '+file, f.write)
f = open(downloaddir+"/"+item,"w")
rc = self.ftpconn.retrlines('RETR '+item, f.write)
f.flush()
f.close()
if rc.find("226") != -1: # upload complete
@@ -349,7 +348,7 @@ class handlerFTP:
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: download issues !!.")
return False
else:
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: file '"+file+"' not available !!.")
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: file '"+item+"' not available !!.")
return None
# also used to move files
@@ -365,8 +364,8 @@ class handlerFTP:
def getFileSizeCompat(self,file):
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFileSizeCompat: called for -> "+file)
list = self.getRoughList()
for item in list:
data = self.getRoughList()
for item in data:
if item.find(file) != -1:
# extact the size
return item.split()[4]
+2
View File
@@ -41,6 +41,7 @@ for x in range(stuff['cols']):
stuff['cleanline'] += ' '
havecolor=1
global dotitles
dotitles=1
esc_seq = "\x1b["
@@ -192,6 +193,7 @@ def xtermTitleReset():
def notitles():
"turn off title setting"
global dotitles
dotitles=0
def nocolor():
+5 -13
View File
@@ -34,14 +34,11 @@ import portage
import portage_const
from portage_dep import isvalidatom, isspecific, isjustname, dep_getkey, dep_getcpv
from portage_util import grabdict_package
from portage_const import USER_CONFIG_PATH
# colours support
from outputTools import *
# misc modules
import sys
import commands
import entropyTools
# Logging initialization
import logTools
@@ -222,7 +219,7 @@ def quickpkg(atom,dirpath):
# getting package info
pkgname = atom.split("/")[1]
pkgcat = atom.split("/")[0]
pkgfile = pkgname+".tbz2"
#pkgfile = pkgname+".tbz2"
if not os.path.isdir(dirpath):
os.makedirs(dirpath)
dirpath += "/"+pkgname+".tbz2"
@@ -230,10 +227,9 @@ def quickpkg(atom,dirpath):
import tarfile
import stat
from portage import dblink
trees = portage.db["/"]
vartree = trees["vartree"]
dblnk = dblink(pkgcat, pkgname, "/", vartree.settings, treetype="vartree", vartree=vartree)
dblnk = portage.dblink(pkgcat, pkgname, "/", vartree.settings, treetype="vartree", vartree=vartree)
dblnk.lockdb()
tar = tarfile.open(dirpath,"w:bz2")
@@ -336,7 +332,6 @@ def synthetizeRoughDependencies(roughDependencies, useflags = None):
useflags = useflags.split()
length = len(roughDependencies)
global atomcount
atomcount = -1
while atomcount < length:
@@ -352,9 +347,9 @@ def synthetizeRoughDependencies(roughDependencies, useflags = None):
openParenthesisFromOr += 1
openParenthesis += 1
curparenthesis = openParenthesis # 2
if (useFlagQuestion == True) and (useMatch == False):
if (useFlagQuestion) and (not useMatch):
skip = True
while (skip == True):
while (skip):
atomcount += 1
atom = roughDependencies[atomcount]
if atom.startswith("("):
@@ -412,7 +407,7 @@ def synthetizeRoughDependencies(roughDependencies, useflags = None):
elif (atom.find("/") != -1) and (not atom.startswith("!")) and (not atom.endswith("?")):
# it's a package name <pkgcat>/<pkgname>-???
if ((useFlagQuestion == True) and (useMatch == True)) or ((useFlagQuestion == False) and (useMatch == False)):
if (useFlagQuestion == useMatch):
# check if there's an OR
if (openOr):
dependencies += atom
@@ -494,7 +489,6 @@ def getPortageAppDbPath():
# Collect installed packages
def getInstalledPackages(dbdir = None):
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledPackages: called.")
import os
if not dbdir:
appDbDir = getPortageAppDbPath()
else:
@@ -513,7 +507,6 @@ def getInstalledPackages(dbdir = None):
def getInstalledPackagesCounters():
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledPackagesCounters: called.")
import os
appDbDir = getPortageAppDbPath()
dbDirs = os.listdir(appDbDir)
installedAtoms = []
@@ -532,7 +525,6 @@ def getInstalledPackagesCounters():
def refillCounter():
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"refillCounter: called.")
import os
appDbDir = getPortageAppDbPath()
counters = set()
for catdir in os.listdir(appDbDir):
+8 -11
View File
@@ -116,7 +116,7 @@ def inject(options):
def update(options, inject = False):
def update(options):
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"update: called -> options: "+str(options))
@@ -152,7 +152,6 @@ def update(options, inject = False):
from portageTools import getInstalledPackagesCounters, quickpkg, getPackageSlot
installedPackages = getInstalledPackagesCounters()
installedCounters = set()
databasePackages = dbconn.listAllPackages()
toBeAdded = set()
toBeRemoved = set()
@@ -243,7 +242,7 @@ def update(options, inject = False):
cat = dbconn.retrieveCategory(match[0])
name = dbconn.retrieveName(match[0])
version = dbconn.retrieveVersion(match[0])
slot = dbconn.retrieveSlot(match[0])
#slot = dbconn.retrieveSlot(match[0])
if os.path.isdir(appdb+"/"+cat+"/"+name+"-"+version):
packages.append([cat+"/"+name+"-"+version,0])
@@ -260,8 +259,8 @@ def update(options, inject = False):
print_info(brown(" # ")+red(x[0]+"..."))
rc = quickpkg(x[0],etpConst['packagesstoredir'])
if (rc is None):
reagentLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"update: "+str(dep)+" -> quickpkg error. Cannot continue.")
print_error(red(" *")+" quickpkg error for "+red(dep))
reagentLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"update: "+str(x)+" -> quickpkg error. Cannot continue.")
print_error(red(" *")+" quickpkg error for "+red(x))
print_error(red(" ***")+" Fatal error, cannot continue")
return 251
@@ -294,7 +293,6 @@ def update(options, inject = False):
counter = 0
etpCreated = 0
etpNotCreated = 0
for tbz2 in tbz2files:
counter += 1
etpCreated += 1
@@ -347,7 +345,7 @@ def tbz2Handler(tbz2path, dbconn, requested_branch, inject = False):
digest = md5sum(etpConst['packagessuploaddir']+"/"+requested_branch+"/"+downloadfile)
dbconn.setDigest(idpk,digest)
hashFilePath = createHashFile(etpConst['packagessuploaddir']+"/"+requested_branch+"/"+downloadfile)
createHashFile(etpConst['packagessuploaddir']+"/"+requested_branch+"/"+downloadfile)
# remove garbage
os.remove(dbpath)
print_info(brown(" * ")+red("Database injection complete for ")+downloadfile)
@@ -601,7 +599,6 @@ def database(options):
etpUi['ask'] = ask
print_info(green(" * ")+red("Switching selected packages ..."))
import re
for pkg in pkglist:
atom = dbconn.retrieveAtom(pkg)
@@ -856,11 +853,11 @@ def database(options):
for pkg in toBeDownloaded:
rc = activatorTools.downloadPackageFromMirror(uri,pkg[1],pkg[2])
if (rc is None):
if (rc == None):
notDownloadedPackages.append([pkg[1],pkg[2]])
if (rc == False):
elif (not rc):
notDownloadedPackages.append([pkg[1],pkg[2]])
if (rc == True):
elif (rc):
pkgDownloadedSuccessfully += 1
availList.append(pkg[0])
+4 -4
View File
@@ -65,8 +65,8 @@ def getRemotePackageChecksum(servername, filename, branch):
proxy_support = urllib2.ProxyHandler(etpConst['proxy'])
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
file = urllib2.urlopen(request)
result = file.readline().strip()
item = urllib2.urlopen(request)
result = item.readline().strip()
return result
except: # no HTTP support?
return None
@@ -148,8 +148,8 @@ def getOnlineContent(url):
proxy_support = urllib2.ProxyHandler(etpConst['proxy'])
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
file = urllib2.urlopen(url)
result = file.readlines()
item = urllib2.urlopen(url)
result = item.readlines()
if (not result):
socket.setdefaulttimeout(2)
return False
+7 -7
View File
@@ -22,7 +22,7 @@
from entropyConstants import *
from xml.dom import minidom
import time, datetime
import time
feed_title = etpConst['systemname']+" Online Repository Status"
feed_description = "Keep you updated on what's going on in the Official "+etpConst['systemname']+" Repository."
@@ -53,7 +53,7 @@ class rssFeed:
self.title = feed_title
self.description = feed_description
self.language = feed_language
self.copyright = feed_copyright
self.cright = feed_copyright
self.editor = feed_editor
self.link = etpConst['rss-website-url']
f = open(self.file,"w")
@@ -67,7 +67,7 @@ class rssFeed:
self.link = self.channel.getElementsByTagName("link")[0].firstChild.data
self.description = self.channel.getElementsByTagName("description")[0].firstChild.data
self.language = self.channel.getElementsByTagName("language")[0].firstChild.data
self.copyright = self.channel.getElementsByTagName("copyright")[0].firstChild.data
self.cright = self.channel.getElementsByTagName("copyright")[0].firstChild.data
self.editor = self.channel.getElementsByTagName("managingEditor")[0].firstChild.data
entries = self.channel.getElementsByTagName("item")
self.itemscounter = len(entries)
@@ -154,10 +154,10 @@ class rssFeed:
language.appendChild(lang_text)
channel.appendChild(language)
# copyright
copyright = doc.createElement("copyright")
cr_text = doc.createTextNode(unicode(self.copyright))
copyright.appendChild(cr_text)
channel.appendChild(copyright)
cright = doc.createElement("copyright")
cr_text = doc.createTextNode(unicode(self.cright))
cright.appendChild(cr_text)
channel.appendChild(cright)
# managingEditor
managingEditor = doc.createElement("managingEditor")
ed_text = doc.createTextNode(unicode(self.editor))
+4 -18
View File
@@ -20,8 +20,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import os
from sys import exit
from entropyConstants import *
@@ -60,14 +58,11 @@ def initConfig_serverConstants():
try:
loglevel = int(loglevel)
except:
print "ERROR: invalid loglevel in: "+etpConst['activatorconf']
exit(51)
print "WARNING: invalid loglevel in: "+etpConst['activatorconf']
if (loglevel > -1) and (loglevel < 3):
etpConst['activatorloglevel'] = loglevel
else:
print "WARNING: invalid loglevel in: "+etpConst['activatorconf']
import time
time.sleep(5)
# reagent section
if (os.path.isfile(etpConst['reagentconf'])):
@@ -80,14 +75,11 @@ def initConfig_serverConstants():
try:
loglevel = int(loglevel)
except:
print "ERROR: invalid loglevel in: "+etpConst['reagentconf']
exit(51)
print "WARNING: invalid loglevel in: "+etpConst['reagentconf']
if (loglevel > -1) and (loglevel < 3):
etpConst['reagentloglevel'] = loglevel
else:
print "WARNING: invalid loglevel in: "+etpConst['reagentconf']
import time
time.sleep(5)
elif line.startswith("rss-feed|") and (len(line.split("rss-feed|")) == 2):
feed = line.split("rss-feed|")[1]
if feed in ("enable","enabled","true","1"):
@@ -123,14 +115,11 @@ def initConfig_serverConstants():
try:
loglevel = int(loglevel)
except:
print "ERROR: invalid loglevel in: "+etpConst['mirrorsconf']
exit(51)
print "WARNING: invalid loglevel in: "+etpConst['mirrorsconf']
if (loglevel > -1) and (loglevel < 3):
etpConst['mirrorsloglevel'] = loglevel
else:
print "WARNING: invalid loglevel in: "+etpConst['mirrorsconf']
import time
time.sleep(5)
# spmbackend section
@@ -144,14 +133,11 @@ def initConfig_serverConstants():
try:
loglevel = int(loglevel)
except:
print "ERROR: invalid loglevel in: "+etpConst['spmbackendconf']
exit(51)
print "WARNING: invalid loglevel in: "+etpConst['spmbackendconf']
if (loglevel > -1) and (loglevel < 3):
etpConst['spmbackendloglevel'] = loglevel
else:
print "WARNING: invalid loglevel in: "+etpConst['spmbackendconf']
import time
time.sleep(5)
# generic settings section
+10 -11
View File
@@ -196,7 +196,6 @@ def DeflateHandler(mytbz2s, savedir):
mytbz2 = entropyTools.removeEdb(tbz2,savedir)
tbz2name = os.path.basename(mytbz2)[:-5] # remove .tbz2
tbz2name = entropyTools.remove_tag(tbz2name)+".tbz2"
oldtbz2 = mytbz2
newtbz2 = os.path.dirname(mytbz2)+"/"+tbz2name
print_info(darkgreen(" * ")+darkred("Deflated package: ")+newtbz2)
@@ -451,15 +450,15 @@ def smartgenerator(atomInfo, emptydeps = False):
entropyTools.uncompressTarBz2(mainBinaryPath,pkgtmpdir) # first unpack
binaryExecs = []
for file in pkgcontent:
for item in pkgcontent:
# remove /
filepath = pkgtmpdir+file
filepath = pkgtmpdir+item
import commands
if os.access(filepath,os.X_OK):
# test if it's an exec
out = commands.getoutput("file "+filepath).split("\n")[0]
if out.find("LSB executable") != -1:
binaryExecs.append(file)
binaryExecs.append(item)
# check if file is executable
# now uncompress all the rest
@@ -541,8 +540,8 @@ def smartgenerator(atomInfo, emptydeps = False):
os.chmod(pkgtmpdir+"/wrp/wrapper",0755)
# now list files in /sh and create .desktop files
for file in binaryExecs:
file = file.split("/")[len(file.split("/"))-1]
for item in binaryExecs:
item = file.split("/")[len(item.split("/"))-1]
runFile = []
runFile.append(
'#include <cstdlib>\n'
@@ -550,21 +549,21 @@ def smartgenerator(atomInfo, emptydeps = False):
'#include <stdio.h>\n'
'int main() {\n'
' int rc = system(\n'
' "pid=$(pidof '+file+'.exe);"\n'
' "pid=$(pidof '+item+'.exe);"\n'
' "listpid=$(ps x | grep $pid);"\n'
' "filename=$(echo $listpid | cut -d\' \' -f 5);"'
' "currdir=$(dirname $filename);"\n'
' "/bin/sh $currdir/wrp/wrapper $currdir '+file+'" );\n'
' "/bin/sh $currdir/wrp/wrapper $currdir '+item+'" );\n'
' return rc;\n'
'}\n'
)
f = open(pkgtmpdir+"/"+file+".cc","w")
f = open(pkgtmpdir+"/"+item+".cc","w")
f.writelines(runFile)
f.flush()
f.close()
# now compile
entropyTools.spawnCommand("cd "+pkgtmpdir+"/ ; g++ -Wall "+file+".cc -o "+file+".exe")
os.remove(pkgtmpdir+"/"+file+".cc")
entropyTools.spawnCommand("cd "+pkgtmpdir+"/ ; g++ -Wall "+item+".cc -o "+item+".exe")
os.remove(pkgtmpdir+"/"+item+".cc")
smartpath = etpConst['smartappsdir']+"/"+pkgname+"-"+etpConst['currentarch']+".tbz2"
print_info(darkgreen(" * ")+red("Compressing smart application: ")+bold(atom))