- added EquoInterface.calculate_available_packages() that lists packages available in repos but not installed
- added database function retrieveKeySlot which returns (pkgkey,slot) for the selected idpackage using only SQL (faster) - changed output of EquoInterface.calculate_world_updates(), removed not neeed atom retrieval - fixed other functions accordingly to the change above - get all the Spritz Packages radio options working (you need entropy from SVN, packages queueing doesn't work yet) git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1021 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
+6
-14
@@ -250,7 +250,12 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
else:
|
||||
foundAtoms = []
|
||||
for package in packages:
|
||||
foundAtoms.append([package,Equo.atomMatch(package)])
|
||||
match = Equo.atomMatch(package)
|
||||
if match[0] == -1:
|
||||
print_warning(bold("!!!")+red(" No match for ")+bold(package)+red(" in database. If you omitted the category, try adding it."))
|
||||
print_warning(red(" Also, if package is masked, you need to unmask it. See ")+bold(etpConst['confdir']+"/packages/*")+red(" files for help."))
|
||||
continue
|
||||
foundAtoms.append(match)
|
||||
if tbz2:
|
||||
for pkg in tbz2:
|
||||
status, atomsfound = Equo.add_tbz2_to_repos(pkg)
|
||||
@@ -269,19 +274,6 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals
|
||||
else:
|
||||
raise exceptionTools.InvalidDataType("InvalidDataType: ??????")
|
||||
|
||||
|
||||
# filter packages not found
|
||||
_foundAtoms = []
|
||||
for result in foundAtoms:
|
||||
exitcode = result[1][0]
|
||||
if (exitcode != -1):
|
||||
_foundAtoms.append(result[1])
|
||||
else:
|
||||
print_warning(bold("!!!")+red(" No match for ")+bold(result[0])+red(" in database. If you omitted the category, try adding it."))
|
||||
print_warning(red(" Also, if package is masked, you need to unmask it. See ")+bold(etpConst['confdir']+"/packages/*")+red(" files for help."))
|
||||
|
||||
foundAtoms = _foundAtoms
|
||||
|
||||
# are there packages in foundAtoms?
|
||||
if (not foundAtoms):
|
||||
print_error(red("No packages found"))
|
||||
|
||||
@@ -2249,6 +2249,17 @@ class etpDatabase(TextInterface):
|
||||
self.storeInfoCache(idpackage,'retrieveName',name)
|
||||
return name
|
||||
|
||||
def retrieveKeySlot(self, idpackage):
|
||||
|
||||
cache = self.fetchInfoCache(idpackage,'retrieveKey')
|
||||
if cache != None: return cache
|
||||
|
||||
self.cursor.execute('SELECT categories.category || "/" || baseinfo.name,baseinfo.slot FROM baseinfo,categories WHERE baseinfo.idpackage = (?) and baseinfo.idcategory = categories.idcategory', (idpackage,))
|
||||
data = self.cursor.fetchone()
|
||||
|
||||
self.storeInfoCache(idpackage,'retrieveKey',data)
|
||||
return data
|
||||
|
||||
def retrieveVersion(self, idpackage):
|
||||
|
||||
cache = self.fetchInfoCache(idpackage,'retrieveVersion')
|
||||
|
||||
+61
-6
@@ -1196,6 +1196,62 @@ class EquoInterface(TextInterface):
|
||||
generateDependsTreeCache[tuple(idpackages)]['deep'] = deep
|
||||
return newtree,0 # treeview is used to show deps while tree is used to run the dependency code.
|
||||
|
||||
def all_repositories_checksum(self):
|
||||
sum_hashes = ''
|
||||
for repo in etpRepositories:
|
||||
dbconn = self.openRepositoryDatabase(repo)
|
||||
sum_hashes += dbconn.tablesChecksum()
|
||||
return sum_hashes
|
||||
|
||||
# this function searches all the not installed packages available in the repositories
|
||||
def calculate_available_packages(self, branch = etpConst['branch']):
|
||||
|
||||
if self.xcache:
|
||||
repo_digest = self.all_repositories_checksum()
|
||||
disk_cache = self.dumpTools.loadobj(etpCache['world_available'])
|
||||
try:
|
||||
if disk_cache != None:
|
||||
if disk_cache['repo_digest'] == repo_digest and \
|
||||
disk_cache['branch'] == branch:
|
||||
return disk_cache['available']
|
||||
except:
|
||||
try:
|
||||
self.dumpTools.dumpobj(etpCache['world_available'], {})
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
available = set()
|
||||
self.setTotalCycles(len(etpRepositories))
|
||||
for repo in etpRepositories:
|
||||
dbconn = self.openRepositoryDatabase(repo)
|
||||
idpackages = dbconn.listAllIdpackages(branch = etpConst['branch'])
|
||||
count = 0
|
||||
maxlen = len(idpackages)
|
||||
for idpackage in idpackages:
|
||||
count += 1
|
||||
self.updateProgress("Calculating updates for %s" % (repo,), importance = 0, type = "info", back = True, header = "::", count = (count,maxlen), percent = True, footer = "::")
|
||||
# get key + slot
|
||||
key, slot = dbconn.retrieveKeySlot(idpackage)
|
||||
match = self.clientDbconn.atomMatch(key, matchSlot = slot)
|
||||
if match[0] == -1:
|
||||
available.add((idpackage,repo))
|
||||
self.cycleDone()
|
||||
|
||||
if self.xcache:
|
||||
try:
|
||||
mycache = {}
|
||||
mycache['repo_digest'] = repo_digest
|
||||
mycache['available'] = available.copy()
|
||||
mycache['branch'] = branch
|
||||
# save cache
|
||||
self.dumpTools.dumpobj(etpCache['world_available'], mycache)
|
||||
mycache.clear()
|
||||
del mycache
|
||||
except:
|
||||
self.dumpTools.dumpobj(etpCache['world_available'], {})
|
||||
|
||||
return available
|
||||
|
||||
def calculate_world_updates(self, empty_deps = False, branch = etpConst['branch']):
|
||||
|
||||
update = set()
|
||||
@@ -1258,8 +1314,8 @@ class EquoInterface(TextInterface):
|
||||
matchresults = self.atomMatch(myscopedata[1]+"/"+myscopedata[2], matchSlot = myscopedata[4], matchBranches = (branch,))
|
||||
if matchresults[0] != -1:
|
||||
mdbconn = self.openRepositoryDatabase(matchresults[1])
|
||||
matchatom = mdbconn.retrieveAtom(matchresults[0])
|
||||
update.add((matchatom,matchresults))
|
||||
#matchatom = mdbconn.retrieveAtom(matchresults[0])
|
||||
update.add(matchresults)
|
||||
else:
|
||||
remove.add(idpackage)
|
||||
# look for packages that would match key with any slot (for eg, gcc updates), slot changes handling
|
||||
@@ -1270,7 +1326,7 @@ class EquoInterface(TextInterface):
|
||||
# compare versions
|
||||
unsatisfied, satisfied = self.filterSatisfiedDependencies((matchatom,))
|
||||
if unsatisfied:
|
||||
update.add((matchatom,matchresults))
|
||||
update.add(matchresults)
|
||||
else:
|
||||
fine.add(myscopedata[0])
|
||||
|
||||
@@ -1331,7 +1387,7 @@ class EquoInterface(TextInterface):
|
||||
compiled_arch = mydbconn.retrieveDownloadURL(myidpackage)
|
||||
if compiled_arch.find("/"+etpSys['arch']+"/") == -1:
|
||||
return -3,atoms_contained
|
||||
atoms_contained.append([tbz2file,(int(myidpackage),basefile)])
|
||||
atoms_contained.append((int(myidpackage),basefile))
|
||||
mydbconn.closeDB()
|
||||
del mydbconn
|
||||
return 0,atoms_contained
|
||||
@@ -1349,8 +1405,7 @@ class EquoInterface(TextInterface):
|
||||
status = -1
|
||||
if update:
|
||||
# calculate install+removal queues
|
||||
matched_atoms = [x[1] for x in update]
|
||||
install, removal, status = self.retrieveInstallQueue(matched_atoms, empty_deps, deep_deps = False)
|
||||
install, removal, status = self.retrieveInstallQueue(update, empty_deps, deep_deps = False)
|
||||
# update data['removed']
|
||||
data['removed'] = [x for x in data['removed'] if x not in removal]
|
||||
data['runQueue'] += install
|
||||
|
||||
@@ -350,7 +350,8 @@ etpCache = {
|
||||
'install': 'resume_install', # resume cache (install)
|
||||
'remove': 'resume_remove', # resume cache (remove)
|
||||
'world': 'resume_world', # resume cache (world)
|
||||
'world_update': 'world_cache'
|
||||
'world_update': 'world_cache',
|
||||
'world_available': 'available_cache'
|
||||
}
|
||||
|
||||
# byte sizes of disk caches
|
||||
|
||||
@@ -359,6 +359,9 @@ class TextInterface:
|
||||
def cycleDone(self):
|
||||
return
|
||||
|
||||
def setTotalCycles(self, total):
|
||||
return
|
||||
|
||||
def outputInstanceTest(self):
|
||||
return
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ class Equo(EquoInterface):
|
||||
def cycleDone(self):
|
||||
self.progress.total.next()
|
||||
|
||||
def setTotalCycles(self, total):
|
||||
self.progress.total.setup( range(total) )
|
||||
|
||||
class GuiUrlFetcher(urlFetcher):
|
||||
""" hello my highness """
|
||||
|
||||
+4
-13
@@ -60,19 +60,10 @@ class YumexPackageInfo:
|
||||
cl = pkg.get_changelog()
|
||||
for l in cl:
|
||||
self.pkgChangeLog.write_line( "%s\n" % l )
|
||||
if pkg.action == 'u':
|
||||
if not pkg.obsolete:
|
||||
lst = self.yumbase.rpmdb.searchNevra(name=pkg.name)
|
||||
txt = _( "Updating : %s\n\n" ) % str(lst[0])
|
||||
self.pkgInfo.write_line( txt )
|
||||
else:
|
||||
obsoletes = self.yumbase.up.getObsoletesTuples( newest=1 )
|
||||
for ( obsoleting, installed ) in obsoletes:
|
||||
if obsoleting[0] == pkg.name:
|
||||
po = self.yumbase.rpmdb.searchPkgTuple( installed )[0]
|
||||
txt = _( "Obsoleting : %s\n\n" ) % str(po)
|
||||
self.pkgInfo.write_line( txt )
|
||||
break
|
||||
#if pkg.action == 'u':
|
||||
# lst = self.yumbase.rpmdb.searchNevra(name=pkg.name)
|
||||
# txt = _( "Updating : %s\n\n" ) % str(lst[0])
|
||||
# self.pkgInfo.write_line( txt )
|
||||
|
||||
self.writePkg( self.pkgInfo, pkg, 'Category : %s\n', "category", True )
|
||||
self.writePkg( self.pkgInfo, pkg, 'Name : %s\n', "name" )
|
||||
|
||||
@@ -179,18 +179,18 @@ class EntropyPackages:
|
||||
yield yp
|
||||
elif mask == 'available':
|
||||
# Get the rest of the available packages.
|
||||
for po in self.pkgSack.returnNewestByNameArch():
|
||||
if not self.isInst(po.name):
|
||||
yp = EntropyPackage(po,self.recent,True)
|
||||
yp.action = 'i'
|
||||
yield yp
|
||||
available = self.Entropy.calculate_available_packages()
|
||||
for pkgdata in available:
|
||||
yp = EntropyPackage(pkgdata, self.recent, False)
|
||||
yp.action = 'i'
|
||||
yield yp
|
||||
elif mask == 'updates':
|
||||
# get updates
|
||||
#XXX add empty_deps and branch switching support
|
||||
updates, remove, fine = self.Entropy.calculate_world_updates()
|
||||
del remove, fine
|
||||
for pkgdata in updates:
|
||||
yp = EntropyPackage(pkgdata[1], self.recent, False)
|
||||
yp = EntropyPackage(pkgdata, self.recent, False)
|
||||
yp.action = 'u'
|
||||
yp.color = color_update
|
||||
yield yp
|
||||
|
||||
Reference in New Issue
Block a user