more work on the new EquoInterface class
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@971 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -73,7 +73,7 @@ class cacheHelper(TextInterface):
|
||||
import equoTools
|
||||
self.equoTools = equoTools
|
||||
# instantiate Equo handling class
|
||||
self.Equo = self.equoTools.Equo()
|
||||
self.Equo = self.equoTools.EquoInterface()
|
||||
import entropyTools
|
||||
self.entropyTools = entropyTools
|
||||
from databaseTools import openRepositoryDatabase
|
||||
|
||||
+1
-9
@@ -21,13 +21,12 @@
|
||||
'''
|
||||
|
||||
from commands import getoutput
|
||||
import shutil
|
||||
from entropyConstants import *
|
||||
from clientConstants import *
|
||||
from outputTools import *
|
||||
import entropyTools
|
||||
import dumpTools
|
||||
import equoTools
|
||||
import shutil
|
||||
import exceptionTools
|
||||
|
||||
# test if diff is installed
|
||||
@@ -310,13 +309,6 @@ def scanfs(dcache = True):
|
||||
except:
|
||||
pass
|
||||
|
||||
# load etpConst['dbconfigprotect']
|
||||
try:
|
||||
clientDbconn = equoTools.openClientDatabase()
|
||||
clientDbconn.closeDB()
|
||||
except exceptionTools.SystemDatabaseError:
|
||||
if (not etpUi['quiet']): print_error(darkred("System database error. Does it exist?"))
|
||||
return
|
||||
# etpConst['dbconfigprotect']
|
||||
if (not etpUi['quiet']): print_info(yellow(" @@ ")+darkgreen("Scanning filesystem..."))
|
||||
scandata = {}
|
||||
|
||||
+7
-3
@@ -144,6 +144,7 @@ options = sys.argv[1:]
|
||||
|
||||
import entropyTools
|
||||
from clientConstants import *
|
||||
import exceptionTools
|
||||
|
||||
# preliminary options parsing
|
||||
_options = []
|
||||
@@ -304,6 +305,9 @@ try:
|
||||
if thread.getName() == "download": # equo current download speed thread
|
||||
thread.kill()
|
||||
sys.exit(rc)
|
||||
except exceptionTools.SystemDatabaseError:
|
||||
print_error(darkred(" * ")+red("Installed Packages Database not found. Please generate it (at least!)"))
|
||||
sys.exit(100)
|
||||
except SystemExit:
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
@@ -336,7 +340,6 @@ except Exception:
|
||||
f = open("/tmp/equoerror.txt","r")
|
||||
errorText = f.readlines()
|
||||
f.close()
|
||||
errorText = ' '.join(errorText)
|
||||
except Exception, e:
|
||||
print
|
||||
print_error(darkred("Oh well, I cannot even write to /tmp. So, please copy the error and mail lxnay@sabayonlinux.org."))
|
||||
@@ -362,8 +365,9 @@ except Exception:
|
||||
print_error(darkgreen("If you want to be contacted back (and actively supported), also answer the questions below:"))
|
||||
fullname = readtext("Your Full name: ")
|
||||
mail = readtext("Your E-Mail address: ")
|
||||
errorText += "\n\nFull name: "+str(fullname)+"\n"
|
||||
errorText += "E-mail: "+str(mail)+"\n"
|
||||
errorText.insert(0,"Full name: "+str(fullname)+"\n")
|
||||
errorText.insert(1,"E-mail: "+str(mail)+"\n\n")
|
||||
errorText = ' '.join(errorText)
|
||||
|
||||
# ok, come on!
|
||||
result = reportApplicationError(errorText)
|
||||
|
||||
+49
-23
@@ -30,7 +30,7 @@ from outputTools import *
|
||||
import remoteTools
|
||||
import exceptionTools
|
||||
from entropyTools import compareMd5, bytesIntoHuman, askquestion, getRandomNumber, dep_getkey, uncompressTarBz2, extractXpak, applicationLockCheck, countdown, isRoot, spliturl, remove_tag, dep_striptag, md5sum, allocateMaskedFile, istextfile, isnumber, extractEdb, unpackXpak, lifobuffer, ebeep, parallelStep
|
||||
from databaseTools import openRepositoryDatabase, openClientDatabase, openGenericDatabase, listAllAvailableBranches
|
||||
from databaseTools import openRepositoryDatabase, openClientDatabase, openGenericDatabase
|
||||
import confTools
|
||||
import dumpTools
|
||||
import gc
|
||||
@@ -43,7 +43,7 @@ equoLog = logTools.LogFile(level = etpConst['equologlevel'],filename = etpConst[
|
||||
'''
|
||||
Main Entropy (client side) package management class
|
||||
'''
|
||||
class Equo(TextInterface):
|
||||
class EquoInterface(TextInterface):
|
||||
|
||||
'''
|
||||
@input indexing(bool): enable/disable database tables indexing
|
||||
@@ -61,14 +61,39 @@ class Equo(TextInterface):
|
||||
self.indexing = indexing
|
||||
self.noclientdb = noclientdb
|
||||
self.xcache = xcache
|
||||
try:
|
||||
self.clientDbconn = self.databaseTools.openClientDatabase(indexing = self.indexing,
|
||||
generate = noclientdb,
|
||||
self.openClientDatatabase()
|
||||
self.repoDbCache = {}
|
||||
|
||||
def reopenClientDbconn(self):
|
||||
self.clientDbconn.closeDB()
|
||||
self.openClientDatatabase()
|
||||
|
||||
def closeAllRepositoryDatabases(self):
|
||||
for item in self.repoDbCache:
|
||||
self.repoDbCache[item].closeDB()
|
||||
del self.repoDbCache[item]
|
||||
self.repoDbCache.clear()
|
||||
|
||||
def openClientDatatabase(self):
|
||||
self.clientDbconn = self.databaseTools.openClientDatabase(indexing = self.indexing,
|
||||
generate = self.noclientdb,
|
||||
xcache = self.xcache
|
||||
)
|
||||
except exceptionTools.SystemDatabaseError:
|
||||
self.updateProgress(darkred("Installed Packages Database not found. Please generate it (at least!)"), importance = 2, type = "error")
|
||||
raise
|
||||
|
||||
def openRepositoryDatabase(self, repoid):
|
||||
if not self.repoDbCache.has_key((repoid,etpConst['systemroot'])):
|
||||
dbconn = self.databaseTools.openRepositoryDatabase(repoid, xcache = self.xcache, indexing = self.indexing)
|
||||
self.repoDbCache[(repoid,etpConst['systemroot'])] = dbconn
|
||||
return dbconn
|
||||
else:
|
||||
return self.repoDbCache.get((repoid,etpConst['systemroot']))
|
||||
|
||||
def listAllAvailableBranches(self):
|
||||
branches = set()
|
||||
for repo in etpRepositories:
|
||||
dbconn = self.openRepositoryDatabase(repo)
|
||||
branches.update(dbconn.listAllBranches())
|
||||
return branches
|
||||
|
||||
def load_cache(self):
|
||||
|
||||
@@ -528,20 +553,20 @@ class Equo(TextInterface):
|
||||
continue
|
||||
else:
|
||||
keyslotcache.add((matchslot,key))
|
||||
|
||||
|
||||
# already analyzed by the calling function
|
||||
if (match in matchFilter) and (usefilter):
|
||||
mydep = mybuffer.pop()
|
||||
continue
|
||||
if usefilter: matchFilter.add(match)
|
||||
|
||||
|
||||
# result already analyzed?
|
||||
if match in matchcache:
|
||||
mydep = mybuffer.pop()
|
||||
continue
|
||||
|
||||
|
||||
treedepth = mydep[0]+1
|
||||
|
||||
|
||||
# all checks passed, well done
|
||||
matchcache.add(match)
|
||||
deptree.add((mydep[0],match)) # add match
|
||||
@@ -556,7 +581,7 @@ class Equo(TextInterface):
|
||||
myundeps = mytestdeps
|
||||
for x in myundeps:
|
||||
mybuffer.push((treedepth,x))
|
||||
|
||||
|
||||
# handle possible library breakage
|
||||
action = filterSatisfiedDependenciesCmpResults.get(mydep[1])
|
||||
if action and ((action < 0) or (action > 0)): # do not use != 0 since action can be "None"
|
||||
@@ -773,6 +798,7 @@ class Equo(TextInterface):
|
||||
return newtree,0 # treeview is used to show deps while tree is used to run the dependency code.
|
||||
|
||||
|
||||
|
||||
########################################################
|
||||
####
|
||||
## Files handling
|
||||
@@ -786,17 +812,17 @@ class Equo(TextInterface):
|
||||
def checkNeededDownload(filepath,checksum = None):
|
||||
# is the file available
|
||||
if os.path.isfile(etpConst['entropyworkdir']+"/"+filepath):
|
||||
if checksum is None:
|
||||
return 0
|
||||
else:
|
||||
# check digest
|
||||
md5res = compareMd5(etpConst['entropyworkdir']+"/"+filepath,checksum)
|
||||
if (md5res):
|
||||
return 0
|
||||
else:
|
||||
return -2
|
||||
if checksum is None:
|
||||
return 0
|
||||
else:
|
||||
# check digest
|
||||
md5res = compareMd5(etpConst['entropyworkdir']+"/"+filepath,checksum)
|
||||
if (md5res):
|
||||
return 0
|
||||
else:
|
||||
return -2
|
||||
else:
|
||||
return -1
|
||||
return -1
|
||||
|
||||
|
||||
def addFailingMirror(mirrorname,increment = 1):
|
||||
|
||||
+343
-449
File diff suppressed because it is too large
Load Diff
@@ -234,7 +234,7 @@ def syncRepositories(reponames = [], forceUpdate = False):
|
||||
rc = False
|
||||
try:
|
||||
import equoTools
|
||||
Equo = equoTools.Equo()
|
||||
Equo = equoTools.EquoInterface()
|
||||
rc = Equo.check_equo_updates()
|
||||
del Equo
|
||||
except:
|
||||
@@ -245,31 +245,6 @@ def syncRepositories(reponames = [], forceUpdate = False):
|
||||
|
||||
return 0
|
||||
|
||||
def checkEquoUpdates():
|
||||
# tell if a new equo release is available
|
||||
import equoTools
|
||||
from databaseTools import openClientDatabase
|
||||
try:
|
||||
clientDbconn = openClientDatabase(xcache = False)
|
||||
except exceptionTools.SystemDatabaseError:
|
||||
del repoConn
|
||||
return False
|
||||
|
||||
found = False
|
||||
matches = clientDbconn.searchPackages("app-admin/equo")
|
||||
if matches:
|
||||
equo_match = "<="+matches[0][0]
|
||||
equo_unsatisfied,x = equoTools.filterSatisfiedDependencies([equo_match])
|
||||
del x
|
||||
if equo_unsatisfied:
|
||||
found = True
|
||||
del matches
|
||||
del equo_unsatisfied
|
||||
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
return found
|
||||
|
||||
#
|
||||
# repository control class, that's it
|
||||
#
|
||||
|
||||
+38
-64
@@ -28,7 +28,7 @@
|
||||
from entropyConstants import *
|
||||
from clientConstants import *
|
||||
from outputTools import *
|
||||
from databaseTools import etpDatabase, openRepositoryDatabase, openClientDatabase, backupClientDatabase
|
||||
from databaseTools import backupClientDatabase
|
||||
import entropyTools
|
||||
import equoTools
|
||||
import exceptionTools
|
||||
@@ -43,6 +43,8 @@ def database(options):
|
||||
print_error(red("You are not ")+bold("root")+red("."))
|
||||
return 1
|
||||
|
||||
Equo = equoTools.EquoInterface(noclientdb = True)
|
||||
|
||||
if (options[0] == "generate"):
|
||||
|
||||
# test if portage is available
|
||||
@@ -74,14 +76,11 @@ def database(options):
|
||||
# try to collect current installed revisions if possible
|
||||
revisionsMatch = {}
|
||||
try:
|
||||
clientDbconn = openClientDatabase()
|
||||
myids = clientDbconn.listAllIdpackages()
|
||||
myids = Equo.clientDbconn.listAllIdpackages()
|
||||
for myid in myids:
|
||||
myatom = clientDbconn.retrieveAtom(myid)
|
||||
myrevision = clientDbconn.retrieveRevision(myid)
|
||||
myatom = Equo.clientDbconn.retrieveAtom(myid)
|
||||
myrevision = Equo.clientDbconn.retrieveRevision(myid)
|
||||
revisionsMatch[myatom] = myrevision
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -94,8 +93,8 @@ def database(options):
|
||||
|
||||
# Now reinitialize it
|
||||
print_info(darkred(" Initializing the new database at "+bold(etpConst['etpdatabaseclientfilepath'])), back = True)
|
||||
clientDbconn = openClientDatabase(generate = True)
|
||||
clientDbconn.initializeDatabase()
|
||||
Equo.reopenClientDbconn()
|
||||
Equo.clientDbconn.initializeDatabase()
|
||||
print_info(darkgreen(" Database reinitialized correctly at "+bold(etpConst['etpdatabaseclientfilepath'])))
|
||||
|
||||
# now collect packages in the system
|
||||
@@ -144,17 +143,15 @@ def database(options):
|
||||
except:
|
||||
pass
|
||||
|
||||
idpk, rev, xx, status = clientDbconn.addPackage(etpData = mydata, revision = mydata['revision'])
|
||||
clientDbconn.addPackageToInstalledTable(idpk,"gentoo-db")
|
||||
idpk, rev, xx, status = Equo.clientDbconn.addPackage(etpData = mydata, revision = mydata['revision'])
|
||||
Equo.clientDbconn.addPackageToInstalledTable(idpk,"gentoo-db")
|
||||
os.remove(temptbz2)
|
||||
|
||||
print_info(red(" All the Gentoo packages have been injected into Entropy database."))
|
||||
|
||||
print_info(red(" Now generating depends caching table..."))
|
||||
clientDbconn.regenerateDependsTable()
|
||||
Equo.clientDbconn.regenerateDependsTable()
|
||||
print_info(red(" Database reinitialized successfully."))
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
return 0
|
||||
|
||||
elif (options[0] == "resurrect"):
|
||||
@@ -185,8 +182,7 @@ def database(options):
|
||||
|
||||
# Now reinitialize it
|
||||
print_info(darkred(" Initializing the new database at "+bold(etpConst['etpdatabaseclientfilepath'])), back = True)
|
||||
clientDbconn = openClientDatabase()
|
||||
clientDbconn.initializeDatabase()
|
||||
Equo.clientDbconn.initializeDatabase()
|
||||
print_info(darkgreen(" Database reinitialized correctly at "+bold(etpConst['etpdatabaseclientfilepath'])))
|
||||
|
||||
print_info(red(" Collecting installed files. Writing: "+etpConst['packagestmpfile']+" Please wait..."), back = True)
|
||||
@@ -221,7 +217,7 @@ def database(options):
|
||||
for repo in etpRepositories:
|
||||
print_info(red(" Matching in repository: ")+etpRepositories[repo]['description'])
|
||||
# get all idpackages
|
||||
dbconn = openRepositoryDatabase(repo)
|
||||
dbconn = Equo.openRepositoryDatabase(repo)
|
||||
idpackages = dbconn.listAllIdpackages(branch = etpConst['branch'])
|
||||
count = str(len(idpackages))
|
||||
cnt = 0
|
||||
@@ -237,8 +233,6 @@ def database(options):
|
||||
atoms[(idpackage,repo)] = idpackageatom
|
||||
filelist.difference_update(set([etpConst['systemroot']+x for x in content]))
|
||||
break
|
||||
dbconn.closeDB()
|
||||
del clientDbconn
|
||||
|
||||
print_info(red(" Found "+str(len(pkgsfound))+" packages. Filling database..."))
|
||||
count = str(len(pkgsfound))
|
||||
@@ -256,10 +250,7 @@ def database(options):
|
||||
|
||||
elif (options[0] == "depends"):
|
||||
print_info(red(" Regenerating depends caching table..."))
|
||||
clientDbconn = openClientDatabase()
|
||||
clientDbconn.regenerateDependsTable()
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
Equo.clientDbconn.regenerateDependsTable()
|
||||
print_info(red(" Depends caching table regenerated successfully."))
|
||||
return 0
|
||||
|
||||
@@ -272,10 +263,7 @@ def database(options):
|
||||
return 1
|
||||
|
||||
print_info(red(" Regenerating counters table. Please wait..."))
|
||||
clientDbconn = openClientDatabase()
|
||||
clientDbconn.regenerateCountersTable(output = True)
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
Equo.clientDbconn.regenerateCountersTable(output = True)
|
||||
print_info(red(" Counters table regenerated. Check above for errors."))
|
||||
return 0
|
||||
|
||||
@@ -289,19 +277,14 @@ def database(options):
|
||||
|
||||
print_info(red(" Scanning Portage and Entropy databases for differences..."))
|
||||
|
||||
try:
|
||||
clientDbconn = openClientDatabase()
|
||||
except exceptionTools.SystemDatabaseError:
|
||||
# damn
|
||||
print_error(darkred(" * ")+bold("Entropy database")+red(" does not exist. So, you can't run this unless you run '")+bold("equo database generate")+red("' first. Sorry."))
|
||||
return 1
|
||||
# make it crash
|
||||
Equo.noclientdb = False
|
||||
Equo.reopenClientDbconn()
|
||||
|
||||
# test if counters table exists, because if not, it's useless to run the diff scan
|
||||
try:
|
||||
clientDbconn.isCounterAvailable(1)
|
||||
Equo.clientDbconn.isCounterAvailable(1)
|
||||
except:
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
print_error(darkred(" * ")+bold("Entropy database")+red(" has never been in sync with Portage one. So, you can't run this unless you run '")+bold("equo database generate")+red("' first. Sorry."))
|
||||
return 1
|
||||
|
||||
@@ -318,12 +301,12 @@ def database(options):
|
||||
# packages to be added/updated (handle add/update later)
|
||||
for x in installedPackages[0]:
|
||||
installedCounters.add(x[1])
|
||||
counter = clientDbconn.isCounterAvailable(x[1])
|
||||
counter = Equo.clientDbconn.isCounterAvailable(x[1])
|
||||
if (not counter):
|
||||
toBeAdded.add(tuple(x))
|
||||
|
||||
# packages to be removed from the database
|
||||
databaseCounters = clientDbconn.listAllCounters()
|
||||
databaseCounters = Equo.clientDbconn.listAllCounters()
|
||||
for x in databaseCounters:
|
||||
if x[0] < 0: # skip packages without valid counter
|
||||
continue
|
||||
@@ -331,7 +314,7 @@ def database(options):
|
||||
# check if the package is in toBeAdded
|
||||
if (toBeAdded):
|
||||
atomkey = entropyTools.dep_getkey(clientDbconn.retrieveAtom(x[1]))
|
||||
atomslot = clientDbconn.retrieveSlot(x[1])
|
||||
atomslot = Equo.clientDbconn.retrieveSlot(x[1])
|
||||
add = True
|
||||
for pkgdata in toBeAdded:
|
||||
addslot = getPackageSlot(pkgdata[0])
|
||||
@@ -351,15 +334,13 @@ def database(options):
|
||||
if (not toBeRemoved) and (not toBeAdded):
|
||||
print_info(red(" Databases already synced."))
|
||||
# then exit gracefully
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
return 0
|
||||
|
||||
if (toBeRemoved):
|
||||
print_info(brown(" @@ ")+blue("Someone removed these packages. Would be removed from the Entropy database:"))
|
||||
|
||||
for x in toBeRemoved:
|
||||
atom = clientDbconn.retrieveAtom(x)
|
||||
atom = Equo.clientDbconn.retrieveAtom(x)
|
||||
print_info(brown(" # ")+red(atom))
|
||||
rc = "Yes"
|
||||
if etpUi['ask']: rc = entropyTools.askquestion(">> Continue with removal?")
|
||||
@@ -368,9 +349,9 @@ def database(options):
|
||||
totalqueue = str(len(toBeRemoved))
|
||||
for x in toBeRemoved:
|
||||
queue += 1
|
||||
atom = clientDbconn.retrieveAtom(x)
|
||||
atom = Equo.clientDbconn.retrieveAtom(x)
|
||||
print_info(red(" ++ ")+bold("(")+blue(str(queue))+"/"+red(totalqueue)+bold(") ")+">>> Removing "+darkgreen(atom))
|
||||
clientDbconn.removePackage(x)
|
||||
Equo.clientDbconn.removePackage(x)
|
||||
print_info(brown(" @@ ")+blue("Database removal complete."))
|
||||
|
||||
if (toBeAdded):
|
||||
@@ -415,21 +396,19 @@ def database(options):
|
||||
myatom += "#"+mydata['versiontag']
|
||||
|
||||
# look for atom in client database
|
||||
oldidpackage = clientDbconn.getIDPackage(myatom)
|
||||
oldidpackage = Equo.clientDbconn.getIDPackage(myatom)
|
||||
if oldidpackage != -1:
|
||||
mydata['revision'] = clientDbconn.retrieveRevision(oldidpackage)
|
||||
mydata['revision'] = Equo.clientDbconn.retrieveRevision(oldidpackage)
|
||||
else:
|
||||
mydata['revision'] = 9999 # can't do much more
|
||||
|
||||
idpk, rev, xx, status = clientDbconn.handlePackage(etpData = mydata, forcedRevision = mydata['revision'])
|
||||
clientDbconn.removePackageFromInstalledTable(idpk)
|
||||
clientDbconn.addPackageToInstalledTable(idpk,"gentoo-db")
|
||||
idpk, rev, xx, status = Equo.clientDbconn.handlePackage(etpData = mydata, forcedRevision = mydata['revision'])
|
||||
Equo.clientDbconn.removePackageFromInstalledTable(idpk)
|
||||
Equo.clientDbconn.addPackageToInstalledTable(idpk,"gentoo-db")
|
||||
os.remove(temptbz2)
|
||||
|
||||
|
||||
print_info(brown(" @@ ")+blue("Database update completed."))
|
||||
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
|
||||
return 0
|
||||
|
||||
else:
|
||||
@@ -473,9 +452,8 @@ def pythonUpdater():
|
||||
old_pdir = os.path.join("/usr/lib/",dirs[0])
|
||||
print_info(brown(" @@ ")+blue("Scanning: %s" % (red(old_pdir),)))
|
||||
|
||||
clientDbconn = openClientDatabase()
|
||||
old_pdir = old_pdir.replace("/usr/lib","/usr/lib*")
|
||||
idpackages = queryTools.searchBelongs(files = [old_pdir], idreturn = True, dbconn = clientDbconn)
|
||||
idpackages = queryTools.searchBelongs(files = [old_pdir], idreturn = True, dbconn = Equo.clientDbconn)
|
||||
if not idpackages:
|
||||
print_info(brown(" @@ ")+blue("There are no files in %s whose belong to your old Python." % (old_pdir,)))
|
||||
return 0
|
||||
@@ -483,7 +461,7 @@ def pythonUpdater():
|
||||
|
||||
atoms = set()
|
||||
for idpackage in idpackages:
|
||||
atom = clientDbconn.retrieveAtom(idpackage)
|
||||
atom = Equo.clientDbconn.retrieveAtom(idpackage)
|
||||
atoms.add((atom, idpackage))
|
||||
print_info(red(" # ")+atom)
|
||||
|
||||
@@ -493,9 +471,9 @@ def pythonUpdater():
|
||||
matchedAtoms = set()
|
||||
for meta in atoms:
|
||||
atomkey = entropyTools.dep_getkey(meta[0])
|
||||
slot = clientDbconn.retrieveSlot(meta[1])
|
||||
slot = Equo.clientDbconn.retrieveSlot(meta[1])
|
||||
print_info(brown(" @@ ")+red("Matching ")+bold(atomkey)+red(":")+darkgreen(slot), back = True)
|
||||
match = uiTools.Equo.atomMatch(atomkey, matchSlot = slot)
|
||||
match = Equo.atomMatch(atomkey, matchSlot = slot)
|
||||
if match[0] != -1:
|
||||
matchedAtoms.add((atomkey+":"+slot,match))
|
||||
del atoms
|
||||
@@ -551,7 +529,7 @@ def getinfo(dict = False):
|
||||
# client database info
|
||||
conn = False
|
||||
try:
|
||||
clientDbconn = openClientDatabase()
|
||||
Equo.clientDbconn.listAllIdPackages()
|
||||
conn = True
|
||||
except:
|
||||
pass
|
||||
@@ -561,8 +539,6 @@ def getinfo(dict = False):
|
||||
info['Removal internal protected directories'] = clientDbconn.listConfigProtectDirectories()
|
||||
info['Removal internal protected directory masks'] = clientDbconn.listConfigProtectDirectories(mask = True)
|
||||
info['Total installed packages'] = len(clientDbconn.listAllIdpackages())
|
||||
clientDbconn.closeDB()
|
||||
del clientDbconn
|
||||
|
||||
# repository databases info (if found on the system)
|
||||
info['Repository databases'] = {}
|
||||
@@ -570,15 +546,13 @@ def getinfo(dict = False):
|
||||
dbfile = etpRepositories[x]['dbpath']+"/"+etpConst['etpdatabasefile']
|
||||
if os.path.isfile(dbfile):
|
||||
# print info about this database
|
||||
dbconn = openRepositoryDatabase(x)
|
||||
dbconn = Equo.openRepositoryDatabase(x)
|
||||
info['Repository databases'][x] = {}
|
||||
info['Repository databases'][x]['Installation internal protected directories'] = dbconn.listConfigProtectDirectories()
|
||||
info['Repository databases'][x]['Installation internal protected directory masks'] = dbconn.listConfigProtectDirectories(mask = True)
|
||||
info['Repository databases'][x]['Total available packages'] = len(dbconn.listAllIdpackages())
|
||||
info['Repository databases'][x]['Database revision'] = repositoriesTools.getRepositoryRevision(x)
|
||||
info['Repository databases'][x]['Database hash'] = repositoriesTools.getRepositoryDbFileHash(x)
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
if (dict):
|
||||
return info
|
||||
|
||||
+86
-122
@@ -29,14 +29,14 @@ from entropyConstants import *
|
||||
from clientConstants import *
|
||||
from outputTools import *
|
||||
import equoTools
|
||||
from databaseTools import openRepositoryDatabase, openGenericDatabase, listAllAvailableBranches
|
||||
from databaseTools import openGenericDatabase
|
||||
import entropyTools
|
||||
import dumpTools
|
||||
import shutil
|
||||
|
||||
import logTools
|
||||
equoLog = logTools.LogFile(level = etpConst['equologlevel'],filename = etpConst['equologfile'], header = "[Equo]")
|
||||
Equo = equoTools.Equo()
|
||||
Equo = equoTools.EquoInterface()
|
||||
|
||||
def package(options):
|
||||
|
||||
@@ -141,7 +141,7 @@ def worldUpdate(onlyfetch = False, replay = False, upgradeTo = None, resume = Fa
|
||||
|
||||
# verify selected release (branch)
|
||||
if (upgradeTo):
|
||||
availbranches = listAllAvailableBranches()
|
||||
availbranches = Equo.listAllAvailableBranches()
|
||||
if (upgradeTo not in availbranches) or (upgradeTo == None):
|
||||
if not (etpUi['quiet'] or returnQueue): print_error(red("Selected release: ")+bold(str(upgradeTo))+red(" is not available."))
|
||||
return 1,-2
|
||||
@@ -175,12 +175,10 @@ def worldUpdate(onlyfetch = False, replay = False, upgradeTo = None, resume = Fa
|
||||
if match[0] == -1: # atom has been changed, or removed?
|
||||
tainted = True
|
||||
else: # not changed, is the revision changed?
|
||||
adbconn = openRepositoryDatabase(match[1])
|
||||
adbconn = Equo.openRepositoryDatabase(match[1])
|
||||
arevision = adbconn.retrieveRevision(match[0])
|
||||
# if revision is 9999, then any revision is fine
|
||||
if revision == 9999: arevision = 9999
|
||||
adbconn.closeDB()
|
||||
del adbconn
|
||||
if revision != arevision:
|
||||
tainted = True
|
||||
elif (replay):
|
||||
@@ -189,20 +187,16 @@ def worldUpdate(onlyfetch = False, replay = False, upgradeTo = None, resume = Fa
|
||||
# Alice! use the key! ... and the slot
|
||||
matchresults = Equo.atomMatch(atomkey, matchSlot = slot, matchBranches = branches)
|
||||
if matchresults[0] != -1:
|
||||
mdbconn = openRepositoryDatabase(matchresults[1])
|
||||
mdbconn = Equo.openRepositoryDatabase(matchresults[1])
|
||||
matchatom = mdbconn.retrieveAtom(matchresults[0])
|
||||
mdbconn.closeDB()
|
||||
del mdbconn
|
||||
updateList.add((matchatom,matchresults))
|
||||
else:
|
||||
removedList.add(idpackage)
|
||||
# look for packages that would match key with any slot (for eg, gcc updates), slot changes handling
|
||||
matchresults = Equo.atomMatch(atomkey, matchBranches = branches)
|
||||
if matchresults[0] != -1:
|
||||
mdbconn = openRepositoryDatabase(matchresults[1])
|
||||
mdbconn = Equo.openRepositoryDatabase(matchresults[1])
|
||||
matchatom = mdbconn.retrieveAtom(matchresults[0])
|
||||
mdbconn.closeDB()
|
||||
del mdbconn
|
||||
# compare versions
|
||||
unsatisfied, satisfied = Equo.filterSatisfiedDependencies((matchatom,))
|
||||
if unsatisfied:
|
||||
@@ -390,8 +384,8 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
idpackage = atomInfo[0]
|
||||
reponame = atomInfo[1]
|
||||
# open database
|
||||
dbconn = openRepositoryDatabase(reponame)
|
||||
|
||||
dbconn = Equo.openRepositoryDatabase(reponame)
|
||||
|
||||
# get needed info
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
pkgver = dbconn.retrieveVersion(idpackage)
|
||||
@@ -400,7 +394,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
pkgtag = "NoTag"
|
||||
pkgrev = dbconn.retrieveRevision(idpackage)
|
||||
pkgslot = dbconn.retrieveSlot(idpackage)
|
||||
|
||||
|
||||
# client info
|
||||
installedVer = "Not installed"
|
||||
installedTag = "NoTag"
|
||||
@@ -433,10 +427,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
else:
|
||||
action = red("Downgrade")
|
||||
if not (etpUi['quiet'] or returnQueue): print_info("\t"+red("Action:\t\t")+" "+action)
|
||||
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
|
||||
if (etpUi['verbose'] or etpUi['ask'] or etpUi['pretend']):
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Number of packages: ")+str(totalatoms))
|
||||
|
||||
@@ -462,15 +453,13 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
crying_atoms = set()
|
||||
for atom in treepackages:
|
||||
for repo in etpRepositories:
|
||||
rdbconn = openRepositoryDatabase(repo)
|
||||
rdbconn = Equo.openRepositoryDatabase(repo)
|
||||
riddep = rdbconn.searchDependency(atom)
|
||||
if riddep != -1:
|
||||
ridpackages = rdbconn.searchIdpackageFromIddependency(riddep)
|
||||
for i in ridpackages:
|
||||
iatom = rdbconn.retrieveAtom(i)
|
||||
crying_atoms.add((iatom,repo))
|
||||
rdbconn.closeDB()
|
||||
del rdbconn
|
||||
if crying_atoms:
|
||||
if not (etpUi['quiet'] or returnQueue): print_error(red(" @@ ")+blue("Dependency found and probably needed by:"))
|
||||
for crying_atomdata in crying_atoms:
|
||||
@@ -523,7 +512,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
|
||||
if not (etpUi['quiet'] or returnQueue):
|
||||
if not (etpUi['ask'] or etpUi['pretend']): print_info(":: Collecting data: "+str(round((float(count)/atomlen)*100,1))+"% ::", back = True)
|
||||
dbconn = openRepositoryDatabase(packageInfo[1])
|
||||
dbconn = Equo.openRepositoryDatabase(packageInfo[1])
|
||||
mydata = dbconn.getBaseData(packageInfo[0])
|
||||
pkgatom = mydata[0]
|
||||
pkgver = mydata[2]
|
||||
@@ -599,8 +588,6 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
oldinfo += oldtag
|
||||
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(darkred(" ##")+flags+repoinfo+enlightenatom(str(pkgatom))+"/"+str(pkgrev)+oldinfo)
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
if (removalQueue):
|
||||
|
||||
@@ -611,7 +598,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
myremmatch = {}
|
||||
[myremmatch.update({(entropyTools.dep_getkey(Equo.clientDbconn.retrieveAtom(x)),Equo.clientDbconn.retrieveSlot(x)): x}) for x in removalQueue]
|
||||
for packageInfo in runQueue:
|
||||
dbconn = openRepositoryDatabase(packageInfo[1])
|
||||
dbconn = Equo.openRepositoryDatabase(packageInfo[1])
|
||||
testtuple = (entropyTools.dep_getkey(dbconn.retrieveAtom(packageInfo[0])),dbconn.retrieveSlot(packageInfo[0]))
|
||||
if testtuple in myremmatch:
|
||||
# remove from removalQueue
|
||||
@@ -621,14 +608,14 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
del myremmatch
|
||||
# update
|
||||
pkgsToRemove = len(removalQueue)
|
||||
|
||||
|
||||
#'''
|
||||
|
||||
|
||||
'''
|
||||
|
||||
|
||||
FIXME: it's broken, on equo world it pulls in depends that shouldn't be removed
|
||||
fix, or remove and forget
|
||||
|
||||
|
||||
# add depends to removalQueue that are not in runQueue
|
||||
dependQueue = set()
|
||||
for idpackage in removalQueue:
|
||||
@@ -639,10 +626,8 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
# match in repositories
|
||||
match = Equo.atomMatch(dependkey, matchSlot = dependslot)
|
||||
if match[0] != -1:
|
||||
matchdbconn = openRepositoryDatabase(match[1])
|
||||
matchdbconn = Equo.openRepositoryDatabase(match[1])
|
||||
matchatom = matchdbconn.retrieveAtom(match[0])
|
||||
matchdbconn.closeDB()
|
||||
del matchdbconn
|
||||
if (matchatom not in actionQueue) and (depend not in removalQueue): # if the atom hasn't been pulled in, we need to remove depend
|
||||
# check if the atom is already up to date
|
||||
mymatch = Equo.atomMatch(matchatom)
|
||||
@@ -725,10 +710,8 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
rconflicts_match = set()
|
||||
# now look for the rest
|
||||
for item in runQueue:
|
||||
rdbconn = openRepositoryDatabase(item[1])
|
||||
rdbconn = Equo.openRepositoryDatabase(item[1])
|
||||
rconflicts = rdbconn.retrieveConflicts(item[0])
|
||||
rdbconn.closeDB()
|
||||
del rdbconn
|
||||
for rconflict in rconflicts:
|
||||
rmatch = Equo.clientDbconn.atomMatch(rconflict)
|
||||
if rmatch[0] != -1:
|
||||
@@ -739,7 +722,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
resume_cache['runQueue'] = runQueue[:]
|
||||
resume_cache['removalQueue'] = removalQueue[:]
|
||||
dumpTools.dumpobj(etpCache['install'],resume_cache)
|
||||
|
||||
|
||||
|
||||
if returnQueue:
|
||||
# prepare return dictionary
|
||||
@@ -770,44 +753,41 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
if not returnQueue:
|
||||
fetchqueue = 0
|
||||
for packageInfo in runQueue:
|
||||
|
||||
|
||||
fetchqueue += 1
|
||||
idpackage = packageInfo[0]
|
||||
repository = packageInfo[1]
|
||||
dbconn = openRepositoryDatabase(repository)
|
||||
dbconn = Equo.openRepositoryDatabase(repository)
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
|
||||
|
||||
infoDict = actionQueue[pkgatom].copy()
|
||||
|
||||
|
||||
infoDict['repository'] = packageInfo[1]
|
||||
infoDict['idpackage'] = packageInfo[0]
|
||||
infoDict['checksum'] = dbconn.retrieveDigest(idpackage)
|
||||
infoDict['download'] = dbconn.retrieveDownloadURL(idpackage)
|
||||
infoDict['verified'] = False
|
||||
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
|
||||
steps = []
|
||||
|
||||
|
||||
if not repository.endswith(".tbz2"):
|
||||
if (actionQueue[pkgatom]['fetch'] < 0):
|
||||
steps.append("fetch")
|
||||
if dochecksum:
|
||||
steps.append("checksum")
|
||||
|
||||
|
||||
# if file exists, first checksum then fetch
|
||||
if os.path.isfile(os.path.join(etpConst['entropyworkdir'],infoDict['download'])):
|
||||
steps.reverse()
|
||||
|
||||
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" :: ")+bold("(")+blue(str(fetchqueue))+"/"+red(totalqueue)+bold(") ")+">>> "+darkgreen(pkgatom))
|
||||
|
||||
|
||||
for step in steps:
|
||||
rc = equoTools.stepExecutor(step,infoDict,str(fetchqueue)+"/"+totalqueue)
|
||||
if (rc != 0):
|
||||
dirscleanup()
|
||||
return -1,rc
|
||||
|
||||
|
||||
# disable fetch now, file fetched
|
||||
# also taint actionQueue[pkgatom]['fetch'] so resume won't re-fetch all again
|
||||
actionQueue[pkgatom]['fetch'] = 1
|
||||
@@ -858,25 +838,25 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
del etpRemovalTriggers[infoDict['removeatom']]
|
||||
|
||||
for packageInfo in runQueue:
|
||||
|
||||
currentqueue += 1
|
||||
idpackage = packageInfo[0]
|
||||
repository = packageInfo[1]
|
||||
# get package atom
|
||||
dbconn = openRepositoryDatabase(repository)
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
|
||||
steps = []
|
||||
|
||||
# setup download stuff
|
||||
|
||||
currentqueue += 1
|
||||
idpackage = packageInfo[0]
|
||||
repository = packageInfo[1]
|
||||
# get package atom
|
||||
dbconn = Equo.openRepositoryDatabase(repository)
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
|
||||
steps = []
|
||||
|
||||
# setup download stuff
|
||||
if returnQueue:
|
||||
if not repository.endswith(".tbz2"):
|
||||
if (actionQueue[pkgatom]['fetch'] < 0):
|
||||
steps.append("fetch")
|
||||
steps.append("checksum")
|
||||
|
||||
# differential remove list
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
# differential remove list
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
# is it still available?
|
||||
if Equo.clientDbconn.isIDPackageAvailable(actionQueue[pkgatom]['removeidpackage']):
|
||||
actionQueue[pkgatom]['diffremoval'] = True
|
||||
@@ -902,14 +882,13 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
actionQueue[pkgatom]['name'] = dbconn.retrieveName(idpackage)
|
||||
actionQueue[pkgatom]['repository'] = packageInfo[1]
|
||||
actionQueue[pkgatom]['idpackage'] = packageInfo[0]
|
||||
|
||||
|
||||
actionQueue[pkgatom]['messages'] = dbconn.retrieveMessages(idpackage)
|
||||
actionQueue[pkgatom]['checksum'] = dbconn.retrieveDigest(idpackage)
|
||||
# get data for triggerring tool
|
||||
etpInstallTriggers[pkgatom] = dbconn.getPackageData(idpackage)
|
||||
etpInstallTriggers[pkgatom]['trigger'] = dbconn.retrieveTrigger(idpackage)
|
||||
|
||||
|
||||
|
||||
# set unpack dir and image dir
|
||||
if actionQueue[pkgatom]['repository'].endswith(".tbz2"):
|
||||
actionQueue[pkgatom]['pkgpath'] = etpRepositories[actionQueue[pkgatom]['repository']]['pkgpath']
|
||||
@@ -930,24 +909,21 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
etpInstallTriggers[pkgatom]['xpakdir'] = actionQueue[pkgatom]['xpakpath']+"/"+etpConst['entropyxpakdatarelativepath']
|
||||
etpInstallTriggers[pkgatom]['unpackdir'] = actionQueue[pkgatom]['unpackdir']
|
||||
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
if (not onlyfetch):
|
||||
# install
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
steps.append("preremove")
|
||||
if (not onlyfetch):
|
||||
# install
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
steps.append("preremove")
|
||||
steps.append("unpack")
|
||||
steps.append("preinstall")
|
||||
steps.append("install")
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
steps.append("postremove")
|
||||
steps.append("postinstall")
|
||||
steps.append("preinstall")
|
||||
steps.append("install")
|
||||
if (actionQueue[pkgatom]['removeidpackage'] != -1):
|
||||
steps.append("postremove")
|
||||
steps.append("postinstall")
|
||||
if not etpConst['gentoo-compat']: # otherwise gentoo triggers will show that
|
||||
steps.append("showmessages")
|
||||
steps.append("cleanup")
|
||||
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" ++ ")+bold("(")+blue(str(currentqueue))+"/"+red(totalqueue)+bold(") ")+">>> "+darkgreen(pkgatom))
|
||||
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" ++ ")+bold("(")+blue(str(currentqueue))+"/"+red(totalqueue)+bold(") ")+">>> "+darkgreen(pkgatom))
|
||||
|
||||
if returnQueue:
|
||||
|
||||
@@ -967,7 +943,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
if not tbz2: # tbz2 caching not supported
|
||||
resume_cache['runQueue'].remove(packageInfo)
|
||||
dumpTools.dumpobj(etpCache['install'],resume_cache)
|
||||
|
||||
|
||||
# unload dict
|
||||
try:
|
||||
del etpRemovalTriggers[actionQueue[pkgatom]['removeatom']]
|
||||
@@ -976,22 +952,18 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
del actionQueue[pkgatom]
|
||||
if not returnQueue:
|
||||
del etpInstallTriggers[pkgatom]
|
||||
|
||||
|
||||
|
||||
if (onlyfetch):
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Fetch Complete."))
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Fetch Complete."))
|
||||
else:
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Install Complete."))
|
||||
if not (etpUi['quiet'] or returnQueue): print_info(red(" @@ ")+blue("Install Complete."))
|
||||
|
||||
# clear resume information
|
||||
dumpTools.dumpobj(etpCache['install'],{})
|
||||
|
||||
dirscleanup()
|
||||
|
||||
if returnQueue:
|
||||
return returnActionQueue,0
|
||||
|
||||
return 0,0
|
||||
|
||||
|
||||
@@ -1281,11 +1253,11 @@ def dependenciesTest(clientDbconn = None, reagent = False):
|
||||
if (depsNotSatisfied):
|
||||
if (not etpUi['quiet']):
|
||||
print_info(red(" @@ ")+blue("These are the packages that lack dependencies: "))
|
||||
for xidpackage in depsNotSatisfied:
|
||||
pkgatom = clientDbconn.retrieveAtom(xidpackage)
|
||||
if (not etpUi['quiet']):
|
||||
print_info(darkred(" ### ")+blue(pkgatom))
|
||||
for dep in depsNotSatisfied[xidpackage]:
|
||||
for xidpackage in depsNotSatisfied:
|
||||
pkgatom = clientDbconn.retrieveAtom(xidpackage)
|
||||
if (not etpUi['quiet']):
|
||||
print_info(darkred(" ### ")+blue(pkgatom))
|
||||
for dep in depsNotSatisfied[xidpackage]:
|
||||
if reagent:
|
||||
match = clientDbconn.atomMatch(dep)
|
||||
else:
|
||||
@@ -1297,36 +1269,34 @@ def dependenciesTest(clientDbconn = None, reagent = False):
|
||||
else:
|
||||
print dep,"--"
|
||||
continue
|
||||
iddep = match[0]
|
||||
repo = match[1]
|
||||
dbconn = openRepositoryDatabase(repo)
|
||||
depatom = dbconn.retrieveAtom(iddep)
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
if (not etpUi['quiet']):
|
||||
print_info(bold(" :o: ")+red(depatom))
|
||||
else:
|
||||
print pkgatom+" -> "+depatom
|
||||
packagesNeeded.add((depatom,dep))
|
||||
iddep = match[0]
|
||||
repo = match[1]
|
||||
dbconn = Equo.openRepositoryDatabase(repo)
|
||||
depatom = dbconn.retrieveAtom(iddep)
|
||||
if (not etpUi['quiet']):
|
||||
print_info(bold(" :o: ")+red(depatom))
|
||||
else:
|
||||
print pkgatom+" -> "+depatom
|
||||
packagesNeeded.add((depatom,dep))
|
||||
|
||||
if (etpUi['pretend']):
|
||||
return 0, packagesNeeded
|
||||
return 0, packagesNeeded
|
||||
|
||||
if (packagesNeeded) and (not etpUi['quiet']) and (not reagent):
|
||||
if (etpUi['ask']):
|
||||
rc = entropyTools.askquestion(" Would you like to install the available packages?")
|
||||
if rc == "No":
|
||||
return 0,packagesNeeded
|
||||
else:
|
||||
print_info(red(" @@ ")+blue("Installing available packages in ")+red("10 seconds")+blue("..."))
|
||||
import time
|
||||
time.sleep(10)
|
||||
|
||||
return 0,packagesNeeded
|
||||
else:
|
||||
print_info(red(" @@ ")+blue("Installing available packages in ")+red("10 seconds")+blue("..."))
|
||||
import time
|
||||
time.sleep(10)
|
||||
|
||||
# organize
|
||||
packages = set([x[0] for x in packagesNeeded])
|
||||
|
||||
entropyTools.applicationLockCheck("install")
|
||||
installPackages(packages, deps = False)
|
||||
|
||||
entropyTools.applicationLockCheck("install")
|
||||
installPackages(packages, deps = False)
|
||||
|
||||
if not etpUi['quiet']: print_info(red(" @@ ")+blue("All done."))
|
||||
return 0,packagesNeeded
|
||||
@@ -1420,7 +1390,7 @@ def librariesTest(clientDbconn = None, reagent = False, listfiles = False):
|
||||
orderedRepos.sort()
|
||||
for repodata in orderedRepos:
|
||||
if not etpUi['quiet']: print_info(red(" @@ ")+blue("Repository: ")+darkgreen(etpRepositories[repodata[1]]['description'])+" ["+red(repodata[1])+"]")
|
||||
dbconn = openRepositoryDatabase(repodata[1])
|
||||
dbconn = Equo.openRepositoryDatabase(repodata[1])
|
||||
libsfound = set()
|
||||
for lib in brokenlibs:
|
||||
packages = dbconn.searchBelongs(file = "%"+lib, like = True, branch = etpConst['branch'])
|
||||
@@ -1433,8 +1403,6 @@ def librariesTest(clientDbconn = None, reagent = False, listfiles = False):
|
||||
if matching_libs:
|
||||
packagesMatched.add((idpackage,repodata[1],lib))
|
||||
brokenlibs.difference_update(libsfound)
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
|
||||
if listfiles:
|
||||
etpUi['quiet'] = qstat
|
||||
@@ -1455,20 +1423,16 @@ def librariesTest(clientDbconn = None, reagent = False, listfiles = False):
|
||||
print_info(darkred(" => ")+red(lib))
|
||||
print_info(darkgreen(" ## ")+red("Matched:"))
|
||||
for packagedata in packagesMatched:
|
||||
dbconn = openRepositoryDatabase(packagedata[1])
|
||||
dbconn = Equo.openRepositoryDatabase(packagedata[1])
|
||||
myatom = dbconn.retrieveAtom(packagedata[0])
|
||||
atomsdata.add((myatom,(packagedata[0],packagedata[1])))
|
||||
print_info(" "+red(packagedata[2])+" => "+brown(myatom)+" ["+red(packagedata[1])+"]")
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
else:
|
||||
for packagedata in packagesMatched:
|
||||
dbconn = openRepositoryDatabase(packagedata[1])
|
||||
dbconn = Equo.openRepositoryDatabase(packagedata[1])
|
||||
myatom = dbconn.retrieveAtom(packagedata[0])
|
||||
atomsdata.add((myatom,(packagedata[0],packagedata[1])))
|
||||
print myatom
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
return 0,atomsdata
|
||||
|
||||
if (etpUi['pretend']):
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
'''
|
||||
|
||||
import os
|
||||
import sys
|
||||
from entropyConstants import *
|
||||
|
||||
### Equo triggering functions for pre/post-install scripts
|
||||
|
||||
+701
-677
File diff suppressed because it is too large
Load Diff
@@ -1462,7 +1462,7 @@ def quickpkg(pkgdata, dirpath, edb = True, portdbPath = None, fake = False, comp
|
||||
# convert path into utf8
|
||||
path = string_to_utf8(path)
|
||||
if path == None:
|
||||
path.decode("utf8") # will raise the exception
|
||||
path.decode("utf-8") # will raise the exception
|
||||
# otherwise, force it
|
||||
raise Exception, "something is broken here!"
|
||||
try:
|
||||
@@ -2126,7 +2126,7 @@ def string_to_utf8(string):
|
||||
|
||||
# try utf8
|
||||
try:
|
||||
newstring = string.decode("utf8").encode(sys.getfilesystemencoding())
|
||||
newstring = string.decode("utf-8").encode(sys.getfilesystemencoding())
|
||||
done = True
|
||||
except:
|
||||
pass
|
||||
@@ -2134,7 +2134,7 @@ def string_to_utf8(string):
|
||||
return newstring
|
||||
|
||||
try:
|
||||
newstring = string.encode("utf8").decode(sys.getfilesystemencoding())
|
||||
newstring = string.encode("utf-8").decode(sys.getfilesystemencoding())
|
||||
done = True
|
||||
except:
|
||||
pass
|
||||
@@ -2167,10 +2167,10 @@ def listToUtf8(mylist):
|
||||
mynewlist = []
|
||||
for item in mylist:
|
||||
try:
|
||||
mynewlist.append(item.decode("utf8"))
|
||||
mynewlist.append(item.decode("utf-8"))
|
||||
except UnicodeDecodeError:
|
||||
try:
|
||||
mynewlist.append(item.decode("latin1").decode("utf8"))
|
||||
mynewlist.append(item.decode("latin1").decode("utf-8"))
|
||||
except:
|
||||
raise
|
||||
return mynewlist
|
||||
|
||||
+35
-42
@@ -24,16 +24,15 @@ import shutil
|
||||
from entropyConstants import *
|
||||
from clientConstants import *
|
||||
from outputTools import *
|
||||
import entropyTools
|
||||
import equoTools
|
||||
import uiTools
|
||||
from databaseTools import openClientDatabase, openRepositoryDatabase, openGenericDatabase
|
||||
Equo = equoTools.Equo()
|
||||
from databaseTools import openGenericDatabase
|
||||
Equo = equoTools.EquoInterface()
|
||||
|
||||
def smart(options):
|
||||
|
||||
# check if I am root
|
||||
if (not entropyTools.isRoot()):
|
||||
if (not Equo.entropyTools.isRoot()):
|
||||
print_error(red("You are not ")+bold("root")+red("."))
|
||||
return 1
|
||||
|
||||
@@ -92,7 +91,7 @@ def QuickpkgHandler(mypackages, savedir = None):
|
||||
packages.append(match)
|
||||
else:
|
||||
if not etpUi['quiet']: print_warning(darkred(" * ")+red("Cannot find: ")+bold(opt))
|
||||
packages = entropyTools.filterDuplicatedEntries(packages)
|
||||
packages = Equo.entropyTools.filterDuplicatedEntries(packages)
|
||||
if (not packages):
|
||||
print_error(darkred(" * ")+red("No valid packages specified."))
|
||||
return 2
|
||||
@@ -108,13 +107,13 @@ def QuickpkgHandler(mypackages, savedir = None):
|
||||
print_info(brown("\t[")+red("from:")+bold("installed")+brown("]")+" - "+atom)
|
||||
|
||||
if (not etpUi['quiet']) or (etpUi['ask']):
|
||||
rc = entropyTools.askquestion(">> Would you like to recompose the selected packages ?")
|
||||
rc = Equo.entropyTools.askquestion(">> Would you like to recompose the selected packages ?")
|
||||
if rc == "No":
|
||||
return 0
|
||||
|
||||
for pkg in packages:
|
||||
if not etpUi['quiet']: print_info(brown(" * ")+red("Compressing: ")+darkgreen(pkgInfo[pkg]))
|
||||
resultfile = entropyTools.quickpkg(pkgdata = pkgData[pkg], dirpath = savedir)
|
||||
resultfile = Equo.entropyTools.quickpkg(pkgdata = pkgData[pkg], dirpath = savedir)
|
||||
if resultfile == None:
|
||||
if not etpUi['quiet']: print_error(darkred(" * ")+red("Error creating package for: ")+bold(pkgInfo[pkg])+darkred(". Cannot continue."))
|
||||
return 3
|
||||
@@ -143,7 +142,7 @@ def CommonFlate(mytbz2s, action, savedir = None):
|
||||
|
||||
for tbz2 in mytbz2s:
|
||||
#print_info(brown(" * ")+darkred("Analyzing: ")+tbz2)
|
||||
if not (os.path.isfile(tbz2) and tbz2.endswith(".tbz2") and entropyTools.isEntropyTbz2(tbz2)):
|
||||
if not (os.path.isfile(tbz2) and tbz2.endswith(".tbz2") and Equo.entropyTools.isEntropyTbz2(tbz2)):
|
||||
print_error(darkred(" * ")+bold(tbz2)+red(" is not a valid tbz2"))
|
||||
return 1
|
||||
|
||||
@@ -168,19 +167,19 @@ def InflateHandler(mytbz2s, savedir):
|
||||
etptbz2path = savedir+"/"+os.path.basename(tbz2)
|
||||
if os.path.realpath(tbz2) != os.path.realpath(etptbz2path): # can convert a file without copying
|
||||
shutil.copy2(tbz2,etptbz2path)
|
||||
mydata = entropyTools.extractPkgData(etptbz2path)
|
||||
mydata = Equo.entropyTools.extractPkgData(etptbz2path)
|
||||
# append arbitrary revision
|
||||
mydata['revision'] = 9999
|
||||
# create temp database
|
||||
dbpath = etpConst['packagestmpdir']+"/"+str(entropyTools.getRandomNumber())
|
||||
dbpath = etpConst['packagestmpdir']+"/"+str(Equo.entropyTools.getRandomNumber())
|
||||
while os.path.isfile(dbpath):
|
||||
dbpath = etpConst['packagestmpdir']+"/"+str(entropyTools.getRandomNumber())
|
||||
dbpath = etpConst['packagestmpdir']+"/"+str(Equo.entropyTools.getRandomNumber())
|
||||
# create
|
||||
mydbconn = openGenericDatabase(dbpath)
|
||||
mydbconn.initializeDatabase()
|
||||
mydbconn.addPackage(mydata, revision = mydata['revision'])
|
||||
mydbconn.closeDB()
|
||||
entropyTools.aggregateEdb(tbz2file = etptbz2path, dbfile = dbpath)
|
||||
Equo.entropyTools.aggregateEdb(tbz2file = etptbz2path, dbfile = dbpath)
|
||||
os.remove(dbpath)
|
||||
print_info(darkgreen(" * ")+darkred("Inflated package: ")+etptbz2path)
|
||||
|
||||
@@ -191,9 +190,9 @@ def DeflateHandler(mytbz2s, savedir):
|
||||
# analyze files
|
||||
for tbz2 in mytbz2s:
|
||||
print_info(darkgreen(" * ")+darkred("Deflating: ")+tbz2, back = True)
|
||||
mytbz2 = entropyTools.removeEdb(tbz2,savedir)
|
||||
mytbz2 = Equo.entropyTools.removeEdb(tbz2,savedir)
|
||||
tbz2name = os.path.basename(mytbz2)[:-5] # remove .tbz2
|
||||
tbz2name = entropyTools.remove_tag(tbz2name)+".tbz2"
|
||||
tbz2name = Equo.entropyTools.remove_tag(tbz2name)+".tbz2"
|
||||
newtbz2 = os.path.dirname(mytbz2)+"/"+tbz2name
|
||||
print_info(darkgreen(" * ")+darkred("Deflated package: ")+newtbz2)
|
||||
|
||||
@@ -208,7 +207,7 @@ def ExtractHandler(mytbz2s, savedir):
|
||||
if os.path.isfile(dbpath):
|
||||
os.remove(dbpath)
|
||||
# extract
|
||||
out = entropyTools.extractEdb(tbz2,dbpath = dbpath)
|
||||
out = Equo.entropyTools.extractEdb(tbz2,dbpath = dbpath)
|
||||
print_info(darkgreen(" * ")+darkred("Extracted Entropy metadata from: ")+out)
|
||||
|
||||
return 0
|
||||
@@ -226,7 +225,7 @@ def smartPackagesHandler(mypackages):
|
||||
packages.append(match)
|
||||
else:
|
||||
print_warning(darkred(" * ")+red("Cannot find: ")+bold(opt))
|
||||
packages = entropyTools.filterDuplicatedEntries(packages)
|
||||
packages = Equo.entropyTools.filterDuplicatedEntries(packages)
|
||||
if (not packages):
|
||||
print_error(darkred(" * ")+red("No valid packages specified."))
|
||||
return 2
|
||||
@@ -235,13 +234,12 @@ def smartPackagesHandler(mypackages):
|
||||
print_info(darkgreen(" * ")+red("This is the list of the packages that would be merged into a single one:"))
|
||||
pkgInfo = {}
|
||||
for pkg in packages:
|
||||
dbconn = openRepositoryDatabase(pkg[1])
|
||||
dbconn = Equo.openRepositoryDatabase(pkg[1])
|
||||
atom = dbconn.retrieveAtom(pkg[0])
|
||||
pkgInfo[pkg] = atom
|
||||
print_info(brown("\t[")+red("from:")+pkg[1]+brown("]")+" - "+atom)
|
||||
dbconn.closeDB()
|
||||
|
||||
rc = entropyTools.askquestion(">> Would you like to create the packages above ?")
|
||||
rc = Equo.entropyTools.askquestion(">> Would you like to create the packages above ?")
|
||||
if rc == "No":
|
||||
return 0
|
||||
|
||||
@@ -259,7 +257,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
fetchdata = []
|
||||
matchedAtoms = {}
|
||||
for x in matchedPackages:
|
||||
xdbconn = openRepositoryDatabase(x[1])
|
||||
xdbconn = Equo.openRepositoryDatabase(x[1])
|
||||
matchedAtoms[x] = {}
|
||||
xatom = xdbconn.retrieveAtom(x[0])
|
||||
xdownload = xdbconn.retrieveDownloadURL(x[0])
|
||||
@@ -268,16 +266,15 @@ def smartpackagegenerator(matchedPackages):
|
||||
matchedAtoms[x]['download'] = xdownload
|
||||
matchedAtoms[x]['revision'] = xrevision
|
||||
fetchdata.append([xatom,x])
|
||||
xdbconn.closeDB()
|
||||
# run installPackages with onlyfetch
|
||||
rc = uiTools.installPackages(atomsdata = fetchdata, deps = False, onlyfetch = True)
|
||||
if rc[1] != 0:
|
||||
return rc[0]
|
||||
|
||||
# create unpack dir and unpack all packages
|
||||
unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(entropyTools.getRandomNumber())
|
||||
unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(Equo.entropyTools.getRandomNumber())
|
||||
while os.path.isdir(unpackdir):
|
||||
unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(entropyTools.getRandomNumber())
|
||||
unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(Equo.entropyTools.getRandomNumber())
|
||||
if os.path.isdir(unpackdir):
|
||||
shutil.rmtree(unpackdir)
|
||||
os.makedirs(unpackdir)
|
||||
@@ -291,7 +288,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
tmpdbfile = dbfile+"--readingdata"
|
||||
for package in matchedPackages:
|
||||
print_info(darkgreen(" * ")+brown(matchedAtoms[package]['atom'])+": "+red("collecting Entropy metadata"))
|
||||
entropyTools.extractEdb(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'],tmpdbfile)
|
||||
Equo.entropyTools.extractEdb(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'],tmpdbfile)
|
||||
# read db and add data to mergeDbconn
|
||||
mydbconn = openGenericDatabase(tmpdbfile)
|
||||
idpackages = mydbconn.listAllIdpackages()
|
||||
@@ -300,7 +297,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
data = mydbconn.getPackageData(myidpackage)
|
||||
if len(idpackages) == 1:
|
||||
# just a plain package that would like to become smart
|
||||
xpakdata = entropyTools.readXpak(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'])
|
||||
xpakdata = Equo.entropyTools.readXpak(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'])
|
||||
else:
|
||||
xpakdata = mydbconn.retrieveXpakMetadata(myidpackage) # already a smart package
|
||||
# add
|
||||
@@ -316,7 +313,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
# merge packages
|
||||
for package in matchedPackages:
|
||||
print_info(darkgreen(" * ")+brown(matchedAtoms[package]['atom'])+": "+red("unpacking content"))
|
||||
rc = entropyTools.uncompressTarBz2(etpConst['entropyworkdir']+"/"+matchedAtoms[x]['download'], extractPath = unpackdir+"/content")
|
||||
rc = Equo.entropyTools.uncompressTarBz2(etpConst['entropyworkdir']+"/"+matchedAtoms[x]['download'], extractPath = unpackdir+"/content")
|
||||
if rc != 0:
|
||||
print_error(darkred(" * ")+red("Unpack failed due to unknown reasons."))
|
||||
return rc
|
||||
@@ -328,7 +325,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
for x in matchedAtoms:
|
||||
atoms.append(matchedAtoms[x]['atom'].split("/")[1])
|
||||
atoms = '+'.join(atoms)
|
||||
rc = entropyTools.compressTarBz2(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",unpackdir+"/content")
|
||||
rc = Equo.entropyTools.compressTarBz2(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",unpackdir+"/content")
|
||||
if rc != 0:
|
||||
print_error(darkred(" * ")+red("Compress failed due to unknown reasons."))
|
||||
return rc
|
||||
@@ -337,7 +334,7 @@ def smartpackagegenerator(matchedPackages):
|
||||
print_error(darkred(" * ")+red("Compressed file does not exist."))
|
||||
return 1
|
||||
|
||||
entropyTools.aggregateEdb(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",dbfile)
|
||||
Equo.entropyTools.aggregateEdb(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",dbfile)
|
||||
print_info("\t"+etpConst['smartpackagesdir']+"/"+atoms+".tbz2")
|
||||
shutil.rmtree(unpackdir,True)
|
||||
return 0
|
||||
@@ -370,13 +367,12 @@ def smartappsHandler(mypackages, emptydeps = False):
|
||||
print_info(darkgreen(" * ")+red("This is the list of the packages that would be worked out:"))
|
||||
pkgInfo = {}
|
||||
for pkg in packages:
|
||||
dbconn = openRepositoryDatabase(pkg[1])
|
||||
dbconn = Equo.openRepositoryDatabase(pkg[1])
|
||||
atom = dbconn.retrieveAtom(pkg[0])
|
||||
pkgInfo[pkg] = atom
|
||||
print_info(brown("\t[")+red("from:")+pkg[1]+red("|SMART")+brown("]")+" - "+atom)
|
||||
dbconn.closeDB()
|
||||
|
||||
rc = entropyTools.askquestion(">> Would you like to create the packages above ?")
|
||||
rc = Equo.entropyTools.askquestion(">> Would you like to create the packages above ?")
|
||||
if rc == "No":
|
||||
return 0
|
||||
|
||||
@@ -391,7 +387,7 @@ def smartappsHandler(mypackages, emptydeps = False):
|
||||
# tool that generates .tar.bz2 packages with all the binary dependencies included
|
||||
def smartgenerator(atomInfo, emptydeps = False):
|
||||
|
||||
dbconn = openRepositoryDatabase(atomInfo[1])
|
||||
dbconn = Equo.openRepositoryDatabase(atomInfo[1])
|
||||
idpackage = atomInfo[0]
|
||||
atom = dbconn.retrieveAtom(idpackage)
|
||||
|
||||
@@ -420,18 +416,16 @@ def smartgenerator(atomInfo, emptydeps = False):
|
||||
if pkgs:
|
||||
print_info(darkgreen(" * ")+red("This is the list of the dependencies that would be included:"))
|
||||
for i in pkgs:
|
||||
mydbconn = openRepositoryDatabase(i[1])
|
||||
mydbconn = Equo.openRepositoryDatabase(i[1])
|
||||
atom = mydbconn.retrieveAtom(i[0])
|
||||
print_info(darkgreen(" (x) ")+red(atom))
|
||||
mydbconn.closeDB()
|
||||
|
||||
fetchdata = []
|
||||
fetchdata.append([atom,atomInfo])
|
||||
for x in pkgs:
|
||||
xdbconn = openRepositoryDatabase(x[1])
|
||||
xdbconn = Equo.openRepositoryDatabase(x[1])
|
||||
xatom = xdbconn.retrieveAtom(x[0])
|
||||
fetchdata.append([xatom,x])
|
||||
xdbconn.closeDB()
|
||||
# run installPackages with onlyfetch
|
||||
rc = uiTools.installPackages(atomsdata = fetchdata, deps = False, onlyfetch = True)
|
||||
if rc[1] != 0:
|
||||
@@ -445,7 +439,7 @@ def smartgenerator(atomInfo, emptydeps = False):
|
||||
os.makedirs(pkgtmpdir)
|
||||
mainBinaryPath = etpConst['packagesbindir']+"/"+pkgbranch+"/"+pkgfilename
|
||||
print_info(darkgreen(" * ")+red("Unpacking main package ")+bold(str(pkgfilename)))
|
||||
entropyTools.uncompressTarBz2(mainBinaryPath,pkgtmpdir) # first unpack
|
||||
Equo.entropyTools.uncompressTarBz2(mainBinaryPath,pkgtmpdir) # first unpack
|
||||
|
||||
binaryExecs = []
|
||||
for item in pkgcontent:
|
||||
@@ -461,14 +455,13 @@ def smartgenerator(atomInfo, emptydeps = False):
|
||||
|
||||
# now uncompress all the rest
|
||||
for dep in pkgs:
|
||||
mydbconn = openRepositoryDatabase(dep[1])
|
||||
mydbconn = Equo.openRepositoryDatabase(dep[1])
|
||||
download = os.path.basename(mydbconn.retrieveDownloadURL(dep[0]))
|
||||
depbranch = mydbconn.retrieveBranch(dep[0])
|
||||
depatom = mydbconn.retrieveAtom(dep[0])
|
||||
print_info(darkgreen(" * ")+red("Unpacking dependency package ")+bold(depatom))
|
||||
deppath = etpConst['packagesbindir']+"/"+depbranch+"/"+download
|
||||
entropyTools.uncompressTarBz2(deppath,pkgtmpdir) # first unpack
|
||||
mydbconn.closeDB()
|
||||
Equo.entropyTools.uncompressTarBz2(deppath,pkgtmpdir) # first unpack
|
||||
|
||||
|
||||
# remove unwanted files (header files)
|
||||
@@ -560,13 +553,13 @@ def smartgenerator(atomInfo, emptydeps = False):
|
||||
f.flush()
|
||||
f.close()
|
||||
# now compile
|
||||
entropyTools.spawnCommand("cd "+pkgtmpdir+"/ ; g++ -Wall "+item+".cc -o "+item+".exe")
|
||||
Equo.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))
|
||||
print_info("\t"+smartpath)
|
||||
entropyTools.compressTarBz2(smartpath,pkgtmpdir+"/")
|
||||
Equo.entropyTools.compressTarBz2(smartpath,pkgtmpdir+"/")
|
||||
shutil.rmtree(pkgtmpdir,True)
|
||||
|
||||
return 0
|
||||
@@ -32,7 +32,7 @@ import repositoriesTools
|
||||
import remoteTools
|
||||
import cacheTools
|
||||
import equoTools
|
||||
Equo = equoTools.Equo()
|
||||
Equo = equoTools.EquoInterface()
|
||||
|
||||
'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user