[entropy.db] first chunk of major entropy.db code updates, create abstract class, move logic there, update API
This commit is contained in:
+38
-59
@@ -670,7 +670,7 @@ def search_reverse_dependencies(atoms, dbconn = None, Equo = None):
|
||||
|
||||
found_atom = dbconn.retrieveAtom(result[0])
|
||||
if repoMasked:
|
||||
idpackage_masked, idmasking_reason = dbconn.idpackageValidator(
|
||||
idpackage_masked, idmasking_reason = dbconn.maskFilter(
|
||||
result[0])
|
||||
|
||||
searchResults = dbconn.retrieveReverseDependencies(result[0],
|
||||
@@ -855,7 +855,7 @@ def search_orphaned_files(Equo = None):
|
||||
if Equo is None:
|
||||
Equo = EquoInterface()
|
||||
|
||||
if (not etpUi['quiet']):
|
||||
if not etpUi['quiet']:
|
||||
print_info(darkred(" @@ ") + \
|
||||
darkgreen("%s..." % (_("Orphans Search"),)))
|
||||
|
||||
@@ -863,12 +863,7 @@ def search_orphaned_files(Equo = None):
|
||||
|
||||
# start to list all files on the system:
|
||||
dirs = Equo.Settings()['system_dirs']
|
||||
filepath = entropy.tools.get_random_temp_file()
|
||||
if os.path.isfile(filepath):
|
||||
os.remove(filepath)
|
||||
tdbconn = Equo.open_generic_repository(filepath)
|
||||
tdbconn.initializeDatabase()
|
||||
tdbconn.dropAllIndexes()
|
||||
file_data = set()
|
||||
|
||||
import re
|
||||
reverse_symlink_map = Equo.Settings()['system_rev_symlinks']
|
||||
@@ -886,7 +881,7 @@ def search_orphaned_files(Equo = None):
|
||||
except RuntimeError: # maximum recursion?
|
||||
continue
|
||||
for currentdir, subdirs, files in wd:
|
||||
foundFiles = {}
|
||||
found_files = set()
|
||||
for filename in files:
|
||||
|
||||
filename = os.path.join(currentdir, filename)
|
||||
@@ -922,19 +917,16 @@ def search_orphaned_files(Equo = None):
|
||||
back = True
|
||||
)
|
||||
try:
|
||||
foundFiles[const_convert_to_unicode(filename)] = \
|
||||
const_convert_to_unicode("obj")
|
||||
found_files.add(const_convert_to_unicode(filename))
|
||||
except (UnicodeDecodeError, UnicodeEncodeError,) as e:
|
||||
if etpUi['quiet']:
|
||||
continue
|
||||
print_generic("!!! error on", filename, "skipping:", repr(e))
|
||||
|
||||
if foundFiles:
|
||||
tdbconn.insertContent(None, foundFiles)
|
||||
if found_files:
|
||||
file_data |= found_files
|
||||
|
||||
tdbconn.commitChanges()
|
||||
tdbconn._cursor().execute('select count(file) from content')
|
||||
totalfiles = tdbconn._cursor().fetchone()[0]
|
||||
totalfiles = len(file_data)
|
||||
|
||||
if not etpUi['quiet']:
|
||||
print_info(red(" @@ ") + blue("%s: " % (_("Analyzed directories"),) )+ \
|
||||
@@ -948,24 +940,21 @@ def search_orphaned_files(Equo = None):
|
||||
_("Now looking into Installed Packages database"),)))
|
||||
|
||||
|
||||
idpackages = clientDbconn.listAllIdpackages()
|
||||
idpackages = clientDbconn.listAllPackageIds()
|
||||
length = str(len(idpackages))
|
||||
count = 0
|
||||
|
||||
# create index on content
|
||||
tdbconn._cursor().execute(
|
||||
"CREATE INDEX IF NOT EXISTS contentindex_file ON content ( file );")
|
||||
|
||||
def gen_cont(idpackage):
|
||||
for path in clientDbconn.retrieveContent(idpackage):
|
||||
# reverse sym
|
||||
for sym_dir in reverse_symlink_map:
|
||||
if path.startswith(sym_dir):
|
||||
for sym_child in reverse_symlink_map[sym_dir]:
|
||||
yield (sym_child+path[len(sym_dir):],)
|
||||
yield sym_child+path[len(sym_dir):]
|
||||
# real path also
|
||||
yield (os.path.realpath(path),)
|
||||
yield (path,)
|
||||
dirname_real = os.path.realpath(os.path.dirname(path))
|
||||
yield os.path.join(dirname_real, os.path.basename(path))
|
||||
yield path
|
||||
|
||||
for idpackage in idpackages:
|
||||
|
||||
@@ -977,13 +966,10 @@ def search_orphaned_files(Equo = None):
|
||||
_("Intersecting with content of the package"),) ) + txt + \
|
||||
bold(str(atom)), back = True)
|
||||
|
||||
# remove from foundFiles
|
||||
tdbconn._cursor().executemany('delete from content where file = (?)',
|
||||
gen_cont(idpackage))
|
||||
# remove from file_data
|
||||
file_data -= set(gen_cont(idpackage))
|
||||
|
||||
tdbconn.commitChanges()
|
||||
tdbconn._cursor().execute('select count(file) from content')
|
||||
orpanedfiles = tdbconn._cursor().fetchone()[0]
|
||||
orpanedfiles = len(file_data)
|
||||
|
||||
if not etpUi['quiet']:
|
||||
print_info(red(" @@ ") + blue("%s: " % (
|
||||
@@ -996,20 +982,19 @@ def search_orphaned_files(Equo = None):
|
||||
print_info(red(" @@ ") + blue("%s: " % (
|
||||
_("Number of orphaned files"),) ) + bold(str(orpanedfiles)))
|
||||
|
||||
tdbconn._cursor().execute('select file from content order by file desc')
|
||||
fname = "/tmp/entropy-orphans.txt"
|
||||
f_out = open(fname, "wb")
|
||||
if not etpUi['quiet']:
|
||||
fname = "/tmp/equo-orphans.txt"
|
||||
f_out = open(fname, "w")
|
||||
print_info(red(" @@ ")+blue("%s: " % (_
|
||||
("Writing file to disk"),)) + bold(fname))
|
||||
|
||||
tdbconn._connection().text_factory = lambda x: const_convert_to_unicode(x)
|
||||
myfile = tdbconn._cursor().fetchone()
|
||||
|
||||
sizecount = 0
|
||||
while myfile:
|
||||
file_data = list(file_data)
|
||||
file_data.sort(reverse = True)
|
||||
|
||||
myfile = const_convert_to_rawstring(myfile[0])
|
||||
for myfile in file_data:
|
||||
|
||||
myfile = const_convert_to_rawstring(myfile)
|
||||
mysize = 0
|
||||
try:
|
||||
mysize += os.stat(myfile)[6]
|
||||
@@ -1017,26 +1002,20 @@ def search_orphaned_files(Equo = None):
|
||||
mysize = 0
|
||||
sizecount += mysize
|
||||
|
||||
if not etpUi['quiet']:
|
||||
f_out.write(myfile+"\n")
|
||||
else:
|
||||
f_out.write(myfile + const_convert_to_rawstring("\n"))
|
||||
if etpUi['quiet']:
|
||||
print_generic(myfile)
|
||||
|
||||
myfile = tdbconn._cursor().fetchone()
|
||||
f_out.flush()
|
||||
f_out.close()
|
||||
|
||||
humansize = entropy.tools.bytes_into_human(sizecount)
|
||||
if not etpUi['quiet']:
|
||||
print_info(red(" @@ ") + \
|
||||
blue("%s: " % (_("Total wasted space"),) ) + bold(humansize))
|
||||
f_out.flush()
|
||||
f_out.close()
|
||||
else:
|
||||
print_generic(humansize)
|
||||
|
||||
tdbconn.closeDB()
|
||||
if os.path.isfile(filepath):
|
||||
os.remove(filepath)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -1166,18 +1145,19 @@ def search_package(packages, Equo = None, get_results = False,
|
||||
try:
|
||||
|
||||
result = dbconn.searchPackages(package, slot = slot,
|
||||
tag = tag)
|
||||
if not result: # look for provide
|
||||
result = dbconn.searchProvide(package, slot = slot,
|
||||
tag = tag)
|
||||
tag = tag, just_id = True)
|
||||
if not result: # look for something else?
|
||||
pkg_id, rc = dbconn.atomMatch(package, matchSlot = slot)
|
||||
if pkg_id != -1:
|
||||
result = [pkg_id]
|
||||
if result:
|
||||
|
||||
my_found = True
|
||||
for pkg in result:
|
||||
for pkg_id in result:
|
||||
if get_results:
|
||||
rc_results.append(dbconn.retrieveAtom(pkg[1]))
|
||||
rc_results.append(dbconn.retrieveAtom(pkg_id))
|
||||
else:
|
||||
print_package_info(pkg[1], dbconn, Equo = Equo,
|
||||
print_package_info(pkg_id, dbconn, Equo = Equo,
|
||||
extended = etpUi['verbose'],
|
||||
clientSearch = from_client)
|
||||
|
||||
@@ -1590,7 +1570,7 @@ def print_package_info(idpackage, dbconn, clientSearch = False,
|
||||
repoinfo = ''
|
||||
desc = ''
|
||||
if showRepoOnQuiet:
|
||||
repoinfo = "[%s] " % (dbconn.dbname,)
|
||||
repoinfo = "[%s] " % (dbconn.reponame,)
|
||||
if showDescOnQuiet:
|
||||
desc = ' %s' % (dbconn.retrieveDescription(idpackage),)
|
||||
print_generic("%s%s%s" % (repoinfo, pkgatom, desc,))
|
||||
@@ -1630,7 +1610,7 @@ def print_package_info(idpackage, dbconn, clientSearch = False,
|
||||
|
||||
print_info(red(" @@ %s: " % (_("Package"),) ) + bold(pkgatom) + \
|
||||
" "+ blue("%s: " % (_("branch"),)) + bold(pkgbranch) + \
|
||||
", [" + purple(str(dbconn.dbname)) + "] ")
|
||||
", [" + purple(str(dbconn.reponame)) + "] ")
|
||||
if not strictOutput and extended:
|
||||
pkgname = dbconn.retrieveName(idpackage)
|
||||
pkgcat = dbconn.retrieveCategory(idpackage)
|
||||
@@ -1644,8 +1624,7 @@ def print_package_info(idpackage, dbconn, clientSearch = False,
|
||||
pkgmasked = False
|
||||
masking_reason = ''
|
||||
# check if it's masked
|
||||
idpackage_masked, idmasking_reason = dbconn.idpackageValidator(
|
||||
idpackage)
|
||||
idpackage_masked, idmasking_reason = dbconn.maskFilter(idpackage)
|
||||
if idpackage_masked == -1:
|
||||
pkgmasked = True
|
||||
masking_reason = ", %s" % (
|
||||
|
||||
+9
-12
@@ -197,7 +197,7 @@ def _database_counters(entropy_client):
|
||||
return rc
|
||||
|
||||
print_info(red(" %s..." % (_("Regenerating counters table"),) ))
|
||||
entropy_client.installed_repository().regenerateSpmUidTable(verbose = True)
|
||||
entropy_client.installed_repository().regenerateSpmUidMapping()
|
||||
print_info(red(" %s" % (
|
||||
_("Counters table regenerated. Look above for errors."),) ))
|
||||
return 0
|
||||
@@ -262,7 +262,7 @@ def _database_resurrect(entropy_client):
|
||||
os.remove(dbpath)
|
||||
dbc = entropy_client.open_generic_repository(dbpath,
|
||||
dbname = etpConst['clientdbid']) # don't do this at home
|
||||
dbc.initializeDatabase()
|
||||
dbc.initializeRepository()
|
||||
dbc.commitChanges()
|
||||
entropy_client._installed_repository = dbc
|
||||
mytxt = " %s %s" % (
|
||||
@@ -325,7 +325,7 @@ def _database_resurrect(entropy_client):
|
||||
print_info(mytxt)
|
||||
# get all idpackages
|
||||
dbconn = entropy_client.open_repository(repo)
|
||||
idpackages = dbconn.listAllIdpackages()
|
||||
idpackages = dbconn.listAllPackageIds()
|
||||
count = str(len(idpackages))
|
||||
cnt = 0
|
||||
for idpackage in idpackages:
|
||||
@@ -575,7 +575,7 @@ def _database_spmsync(entropy_client):
|
||||
mydata['name'], mydata['version'], mydata['versiontag'])
|
||||
|
||||
# look for atom in client database
|
||||
idpkgs = entropy_client.installed_repository().getIdpackages(myatom)
|
||||
idpkgs = entropy_client.installed_repository().getPackageIds(myatom)
|
||||
oldidpackages = sorted(idpkgs)
|
||||
oldidpackage = None
|
||||
if oldidpackages:
|
||||
@@ -627,7 +627,7 @@ def _database_generate(entropy_client):
|
||||
# try to collect current installed revisions if possible
|
||||
revisions_match = {}
|
||||
try:
|
||||
myids = entropy_client.installed_repository().listAllIdpackages()
|
||||
myids = entropy_client.installed_repository().listAllPackageIds()
|
||||
for myid in myids:
|
||||
myatom = entropy_client.installed_repository().retrieveAtom(myid)
|
||||
myrevision = entropy_client.installed_repository().retrieveRevision(myid)
|
||||
@@ -652,12 +652,9 @@ def _database_generate(entropy_client):
|
||||
)
|
||||
print_info(mytxt, back = True)
|
||||
entropy_client.reopen_installed_repository()
|
||||
dbfile = entropy_client.installed_repository().dbFile
|
||||
entropy_client.installed_repository().closeDB()
|
||||
if os.path.isfile(dbfile):
|
||||
os.remove(dbfile)
|
||||
entropy_client._open_installed_repository()
|
||||
entropy_client.installed_repository().initializeDatabase()
|
||||
entropy_client.installed_repository().initializeRepository()
|
||||
mytxt = darkred(" %s %s") % (
|
||||
_("Database reinitialized correctly at"),
|
||||
bold(etpConst['etpdatabaseclientfilepath']),
|
||||
@@ -735,7 +732,7 @@ def _database_check(entropy_client):
|
||||
importance = 2,
|
||||
level = "warning"
|
||||
)
|
||||
idpkgs = entropy_client.installed_repository().listAllIdpackages()
|
||||
idpkgs = entropy_client.installed_repository().listAllPackageIds()
|
||||
length = len(idpkgs)
|
||||
count = 0
|
||||
errors = False
|
||||
@@ -830,7 +827,7 @@ def _getinfo(entropy_client):
|
||||
# print db info
|
||||
info['Removal internal protected directories'] = cdbconn.listConfigProtectEntries()
|
||||
info['Removal internal protected directory masks'] = cdbconn.listConfigProtectEntries(mask = True)
|
||||
info['Total installed packages'] = len(cdbconn.listAllIdpackages())
|
||||
info['Total installed packages'] = len(cdbconn.listAllPackageIds())
|
||||
|
||||
# repository databases info (if found on the system)
|
||||
info['Repository databases'] = {}
|
||||
@@ -842,7 +839,7 @@ def _getinfo(entropy_client):
|
||||
info['Repository databases'][x] = {}
|
||||
info['Repository databases'][x]['Installation internal protected directories'] = dbconn.listConfigProtectEntries()
|
||||
info['Repository databases'][x]['Installation internal protected directory masks'] = dbconn.listConfigProtectEntries(mask = True)
|
||||
info['Repository databases'][x]['Total available packages'] = len(dbconn.listAllIdpackages())
|
||||
info['Repository databases'][x]['Total available packages'] = len(dbconn.listAllPackageIds())
|
||||
info['Repository databases'][x]['Database revision'] = entropy_client.get_repository_revision(x)
|
||||
|
||||
keys = sorted(info)
|
||||
|
||||
@@ -235,7 +235,7 @@ def inflate_handler(entropy_client, mytbz2s, savedir):
|
||||
dbpath = etpConst['packagestmpdir']+os.path.sep+str(entropy.tools.get_random_number())
|
||||
# create
|
||||
mydbconn = entropy_client.open_generic_repository(dbpath)
|
||||
mydbconn.initializeDatabase()
|
||||
mydbconn.initializeRepository()
|
||||
idpackage, yyy, xxx = mydbconn.addPackage(mydata, revision = mydata['revision'])
|
||||
del yyy, xxx
|
||||
Qa.test_missing_dependencies([idpackage], mydbconn)
|
||||
@@ -358,7 +358,7 @@ def smartpackagegenerator(entropy_client, matched_pkgs):
|
||||
# create master database
|
||||
dbfile = unpackdir+"/db/merged.db"
|
||||
mergeDbconn = entropy_client.open_generic_repository(dbfile, dbname = "client")
|
||||
mergeDbconn.initializeDatabase()
|
||||
mergeDbconn.initializeRepository()
|
||||
tmpdbfile = dbfile+"--readingdata"
|
||||
for package in matched_pkgs:
|
||||
print_info(darkgreen(" * ")+brown(matchedAtoms[package]['atom'])+": "+red(_("collecting Entropy metadata")))
|
||||
@@ -367,7 +367,7 @@ def smartpackagegenerator(entropy_client, matched_pkgs):
|
||||
matchedAtoms[package]['download'], tmpdbfile)
|
||||
# read db and add data to mergeDbconn
|
||||
mydbconn = entropy_client.open_generic_repository(tmpdbfile)
|
||||
idpackages = mydbconn.listAllIdpackages()
|
||||
idpackages = mydbconn.listAllPackageIds()
|
||||
|
||||
for myidpackage in idpackages:
|
||||
data = mydbconn.getPackageData(myidpackage)
|
||||
@@ -376,11 +376,11 @@ def smartpackagegenerator(entropy_client, matched_pkgs):
|
||||
xpakdata = xpaktools.read_xpak(etpConst['entropyworkdir'] + \
|
||||
os.path.sep + matchedAtoms[package]['download'])
|
||||
else:
|
||||
xpakdata = mydbconn.retrieveXpakMetadata(myidpackage) # already a smart package
|
||||
xpakdata = mydbconn.retrieveSpmMetadata(myidpackage) # already a smart package
|
||||
# add
|
||||
idpk, rev, y = mergeDbconn.handlePackage(data, forcedRevision = matchedAtoms[package]['revision']) # get the original rev
|
||||
del y
|
||||
mergeDbconn.storeXpakMetadata(idpk, xpakdata)
|
||||
mergeDbconn.storeSpmMetadata(idpk, xpakdata)
|
||||
mydbconn.closeDB()
|
||||
os.remove(tmpdbfile)
|
||||
|
||||
|
||||
+16
-15
@@ -308,12 +308,13 @@ def show_config_files_to_update(entropy_client):
|
||||
def _upgrade_package_handle_calculation(entropy_client, resume, replay, onlyfetch):
|
||||
if not resume:
|
||||
|
||||
try:
|
||||
update, remove, fine, spm_fine = entropy_client.calculate_updates(
|
||||
empty = replay)
|
||||
except SystemDatabaseError:
|
||||
# handled in equo.py
|
||||
raise
|
||||
with entropy_client.Cacher():
|
||||
try:
|
||||
update, remove, fine, \
|
||||
spm_fine = entropy_client.calculate_updates(empty = replay)
|
||||
except SystemDatabaseError:
|
||||
# handled in equo.py
|
||||
raise
|
||||
|
||||
if etpUi['verbose'] or etpUi['pretend']:
|
||||
print_info(red(" @@ ") + "%s => %s" % (
|
||||
@@ -416,7 +417,7 @@ def upgrade_packages(entropy_client, onlyfetch = False, replay = False,
|
||||
|
||||
# verify that client database idpackage still exist,
|
||||
# validate here before passing removePackage() wrong info
|
||||
remove = [x for x in remove if entropy_client.installed_repository().isIdpackageAvailable(x)]
|
||||
remove = [x for x in remove if entropy_client.installed_repository().isPackageIdAvailable(x)]
|
||||
# Filter out packages installed from unavailable repositories, this is
|
||||
# mainly required to allow 3rd party packages installation without
|
||||
# erroneously inform user about unavailability.
|
||||
@@ -573,9 +574,9 @@ def _show_masked_pkg_info(entropy_client, package, from_user = True):
|
||||
riddep = rdbconn.searchDependency(atom)
|
||||
if riddep == -1:
|
||||
continue
|
||||
ridpackages = rdbconn.searchIdpackageFromIddependency(riddep)
|
||||
ridpackages = rdbconn.searchPackageIdFromDependencyId(riddep)
|
||||
for i in ridpackages:
|
||||
i, r = rdbconn.idpackageValidator(i)
|
||||
i, r = rdbconn.maskFilter(i)
|
||||
if i == -1:
|
||||
continue
|
||||
iatom = rdbconn.retrieveAtom(i)
|
||||
@@ -585,7 +586,7 @@ def _show_masked_pkg_info(entropy_client, package, from_user = True):
|
||||
def get_masked_package_reason(match):
|
||||
idpackage, repoid = match
|
||||
dbconn = entropy_client.open_repository(repoid)
|
||||
idpackage, idreason = dbconn.idpackageValidator(idpackage)
|
||||
idpackage, idreason = dbconn.maskFilter(idpackage)
|
||||
masked = False
|
||||
if idpackage == -1:
|
||||
masked = True
|
||||
@@ -1753,7 +1754,7 @@ def remove_packages(entropy_client, packages = None, atomsdata = None,
|
||||
found_pkg_atoms = []
|
||||
if atomsdata:
|
||||
for idpackage in atomsdata:
|
||||
if not installed_repo.isIdpackageAvailable(idpackage):
|
||||
if not installed_repo.isPackageIdAvailable(idpackage):
|
||||
continue
|
||||
found_pkg_atoms.append(idpackage)
|
||||
else:
|
||||
@@ -2032,7 +2033,7 @@ def _unused_packages_test(entropy_client, do_size_sort = False):
|
||||
|
||||
def unused_packages_test():
|
||||
inst_repo = entropy_client.installed_repository()
|
||||
return [x for x in inst_repo.retrieveUnusedIdpackages() if \
|
||||
return [x for x in inst_repo.retrieveUnusedPackageIds() if \
|
||||
entropy_client.validate_package_removal(x)]
|
||||
|
||||
data = [(entropy_client.installed_repository().retrieveOnDiskSize(x), x, \
|
||||
@@ -2066,7 +2067,7 @@ def _dependencies_test(entropy_client):
|
||||
|
||||
riddep = inst_repo.searchDependency(dep)
|
||||
if riddep != -1:
|
||||
ridpackages = inst_repo.searchIdpackageFromIddependency(riddep)
|
||||
ridpackages = inst_repo.searchPackageIdFromDependencyId(riddep)
|
||||
for i in ridpackages:
|
||||
iatom = inst_repo.retrieveAtom(i)
|
||||
if iatom:
|
||||
@@ -2081,9 +2082,9 @@ def _dependencies_test(entropy_client):
|
||||
iddep = inst_repo.searchDependency(dep)
|
||||
if iddep == -1:
|
||||
continue
|
||||
c_idpackages = inst_repo.searchIdpackageFromIddependency(iddep)
|
||||
c_idpackages = inst_repo.searchPackageIdFromDependencyId(iddep)
|
||||
for c_idpackage in c_idpackages:
|
||||
if not inst_repo.isIdpackageAvailable(c_idpackage):
|
||||
if not inst_repo.isPackageIdAvailable(c_idpackage):
|
||||
continue
|
||||
key, slot = inst_repo.retrieveKeySlot(c_idpackage)
|
||||
key_slot = "%s%s%s" % (key, etpConst['entropyslotprefix'],
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
|
||||
0.99.50:
|
||||
|
||||
- sulfur: make use of provided_mime (and desktop_mime) metadata
|
||||
- move repository sync() code inside EntropyRepository? (makes sense)
|
||||
|
||||
- entropy.server: expanding queues/whatever sort files when printing
|
||||
- Client.open_generic_repository: fix arguments
|
||||
- sulfur: make use of provided_mime (and desktop_mime) metadata
|
||||
- entropy.fetchers API docs
|
||||
- entropy.server API docs
|
||||
- entropy.client API docs
|
||||
@@ -12,6 +15,7 @@
|
||||
- entropy.db.search* unittest
|
||||
- entropy package metadata .dtd specs
|
||||
- complete API documentation
|
||||
- entropy.db: remove @deprecated methods
|
||||
|
||||
2.0:
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from entropy.output import bold, darkgreen, darkred, blue, red, purple
|
||||
from entropy.i18n import _
|
||||
from entropy.db.exceptions import IntegrityError, OperationalError, Error, \
|
||||
DatabaseError, InterfaceError
|
||||
from entropy.db import EntropyRepository
|
||||
from entropy.db.skel import EntropyRepositoryBase
|
||||
|
||||
import entropy.tools
|
||||
|
||||
@@ -27,7 +27,7 @@ class CalculatorsMixin:
|
||||
def dependencies_test(self):
|
||||
|
||||
# get all the installed packages
|
||||
installed_packages = self._installed_repository.listAllIdpackages()
|
||||
installed_packages = self._installed_repository.listAllPackageIds()
|
||||
|
||||
pdepend_id = etpConst['dependency_type_ids']['pdepend_id']
|
||||
bdepend_id = etpConst['dependency_type_ids']['bdepend_id']
|
||||
@@ -171,7 +171,7 @@ class CalculatorsMixin:
|
||||
#if isinstance(m_id, tuple):
|
||||
# m_id = m_id[0]
|
||||
m_db = self.open_repository(m_repo)
|
||||
if not m_db.isIdpackageAvailable(m_id):
|
||||
if not m_db.isPackageIdAvailable(m_id):
|
||||
return None
|
||||
else:
|
||||
# (14479, 'sabayonlinux.org')
|
||||
@@ -182,7 +182,7 @@ class CalculatorsMixin:
|
||||
m_db = self.open_repository(m_repo)
|
||||
if not const_isnumber(m_id):
|
||||
return None
|
||||
if not m_db.isIdpackageAvailable(m_id):
|
||||
if not m_db.isPackageIdAvailable(m_id):
|
||||
return None
|
||||
|
||||
return cached_obj
|
||||
@@ -254,7 +254,7 @@ class CalculatorsMixin:
|
||||
query_data, query_rc = dbconn.atomMatch(
|
||||
atom,
|
||||
matchSlot = match_slot,
|
||||
packagesFilter = mask_filter,
|
||||
maskFilter = mask_filter,
|
||||
extendedResults = extended_results,
|
||||
useCache = xuse_cache
|
||||
)
|
||||
@@ -312,7 +312,7 @@ class CalculatorsMixin:
|
||||
query_data, query_rc = dbconn.atomMatch(
|
||||
atom,
|
||||
matchSlot = match_slot,
|
||||
packagesFilter = mask_filter,
|
||||
maskFilter = mask_filter,
|
||||
multiMatch = True,
|
||||
extendedResults = extended_results
|
||||
)
|
||||
@@ -329,7 +329,7 @@ class CalculatorsMixin:
|
||||
query_data, query_rc = dbconn.atomMatch(
|
||||
atom,
|
||||
matchSlot = match_slot,
|
||||
packagesFilter = mask_filter,
|
||||
maskFilter = mask_filter,
|
||||
multiMatch = True,
|
||||
extendedResults = extended_results
|
||||
)
|
||||
@@ -497,7 +497,7 @@ class CalculatorsMixin:
|
||||
# WARN: unfortunately, need to deal with Portage (and other
|
||||
# backends) old-style PROVIDE metadata
|
||||
if entropy.tools.dep_getcat(dependency) == \
|
||||
EntropyRepository.VIRTUAL_META_PACKAGE_CATEGORY:
|
||||
EntropyRepositoryBase.VIRTUAL_META_PACKAGE_CATEGORY:
|
||||
provide_stop = False
|
||||
for c_id in c_ids:
|
||||
# optimize speed with a trick
|
||||
@@ -840,7 +840,7 @@ class CalculatorsMixin:
|
||||
first_element = False
|
||||
# we need to check if first element is masked because of
|
||||
# course, we don't trust function caller.
|
||||
mask_pkg_id, idreason = repo_db.idpackageValidator(pkg_id)
|
||||
mask_pkg_id, idreason = repo_db.maskFilter(pkg_id)
|
||||
if mask_pkg_id == -1:
|
||||
mask_atom = repo_db.retrieveAtom(pkg_id)
|
||||
if mask_atom is None:
|
||||
@@ -1348,7 +1348,7 @@ class CalculatorsMixin:
|
||||
|
||||
repo_db = self.open_repository(repo_id)
|
||||
# validate package
|
||||
if not repo_db.isIdpackageAvailable(idpackage):
|
||||
if not repo_db.isPackageIdAvailable(idpackage):
|
||||
continue
|
||||
|
||||
count += 1
|
||||
@@ -1447,8 +1447,8 @@ class CalculatorsMixin:
|
||||
continue
|
||||
try:
|
||||
# db may be corrupted, we cannot deal with it here
|
||||
idpackages = [x for x in dbconn.listAllIdpackages(
|
||||
order_by = 'atom') if dbconn.idpackageValidator(x)[0] != -1]
|
||||
idpackages = [x for x in dbconn.listAllPackageIds(
|
||||
order_by = 'atom') if dbconn.maskFilter(x)[0] != -1]
|
||||
except OperationalError:
|
||||
continue
|
||||
count = 0
|
||||
@@ -1628,7 +1628,7 @@ class CalculatorsMixin:
|
||||
|
||||
# get all the installed packages
|
||||
try:
|
||||
idpackages = self._installed_repository.listAllIdpackages(
|
||||
idpackages = self._installed_repository.listAllPackageIds(
|
||||
order_by = 'atom')
|
||||
except OperationalError:
|
||||
# client db is broken!
|
||||
@@ -1782,7 +1782,7 @@ class CalculatorsMixin:
|
||||
match_id, match_repo = package_match
|
||||
mydbconn = self.open_repository(match_repo)
|
||||
myatom = mydbconn.retrieveAtom(match_id)
|
||||
idpackage, idreason = mydbconn.idpackageValidator(match_id)
|
||||
idpackage, idreason = mydbconn.maskFilter(match_id)
|
||||
if idpackage == -1:
|
||||
treelevel += 1
|
||||
if atoms:
|
||||
@@ -1825,7 +1825,7 @@ class CalculatorsMixin:
|
||||
|
||||
if idpackage != -1:
|
||||
# doing even here because atomMatch with
|
||||
# packagesFilter = False can pull something different
|
||||
# maskFilter = False can pull something different
|
||||
matchfilter.add((idpackage, repoid))
|
||||
|
||||
# collect masked
|
||||
@@ -1837,8 +1837,7 @@ class CalculatorsMixin:
|
||||
if treelevel not in maskedtree and not flat:
|
||||
maskedtree[treelevel] = {}
|
||||
dbconn = self.open_repository(repoid)
|
||||
vidpackage, idreason = dbconn.idpackageValidator(
|
||||
idpackage)
|
||||
vidpackage, idreason = dbconn.maskFilter(idpackage)
|
||||
if atoms:
|
||||
mydict = {dbconn.retrieveAtom(idpackage): idreason}
|
||||
else:
|
||||
@@ -1978,7 +1977,7 @@ class CalculatorsMixin:
|
||||
Return removal queue (list of installed packages identifiers).
|
||||
|
||||
@param package_identifiers: list of package identifiers proposed
|
||||
for removal (returned by Client.installed_repository().listAllIdpackages())
|
||||
for removal (returned by Client.installed_repository().listAllPackageIds())
|
||||
@type package_identifiers: list
|
||||
@keyword deep: deeply scan inverse dependencies to include unused
|
||||
packages
|
||||
|
||||
@@ -100,16 +100,13 @@ class RepositoryMixin:
|
||||
# to avoid having zillions of open files when loading a lot of EquoInterfaces
|
||||
self.close_repositories(mask_clear = False)
|
||||
|
||||
def __get_repository_cache_key(self, repoid):
|
||||
return (repoid, etpConst['systemroot'],)
|
||||
|
||||
def _init_generic_temp_repository(self, repoid, description,
|
||||
package_mirrors = None, temp_file = None):
|
||||
if package_mirrors is None:
|
||||
package_mirrors = []
|
||||
|
||||
dbc = self.open_temp_repository(dbname = repoid, temp_file = temp_file)
|
||||
repo_key = self.__get_repository_cache_key(repoid)
|
||||
repo_key = (repoid, etpConst['systemroot'],)
|
||||
self._memory_db_instances[repo_key] = dbc
|
||||
|
||||
# add to self._settings['repositories']['available']
|
||||
@@ -118,7 +115,7 @@ class RepositoryMixin:
|
||||
'__temporary__': True,
|
||||
'description': description,
|
||||
'packages': package_mirrors,
|
||||
'dbpath': dbc.dbFile,
|
||||
'dbpath': temp_file,
|
||||
}
|
||||
self.add_repository(repodata)
|
||||
return dbc
|
||||
@@ -153,19 +150,16 @@ class RepositoryMixin:
|
||||
if repoid == etpConst['clientdbid']:
|
||||
return self._installed_repository
|
||||
|
||||
key = self.__get_repository_cache_key(repoid)
|
||||
if key not in self._repodb_cache:
|
||||
dbconn = self._load_repository_database(repoid,
|
||||
xcache = self.xcache, indexing = self.indexing)
|
||||
try:
|
||||
dbconn.checkDatabaseApi()
|
||||
except (OperationalError, TypeError,):
|
||||
pass
|
||||
key = (repoid, etpConst['systemroot'],)
|
||||
cached = self._repodb_cache.get(key)
|
||||
if cached is not None:
|
||||
return cached
|
||||
|
||||
self._repodb_cache[key] = dbconn
|
||||
return dbconn
|
||||
dbconn = self._load_repository_database(repoid,
|
||||
xcache = self.xcache, indexing = self.indexing)
|
||||
|
||||
return self._repodb_cache.get(key)
|
||||
self._repodb_cache[key] = dbconn
|
||||
return dbconn
|
||||
|
||||
def _load_repository_database(self, repoid, xcache = True, indexing = True):
|
||||
|
||||
@@ -186,7 +180,7 @@ class RepositoryMixin:
|
||||
raise RepositoryError("RepositoryError: %s" % (t,))
|
||||
|
||||
if repo_data[repoid].get('__temporary__'):
|
||||
repo_key = self.__get_repository_cache_key(repoid)
|
||||
repo_key = (repoid, etpConst['systemroot'],)
|
||||
conn = self._memory_db_instances.get(repo_key)
|
||||
else:
|
||||
dbfile = os.path.join(repo_data[repoid]['dbpath'],
|
||||
@@ -318,7 +312,7 @@ class RepositoryMixin:
|
||||
self.__save_repository_settings(repodata, remove = True)
|
||||
self._settings.clear()
|
||||
|
||||
repo_mem_key = self.__get_repository_cache_key(repoid)
|
||||
repo_mem_key = (repoid, etpConst['systemroot'],)
|
||||
mem_inst = self._memory_db_instances.pop(repo_mem_key, None)
|
||||
if isinstance(mem_inst, EntropyRepository):
|
||||
mem_inst.closeDB()
|
||||
@@ -515,7 +509,7 @@ class RepositoryMixin:
|
||||
# read all idpackages
|
||||
try:
|
||||
# all branches admitted from external files
|
||||
myidpackages = mydbconn.listAllIdpackages()
|
||||
myidpackages = mydbconn.listAllPackageIds()
|
||||
except (AttributeError, DatabaseError, IntegrityError,
|
||||
OperationalError,):
|
||||
return -2, atoms_contained
|
||||
@@ -668,7 +662,7 @@ class RepositoryMixin:
|
||||
temporary = True
|
||||
)
|
||||
self._add_plugin_to_client_repository(dbc, dbname)
|
||||
dbc.initializeDatabase()
|
||||
dbc.initializeRepository()
|
||||
return dbc
|
||||
|
||||
def backup_repository(self, dbpath, backup_dir = None, silent = False,
|
||||
@@ -1265,7 +1259,7 @@ class MiscMixin:
|
||||
if not wl: # no whitelist available
|
||||
return True
|
||||
|
||||
keys = dbconn.retrieveLicensedataKeys(pkg_id)
|
||||
keys = dbconn.retrieveLicenseDataKeys(pkg_id)
|
||||
keys = [x for x in keys if x not in wl]
|
||||
if keys:
|
||||
return False
|
||||
@@ -1284,7 +1278,7 @@ class MiscMixin:
|
||||
if not wl:
|
||||
continue
|
||||
try:
|
||||
keys = dbconn.retrieveLicensedataKeys(pkg_id)
|
||||
keys = dbconn.retrieveLicenseDataKeys(pkg_id)
|
||||
except OperationalError:
|
||||
# it has to be fault-tolerant, cope with missing tables
|
||||
continue
|
||||
@@ -1405,7 +1399,7 @@ class MiscMixin:
|
||||
tmp_fd, tmp_path = tempfile.mkstemp()
|
||||
os.close(tmp_fd)
|
||||
dbconn = self.open_generic_repository(tmp_path)
|
||||
dbconn.initializeDatabase()
|
||||
dbconn.initializeRepository()
|
||||
dbconn.addPackage(data, revision = data['revision'])
|
||||
if treeupdates_actions != None:
|
||||
dbconn.bumpTreeUpdatesActions(treeupdates_actions)
|
||||
@@ -1524,7 +1518,7 @@ class MatchMixin:
|
||||
def is_package_masked(self, package_match, live_check = True):
|
||||
m_id, m_repo = package_match
|
||||
dbconn = self.open_repository(m_repo)
|
||||
idpackage, idreason = dbconn.idpackageValidator(m_id, live = live_check)
|
||||
idpackage, idreason = dbconn.maskFilter(m_id, live = live_check)
|
||||
if idpackage != -1:
|
||||
return False
|
||||
return True
|
||||
@@ -1535,7 +1529,7 @@ class MatchMixin:
|
||||
if m_repo not in self._enabled_repos:
|
||||
return False
|
||||
dbconn = self.open_repository(m_repo)
|
||||
idpackage, idreason = dbconn.idpackageValidator(m_id, live = live_check)
|
||||
idpackage, idreason = dbconn.maskFilter(m_id, live = live_check)
|
||||
if idpackage != -1:
|
||||
return False
|
||||
|
||||
@@ -1552,7 +1546,7 @@ class MatchMixin:
|
||||
if m_repo not in self._enabled_repos:
|
||||
return False
|
||||
dbconn = self.open_repository(m_repo)
|
||||
idpackage, idreason = dbconn.idpackageValidator(m_id, live = live_check)
|
||||
idpackage, idreason = dbconn.maskFilter(m_id, live = live_check)
|
||||
if idpackage == -1:
|
||||
return False
|
||||
|
||||
|
||||
@@ -1017,7 +1017,7 @@ class Package:
|
||||
# for other pkgs with same atom but different tag (which is an
|
||||
# entropy-only metadatum)
|
||||
test_atom = entropy.tools.remove_tag(self.pkgmeta['removeatom'])
|
||||
others_installed = self._entropy.installed_repository().getIdpackages(test_atom)
|
||||
others_installed = self._entropy.installed_repository().getPackageIds(test_atom)
|
||||
|
||||
# It's obvious that clientdb cannot have more than one idpackage
|
||||
# featuring the same "atom" value, but still, let's be fault-tolerant.
|
||||
@@ -1509,7 +1509,7 @@ class Package:
|
||||
|
||||
# it is safe to consider that package dbs coming from repos
|
||||
# contain only one entry
|
||||
pkg_idpackage = sorted(pkg_dbconn.listAllIdpackages())[0]
|
||||
pkg_idpackage = sorted(pkg_dbconn.listAllPackageIds())[0]
|
||||
content = pkg_dbconn.retrieveContent(
|
||||
pkg_idpackage, extended = True,
|
||||
formatted = True, insert_formatted = True
|
||||
@@ -2771,7 +2771,7 @@ class Package:
|
||||
def _removeconflict_step(self):
|
||||
|
||||
for idpackage in self.pkgmeta['conflicts']:
|
||||
if not self._entropy.installed_repository().isIdpackageAvailable(idpackage):
|
||||
if not self._entropy.installed_repository().isPackageIdAvailable(idpackage):
|
||||
continue
|
||||
|
||||
pkg = self._entropy.Package()
|
||||
@@ -3098,7 +3098,7 @@ class Package:
|
||||
|
||||
idpackage = self._package_match[0]
|
||||
|
||||
if not self._entropy.installed_repository().isIdpackageAvailable(
|
||||
if not self._entropy.installed_repository().isPackageIdAvailable(
|
||||
idpackage):
|
||||
self.pkgmeta['remove_installed_vanished'] = True
|
||||
return 0
|
||||
@@ -3123,7 +3123,7 @@ class Package:
|
||||
self.pkgmeta['removecontent'] = \
|
||||
self._entropy.installed_repository().retrieveContent(idpackage)
|
||||
self.pkgmeta['triggers']['remove'] = \
|
||||
self._entropy.installed_repository().getTriggerInfo(idpackage)
|
||||
self._entropy.installed_repository().getTriggerData(idpackage)
|
||||
if self.pkgmeta['triggers']['remove'] is None:
|
||||
self.pkgmeta['remove_installed_vanished'] = True
|
||||
return 0
|
||||
@@ -3268,7 +3268,7 @@ class Package:
|
||||
self.pkgmeta['removeidpackage'] = inst_idpackage
|
||||
|
||||
if self.pkgmeta['removeidpackage'] != -1:
|
||||
avail = inst_repo.isIdpackageAvailable(
|
||||
avail = inst_repo.isPackageIdAvailable(
|
||||
self.pkgmeta['removeidpackage'])
|
||||
if avail:
|
||||
inst_atom = inst_repo.retrieveAtom(
|
||||
@@ -3314,7 +3314,7 @@ class Package:
|
||||
# compare both versions and if they match, disable removeidpackage
|
||||
if self.pkgmeta['removeidpackage'] != -1:
|
||||
|
||||
trigger_data = inst_repo.getTriggerInfo(
|
||||
trigger_data = inst_repo.getTriggerData(
|
||||
self.pkgmeta['removeidpackage'])
|
||||
if trigger_data is None:
|
||||
# installed repository entry is corrupted
|
||||
@@ -3357,7 +3357,7 @@ class Package:
|
||||
self.pkgmeta['steps'].append("postinstall")
|
||||
self.pkgmeta['steps'].append("cleanup")
|
||||
|
||||
self.pkgmeta['triggers']['install'] = dbconn.getTriggerInfo(idpackage)
|
||||
self.pkgmeta['triggers']['install'] = dbconn.getTriggerData(idpackage)
|
||||
if self.pkgmeta['triggers']['install'] is None:
|
||||
# wtf!?
|
||||
return 1
|
||||
|
||||
@@ -690,7 +690,7 @@ class Repository:
|
||||
return False
|
||||
|
||||
try:
|
||||
myidpackages = mydbconn.listAllIdpackages()
|
||||
myidpackages = mydbconn.listAllPackageIds()
|
||||
except (DatabaseError, IntegrityError, OperationalError,):
|
||||
mydbconn.closeDB()
|
||||
self.__eapi3_close(eapi3_interface, session)
|
||||
@@ -931,7 +931,7 @@ class Repository:
|
||||
try:
|
||||
mydbconn.addPackage(
|
||||
mydata, revision = mydata['revision'],
|
||||
idpackage = idpackage, do_commit = False,
|
||||
package_id = idpackage, do_commit = False,
|
||||
formatted_content = True
|
||||
)
|
||||
except (Error,) as err:
|
||||
@@ -1844,7 +1844,7 @@ class Repository:
|
||||
)
|
||||
dbconn = self._entropy.open_generic_repository(dbfile,
|
||||
xcache = False, indexing_override = False)
|
||||
rc = dbconn.doDatabaseImport(dumpfile, dbfile)
|
||||
rc = dbconn.importRepository(dumpfile, dbfile)
|
||||
dbconn.closeDB()
|
||||
return rc
|
||||
|
||||
@@ -2062,14 +2062,10 @@ class Repository:
|
||||
dbconn = self._entropy.open_repository(repo)
|
||||
dbconn.createAllIndexes()
|
||||
dbconn.commitChanges(force = True)
|
||||
# get list of indexes
|
||||
repo_indexes = dbconn.listAllIndexes()
|
||||
if self._entropy.installed_repository() is not None:
|
||||
try: # client db can be absent
|
||||
client_indexes = self._entropy.installed_repository().listAllIndexes()
|
||||
if repo_indexes != client_indexes:
|
||||
self._entropy.installed_repository().createAllIndexes()
|
||||
except:
|
||||
self._entropy.installed_repository().createAllIndexes()
|
||||
except (OperationalError, IntegrityError,):
|
||||
pass
|
||||
const_set_nice_level(old_prio)
|
||||
|
||||
|
||||
@@ -448,8 +448,7 @@ def const_default_settings(rootdir):
|
||||
'etpdatabaseclientfilepath': default_etp_dir + \
|
||||
default_etp_client_repodir + default_etp_dbdir + os.path.sep + \
|
||||
default_etp_dbclientfile,
|
||||
# prefix of the name of self.dbname in
|
||||
# entropy.db.LocalRepository class for the repositories
|
||||
# prefix of the name of EntropyRepository.reponame
|
||||
'dbnamerepoprefix': "repo_",
|
||||
# prefix of database backups
|
||||
'dbbackupprefix': 'etp_backup_',
|
||||
|
||||
@@ -61,7 +61,7 @@ class Singleton(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
class EntropyPluginStore:
|
||||
class EntropyPluginStore(object):
|
||||
|
||||
"""
|
||||
This is a base class for handling a map of plugin objects by providing
|
||||
@@ -69,6 +69,7 @@ class EntropyPluginStore:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
object.__init__(self)
|
||||
self.__plugins = {}
|
||||
|
||||
def get_plugins(self):
|
||||
|
||||
+820
-4150
File diff suppressed because it is too large
Load Diff
@@ -1,143 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
|
||||
@author: Fabio Erculiani <lxnay@sabayon.org>
|
||||
@contact: lxnay@sabayon.org
|
||||
@copyright: Fabio Erculiani
|
||||
@license: GPL-2
|
||||
|
||||
B{Entropy Framework repository database plugin store module}.
|
||||
|
||||
"""
|
||||
from entropy.core import EntropyPluginStore
|
||||
from entropy.db.skel import EntropyRepositoryPlugin
|
||||
|
||||
class EntropyRepositoryPluginStore(EntropyPluginStore):
|
||||
|
||||
"""
|
||||
EntropyRepository plugin interface. This is the EntropyRepository part
|
||||
aimed to handle connected plugins.
|
||||
"""
|
||||
|
||||
_PERMANENT_PLUGINS = {}
|
||||
|
||||
def __init__(self):
|
||||
EntropyPluginStore.__init__(self)
|
||||
permanent_plugs = EntropyRepositoryPluginStore.get_permanent_plugins()
|
||||
for plug in permanent_plugs.values():
|
||||
plug.add_plugin_hook(self)
|
||||
|
||||
def add_plugin(self, entropy_repository_plugin):
|
||||
"""
|
||||
Overloaded from EntropyPluginStore, adds support for hooks execution.
|
||||
"""
|
||||
inst = entropy_repository_plugin
|
||||
if not isinstance(inst, EntropyRepositoryPlugin):
|
||||
raise AttributeError("EntropyRepositoryPluginStore: " + \
|
||||
"expected valid EntropyRepositoryPlugin instance")
|
||||
EntropyPluginStore.add_plugin(self, inst.get_id(), inst)
|
||||
inst.add_plugin_hook(self)
|
||||
|
||||
def remove_plugin(self, plugin_id):
|
||||
"""
|
||||
Overloaded from EntropyPluginStore, adds support for hooks execution.
|
||||
"""
|
||||
plugins = self.get_plugins()
|
||||
plug_inst = plugins.get(plugin_id)
|
||||
if plug_inst is not None:
|
||||
plug_inst.remove_plugin_hook(self)
|
||||
return EntropyPluginStore.remove_plugin(self, plugin_id)
|
||||
|
||||
@staticmethod
|
||||
def add_permanent_plugin(entropy_repository_plugin):
|
||||
"""
|
||||
Add EntropyRepository permanent plugin. This plugin object will be
|
||||
used across all the instantiated EntropyRepositoryPluginStore classes.
|
||||
Each time a new instance is created, add_plugin_hook will be executed
|
||||
for all the permanent plugins.
|
||||
|
||||
@param entropy_repository_plugin: EntropyRepositoryPlugin instance
|
||||
@type entropy_repository_plugin: EntropyRepositoryPlugin instance
|
||||
"""
|
||||
inst = entropy_repository_plugin
|
||||
if not isinstance(inst, EntropyRepositoryPlugin):
|
||||
raise AttributeError("EntropyRepositoryPluginStore: " + \
|
||||
"expected valid EntropyRepositoryPlugin instance")
|
||||
EntropyRepositoryPluginStore._PERMANENT_PLUGINS[inst.get_id()] = inst
|
||||
|
||||
@staticmethod
|
||||
def remove_permanent_plugin(plugin_id):
|
||||
"""
|
||||
Remove EntropyRepository permanent plugin. This plugin object will be
|
||||
removed across all the EntropyRepository instances around.
|
||||
Please note: due to the fact that there are no destructors around,
|
||||
the "remove_plugin_hook" callback won't be executed when calling this
|
||||
static method.
|
||||
|
||||
@param plugin_id: EntropyRepositoryPlugin identifier
|
||||
@type plugin_id: string
|
||||
@raise KeyError: in case of unavailable plugin identifier
|
||||
"""
|
||||
del EntropyRepositoryPluginStore._PERMANENT_PLUGINS[plugin_id]
|
||||
|
||||
@staticmethod
|
||||
def get_permanent_plugins():
|
||||
"""
|
||||
Return EntropyRepositoryStore installed permanent plugins.
|
||||
|
||||
@return: copy of internal permanent plugins dict
|
||||
@rtype: dict
|
||||
"""
|
||||
return EntropyRepositoryPluginStore._PERMANENT_PLUGINS.copy()
|
||||
|
||||
def get_plugins(self):
|
||||
"""
|
||||
Overloaded from EntropyPluginStore, adds support for permanent plugins.
|
||||
"""
|
||||
plugins = EntropyPluginStore.get_plugins(self)
|
||||
plugins.update(EntropyRepositoryPluginStore.get_permanent_plugins())
|
||||
return plugins
|
||||
|
||||
def get_plugins_metadata(self):
|
||||
"""
|
||||
Return EntropyRepositoryPluginStore registered plugins metadata.
|
||||
|
||||
@return: plugins metadata
|
||||
@rtype: dict
|
||||
"""
|
||||
plugins = self.get_plugins()
|
||||
meta = {}
|
||||
for plugin_id in plugins:
|
||||
meta.update(plugins[plugin_id].get_metadata())
|
||||
return meta
|
||||
|
||||
def get_plugin_metadata(self, plugin_id, key):
|
||||
"""
|
||||
Return EntropyRepositoryPlugin metadata value referenced by "key".
|
||||
|
||||
@param plugin_id. EntropyRepositoryPlugin identifier
|
||||
@type plugin_id: string
|
||||
@param key: EntropyRepositoryPlugin metadatum identifier
|
||||
@type key: string
|
||||
@return: metadatum value
|
||||
@rtype: any Python object
|
||||
@raise KeyError: if provided key or plugin_id is not available
|
||||
"""
|
||||
plugins = self.get_plugins()
|
||||
return plugins[plugin_id][key]
|
||||
|
||||
def set_plugin_metadata(self, plugin_id, key, value):
|
||||
"""
|
||||
Set EntropyRepositoryPlugin stored metadata.
|
||||
|
||||
@param plugin_id. EntropyRepositoryPlugin identifier
|
||||
@type plugin_id: string
|
||||
@param key: EntropyRepositoryPlugin metadatum identifier
|
||||
@type key: string
|
||||
@param value: value to set
|
||||
@type value: any valid Python object
|
||||
@raise KeyError: if plugin_id is not available
|
||||
"""
|
||||
plugins = self.get_plugins()
|
||||
meta = plugins[plugin_id].get_metadata()
|
||||
meta[key] = value
|
||||
+4347
-14
File diff suppressed because it is too large
Load Diff
@@ -1112,7 +1112,7 @@ class QAInterface(TextInterface, EntropyPluginStore):
|
||||
|
||||
if valid:
|
||||
try:
|
||||
for idpackage in dbc.listAllIdpackages():
|
||||
for idpackage in dbc.listAllPackageIds():
|
||||
dbc.retrieveContent(idpackage, extended = True,
|
||||
formatted = True, insert_formatted = True)
|
||||
except Error:
|
||||
|
||||
@@ -113,7 +113,7 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
# better than having a completely broken db
|
||||
self._metadata['read_only'] = False
|
||||
entropy_repository_instance.readOnly = False
|
||||
entropy_repository_instance.initializeDatabase()
|
||||
entropy_repository_instance.initializeRepository()
|
||||
entropy_repository_instance.commitChanges()
|
||||
|
||||
out_intf = self._metadata.get('output_interface')
|
||||
@@ -234,12 +234,12 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
spm = self._server.Spm()
|
||||
return spm.get_package_category_description_metadata(category)
|
||||
|
||||
def _write_rss_for_removed_package(self, repo_db, idpackage):
|
||||
def _write_rss_for_removed_package(self, repo_db, package_id):
|
||||
|
||||
# setup variables we're going to use
|
||||
srv_repo = self._metadata['repo_name']
|
||||
rss_revision = repo_db.retrieveRevision(idpackage)
|
||||
rss_atom = "%s~%s" % (repo_db.retrieveAtom(idpackage), rss_revision,)
|
||||
rss_revision = repo_db.retrieveRevision(package_id)
|
||||
rss_atom = "%s~%s" % (repo_db.retrieveAtom(package_id), rss_revision,)
|
||||
status = ServerRepositoryStatus()
|
||||
srv_updates = status.get_updates_log(srv_repo)
|
||||
rss_name = srv_repo + etpConst['rss-dump-name']
|
||||
@@ -267,11 +267,11 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
# add metadata
|
||||
mydict = {}
|
||||
try:
|
||||
mydict['description'] = repo_db.retrieveDescription(idpackage)
|
||||
mydict['description'] = repo_db.retrieveDescription(package_id)
|
||||
except TypeError:
|
||||
mydict['description'] = "N/A"
|
||||
try:
|
||||
mydict['homepage'] = repo_db.retrieveHomepage(idpackage)
|
||||
mydict['homepage'] = repo_db.retrieveHomepage(package_id)
|
||||
except TypeError:
|
||||
mydict['homepage'] = ""
|
||||
srv_updates['removed'][rss_atom] = mydict
|
||||
@@ -321,7 +321,7 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
self.Cacher.push(rss_name, srv_updates, async = False,
|
||||
cache_dir = Server.CACHE_DIR)
|
||||
|
||||
def add_package_hook(self, entropy_repository_instance, idpackage,
|
||||
def add_package_hook(self, entropy_repository_instance, package_id,
|
||||
package_data):
|
||||
|
||||
const_debug_write(__name__,
|
||||
@@ -345,7 +345,7 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
|
||||
return 0
|
||||
|
||||
def remove_package_hook(self, entropy_repository_instance, idpackage,
|
||||
def remove_package_hook(self, entropy_repository_instance, package_id,
|
||||
from_add_package):
|
||||
|
||||
const_debug_write(__name__,
|
||||
@@ -360,15 +360,15 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
|
||||
# store addPackage action
|
||||
self._write_rss_for_removed_package(entropy_repository_instance,
|
||||
idpackage)
|
||||
package_id)
|
||||
|
||||
return 0
|
||||
|
||||
def treeupdates_move_action_hook(self, entropy_repository_instance,
|
||||
idpackage):
|
||||
package_id):
|
||||
# check for injection and warn the developer
|
||||
injected = entropy_repository_instance.isInjected(idpackage)
|
||||
new_atom = entropy_repository_instance.retrieveAtom(idpackage)
|
||||
injected = entropy_repository_instance.isInjected(package_id)
|
||||
new_atom = entropy_repository_instance.retrieveAtom(package_id)
|
||||
if injected:
|
||||
mytxt = "%s: %s %s. %s !!! %s." % (
|
||||
bold(_("INJECT")),
|
||||
@@ -386,9 +386,9 @@ class ServerEntropyRepositoryPlugin(EntropyRepositoryPlugin):
|
||||
return 0
|
||||
|
||||
def treeupdates_slot_move_action_hook(self, entropy_repository_instance,
|
||||
idpackage):
|
||||
package_id):
|
||||
return self.treeupdates_move_action_hook(entropy_repository_instance,
|
||||
idpackage)
|
||||
package_id)
|
||||
|
||||
def reverse_dependencies_tree_generation_hook(self,
|
||||
entropy_repository_instance):
|
||||
@@ -874,7 +874,7 @@ class ServerQAInterfacePlugin(QAInterfacePlugin):
|
||||
if not found_edb:
|
||||
return False
|
||||
dbc = self._server._open_temp_repository("test", temp_file = tmp_f)
|
||||
for package_id in dbc.listAllIdpackages():
|
||||
for package_id in dbc.listAllPackageIds():
|
||||
keywords = dbc.retrieveKeywords(package_id)
|
||||
if not keywords:
|
||||
atom = dbc.retrieveAtom(package_id)
|
||||
@@ -1342,7 +1342,7 @@ class ServerPackageDepsMixin:
|
||||
dbconn = self.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = repo)
|
||||
if ("world" in packages) or not packages:
|
||||
return dbconn.listAllIdpackages(), True
|
||||
return dbconn.listAllPackageIds(), True
|
||||
else:
|
||||
idpackages = set()
|
||||
for package in packages:
|
||||
@@ -1408,7 +1408,7 @@ class ServerPackagesHandlingMixin:
|
||||
# initialize
|
||||
dbconn = self.open_server_repository(read_only = False,
|
||||
no_upload = True, repo = repo, is_new = True)
|
||||
dbconn.initializeDatabase()
|
||||
dbconn.initializeRepository()
|
||||
|
||||
dbconn.commitChanges()
|
||||
self.close_repositories()
|
||||
@@ -1505,7 +1505,7 @@ class ServerPackagesHandlingMixin:
|
||||
no_upload = True, repo = repo)
|
||||
|
||||
idpackage_map = dict(((x, [],) for x in from_branches))
|
||||
idpackages = dbconn.listAllIdpackages(order_by = 'atom')
|
||||
idpackages = dbconn.listAllPackageIds(order_by = 'atom')
|
||||
for idpackage in idpackages:
|
||||
download_url = dbconn.retrieveDownloadURL(idpackage)
|
||||
url_br = self._get_branch_from_download_relative_uri(
|
||||
@@ -1810,7 +1810,7 @@ class ServerPackagesHandlingMixin:
|
||||
no_upload = True, repo = from_repo)
|
||||
my_matches = set( \
|
||||
[(x, from_repo) for x in \
|
||||
dbconn.listAllIdpackages()]
|
||||
dbconn.listAllPackageIds()]
|
||||
)
|
||||
|
||||
mytxt = _("Preparing to move selected packages to")
|
||||
@@ -1872,7 +1872,7 @@ class ServerPackagesHandlingMixin:
|
||||
dbconn.retrieveCategory(idpackage), \
|
||||
dbconn.retrieveSlot(idpackage), \
|
||||
dbconn.isInjected(idpackage)
|
||||
to_rm_idpackages = todbconn.retrieve_packages_to_remove(from_name,
|
||||
to_rm_idpackages = todbconn.getPackagesToRemove(from_name,
|
||||
from_category, from_slot, from_injected)
|
||||
for to_rm_idpackage in to_rm_idpackages:
|
||||
self.output(
|
||||
@@ -2157,7 +2157,7 @@ class ServerPackagesHandlingMixin:
|
||||
|
||||
todbconn = self.open_server_repository(read_only = False,
|
||||
no_upload = True, repo = to_repo)
|
||||
todbconn.doCleanups()
|
||||
todbconn.clean()
|
||||
|
||||
# just run this to make dev aware
|
||||
self.dependencies_test(to_repo)
|
||||
@@ -2667,7 +2667,7 @@ class ServerPackagesHandlingMixin:
|
||||
)
|
||||
|
||||
dbconn = self.open_server_repository(repo = repo, read_only = False)
|
||||
idpackages = dbconn.listAllIdpackages()
|
||||
idpackages = dbconn.listAllPackageIds()
|
||||
|
||||
self.output(
|
||||
blue(_("All the missing packages in repository will be downloaded.")),
|
||||
@@ -3030,7 +3030,7 @@ class ServerPackagesHandlingMixin:
|
||||
dbconn = self.open_server_repository(read_only = False,
|
||||
no_upload = True, repo = repo, lock_remote = False)
|
||||
|
||||
idpackages = dbconn.listAllIdpackages()
|
||||
idpackages = dbconn.listAllPackageIds()
|
||||
already_switched = set()
|
||||
not_found = set()
|
||||
switched = set()
|
||||
@@ -3178,7 +3178,7 @@ class ServerQAMixin:
|
||||
dbconn = self.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = repo, do_treeupdates = False)
|
||||
installed_packages |= set([(x, repo) for x in \
|
||||
dbconn.listAllIdpackages()])
|
||||
dbconn.listAllPackageIds()])
|
||||
|
||||
|
||||
deps_not_satisfied = set()
|
||||
@@ -3236,7 +3236,7 @@ class ServerQAMixin:
|
||||
riddep = dbconn.searchDependency(atom)
|
||||
if riddep == -1:
|
||||
continue
|
||||
ridpackages = dbconn.searchIdpackageFromIddependency(riddep)
|
||||
ridpackages = dbconn.searchPackageIdFromDependencyId(riddep)
|
||||
for i in ridpackages:
|
||||
iatom = dbconn.retrieveAtom(i)
|
||||
if atom not in crying_atoms:
|
||||
@@ -3726,7 +3726,7 @@ class ServerRepositoryMixin:
|
||||
skipChecks = True,
|
||||
temporary = True
|
||||
)
|
||||
conn.initializeDatabase()
|
||||
conn.initializeRepository()
|
||||
return conn
|
||||
|
||||
def open_repository(self, repoid):
|
||||
@@ -3796,7 +3796,7 @@ class ServerRepositoryMixin:
|
||||
dbname = repo,
|
||||
xcache = False # always set to False, if you want to enable
|
||||
# you need to make sure that client-side and server-side caches
|
||||
# don't collide due to sharing EntropyRepository.dbname
|
||||
# don't collide due to sharing EntropyRepository.reponame
|
||||
)
|
||||
etp_repo_meta = {
|
||||
'lock_remote': lock_remote,
|
||||
@@ -3890,7 +3890,7 @@ class ServerRepositoryMixin:
|
||||
back = True
|
||||
)
|
||||
dbconn = self.open_generic_repository(dbpath)
|
||||
dbconn.initializeDatabase()
|
||||
dbconn.initializeRepository()
|
||||
dbconn.commitChanges()
|
||||
dbconn.closeDB()
|
||||
mytxt = "%s %s %s." % (
|
||||
@@ -4023,7 +4023,7 @@ class ServerRepositoryMixin:
|
||||
mydbconn = self.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = myrepo)
|
||||
|
||||
myrepo_idpackages = mydbconn.getIdpackages(rev_test_atom)
|
||||
myrepo_idpackages = mydbconn.getPackageIds(rev_test_atom)
|
||||
for myrepo_idpackage in myrepo_idpackages:
|
||||
myrev = mydbconn.retrieveRevision(myrepo_idpackage)
|
||||
if myrev > max_rev:
|
||||
@@ -4043,7 +4043,7 @@ class ServerRepositoryMixin:
|
||||
for myrepo in myserver_repos:
|
||||
mydbconn = self.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = myrepo)
|
||||
mylist = mydbconn.retrieve_packages_to_remove(
|
||||
mylist = mydbconn.getPackagesToRemove(
|
||||
mydata['name'],
|
||||
mydata['category'],
|
||||
mydata['slot'],
|
||||
@@ -4213,7 +4213,7 @@ class ServerRepositoryMixin:
|
||||
# after a previous failure to have garbage here
|
||||
dbconn = self.open_server_repository(just_reading = True, repo = repo)
|
||||
idpackages_added = set((x for x in idpackages_added if \
|
||||
dbconn.isIdpackageAvailable(x)))
|
||||
dbconn.isPackageIdAvailable(x)))
|
||||
|
||||
if idpackages_added:
|
||||
dbconn = self.open_server_repository(read_only = False,
|
||||
@@ -4646,7 +4646,7 @@ class ServerMiscMixin:
|
||||
def _transform_package_into_injected(self, idpackage, repo = None):
|
||||
dbconn = self.open_server_repository(read_only = False,
|
||||
no_upload = True, repo = repo)
|
||||
counter = dbconn.getNewNegativeSpmUid()
|
||||
counter = dbconn.getFakeSpmUid()
|
||||
dbconn.setSpmUid(idpackage, counter)
|
||||
dbconn.setInjected(idpackage)
|
||||
|
||||
|
||||
@@ -704,7 +704,7 @@ class Server(ServerNoticeBoardMixin):
|
||||
|
||||
dbconn = self._entropy.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = repo)
|
||||
idpackage = dbconn.getIdpackageFromDownload(pkg_relative_path)
|
||||
idpackage = dbconn.getPackageIdFromDownload(pkg_relative_path)
|
||||
if idpackage == -1:
|
||||
self._entropy.output(
|
||||
"[repo:%s|%s|#%s] %s: %s %s" % (
|
||||
@@ -1014,7 +1014,7 @@ class Server(ServerNoticeBoardMixin):
|
||||
f_out = opener(destination_path, "wb")
|
||||
dbconn = self._entropy.open_server_repository(db_path,
|
||||
just_reading = True, repo = repo, do_treeupdates = False)
|
||||
dbconn.doDatabaseExport(f_out, exclude_tables = exclude_tables)
|
||||
dbconn.exportRepository(f_out, exclude_tables = exclude_tables)
|
||||
self._entropy.close_repository(dbconn)
|
||||
f_out.close()
|
||||
|
||||
@@ -1579,7 +1579,7 @@ class Server(ServerNoticeBoardMixin):
|
||||
dbconn = self._entropy.open_server_repository(read_only = False,
|
||||
no_upload = True, repo = repo, indexing = False,
|
||||
do_treeupdates = False)
|
||||
dbconn.doCleanups()
|
||||
dbconn.clean()
|
||||
dbconn.dropAllIndexes()
|
||||
dbconn.vacuum()
|
||||
dbconn.vacuum()
|
||||
|
||||
@@ -114,7 +114,7 @@ class Repository(SocketCommands):
|
||||
strings = True)
|
||||
secure_checksum = dbconn.checksum(do_order = True, strict = False,
|
||||
strings = True, include_signatures = True)
|
||||
myids = dbconn.listAllIdpackages()
|
||||
myids = dbconn.listAllPackageIds()
|
||||
cached = std_checksum, secure_checksum, myids
|
||||
self.HostInterface.set_dcache(
|
||||
x + ('docmd_dbdiff', mtime, rev_id,), cached, repository)
|
||||
|
||||
@@ -1001,7 +1001,7 @@ class Repository(SocketCommands):
|
||||
return False, 'repository id not available'
|
||||
|
||||
dbconn = self.HostInterface.Entropy.open_server_repository(repo = repoid, just_reading = True, warnings = False, do_cache = False)
|
||||
idpackages = dbconn.listAllIdpackages(order_by = 'atom')
|
||||
idpackages = dbconn.listAllPackageIds(order_by = 'atom')
|
||||
package_data = []
|
||||
package_data = {
|
||||
'ordered_idpackages': idpackages,
|
||||
|
||||
@@ -3124,7 +3124,7 @@ class PortagePlugin(SpmPlugin):
|
||||
# we need to get the .xpak from database
|
||||
xdbconn = entropy_client.open_repository(
|
||||
package_metadata['repository'])
|
||||
xpakdata = xdbconn.retrieveXpakMetadata(
|
||||
xpakdata = xdbconn.retrieveSpmMetadata(
|
||||
package_metadata['idpackage'])
|
||||
if xpakdata:
|
||||
# save into a file
|
||||
|
||||
@@ -40,7 +40,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
"""
|
||||
sys.stdout.write("%s ran\n" % (self,))
|
||||
sys.stdout.flush()
|
||||
self.Client.destroy()
|
||||
self.Client.shutdown()
|
||||
|
||||
def test_another_instance(self):
|
||||
pid = os.fork()
|
||||
@@ -57,13 +57,13 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
def test_singleton(self):
|
||||
myclient = Client(noclientdb = 2)
|
||||
self.assert_(myclient is self.Client)
|
||||
myclient.destroy()
|
||||
myclient.shutdown()
|
||||
self.assert_(myclient.is_destroyed())
|
||||
self.assert_(self.Client.is_destroyed())
|
||||
myclient2 = Client(noclientdb = 2, indexing = False, xcache = False,
|
||||
repo_validation = False)
|
||||
self.assert_(myclient is not myclient2)
|
||||
myclient2.destroy()
|
||||
myclient2.shutdown()
|
||||
self.assert_(myclient2.is_destroyed())
|
||||
|
||||
def test_constant_backup(self):
|
||||
@@ -173,7 +173,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
self.assert_(rc == 0)
|
||||
|
||||
# remove pkg
|
||||
idpackages = self.Client.installed_repository().listAllIdpackages()
|
||||
idpackages = self.Client.installed_repository().listAllPackageIds()
|
||||
for idpackage in idpackages:
|
||||
my_p = self.Client.Package()
|
||||
my_p.prepare((idpackage,), "remove", {})
|
||||
|
||||
+9
-20
@@ -38,7 +38,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
sys.stdout.flush()
|
||||
self.test_db.closeDB()
|
||||
self.test_db2.closeDB()
|
||||
self.Client.destroy()
|
||||
self.Client.shutdown()
|
||||
|
||||
def __open_test_db(self, tmp_path):
|
||||
return self.Client.open_temp_repository(dbname = self.test_db_name,
|
||||
@@ -67,7 +67,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
|
||||
def test_db_creation(self):
|
||||
self.assert_(isinstance(self.test_db, EntropyRepository))
|
||||
self.assertEqual(self.test_db_name, self.test_db.dbname)
|
||||
self.assertEqual(self.test_db_name, self.test_db.reponame)
|
||||
self.assert_(self.test_db._doesTableExist('baseinfo'))
|
||||
self.assert_(self.test_db._doesTableExist('extrainfo'))
|
||||
|
||||
@@ -121,14 +121,6 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
orig_diff = [const_convert_to_unicode(x, 'utf-8') for x in orig_diff]
|
||||
self.assertEqual(orig_diff, py_diff)
|
||||
|
||||
# test package content match
|
||||
self.assertEqual(self.test_db.getIdpackagesFromFile(orig_diff[3]),
|
||||
[1])
|
||||
category = self.test_db.retrieveCategory(idpackage)
|
||||
idcategory = self.test_db.getIdcategory(category)
|
||||
self.assertEqual(self.test_db.getCategory(idcategory),
|
||||
new_data['category'])
|
||||
|
||||
versioning_data = self.test_db.getVersioningData(idpackage)
|
||||
dbverdata = (self.test_db.retrieveVersion(idpackage),
|
||||
self.test_db.retrieveTag(idpackage),
|
||||
@@ -155,15 +147,12 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(scope_data, dbverdata)
|
||||
|
||||
trigger_info = self.test_db.getTriggerInfo(idpackage)
|
||||
trigger_info = self.test_db.getTriggerData(idpackage)
|
||||
trigger_keys = ['version', 'eclasses', 'etpapi', 'cxxflags', 'cflags',
|
||||
'chost', 'atom', 'category', 'name', 'versiontag', 'content',
|
||||
'trigger', 'branch', 'spm_phases', 'revision']
|
||||
self.assertEqual(sorted(trigger_keys), sorted(trigger_info.keys()))
|
||||
|
||||
system_pkgs = self.test_db.retrieveSystemPackages()
|
||||
self.assertEqual(system_pkgs, set([idpackage]))
|
||||
|
||||
def test_db_insert_compare_match_provide(self):
|
||||
test_pkg = _misc.get_test_entropy_package_provide()
|
||||
data = self.Spm.extract_package_metadata(test_pkg)
|
||||
@@ -185,18 +174,18 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
started = cacher.is_started()
|
||||
cacher.start()
|
||||
|
||||
cached = self.test_db._EntropyRepository__atomMatchFetchCache(
|
||||
cached = self.test_db._EntropyRepositoryBase__atomMatchFetchCache(
|
||||
key, True, False, False, None, None, False, False, True)
|
||||
self.assert_(cached is None)
|
||||
|
||||
# now store
|
||||
self.test_db._EntropyRepository__atomMatchStoreCache(
|
||||
self.test_db._EntropyRepositoryBase__atomMatchStoreCache(
|
||||
key, True, False, False, None, None, False, False, True,
|
||||
result = (123, 0)
|
||||
)
|
||||
cacher.sync()
|
||||
|
||||
cached = self.test_db._EntropyRepository__atomMatchFetchCache(
|
||||
cached = self.test_db._EntropyRepositoryBase__atomMatchFetchCache(
|
||||
key, True, False, False, None, None, False, False, True)
|
||||
self.assertEqual(cached, (123, 0))
|
||||
if not started:
|
||||
@@ -453,13 +442,13 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
fd, buf_file = tempfile.mkstemp()
|
||||
os.close(fd)
|
||||
buf = open(buf_file, "wb")
|
||||
self.test_db.doDatabaseExport(buf)
|
||||
self.test_db.exportRepository(buf)
|
||||
buf.flush()
|
||||
buf.close()
|
||||
|
||||
fd, new_db_path = tempfile.mkstemp()
|
||||
os.close(fd)
|
||||
self.test_db.doDatabaseImport(buf_file, new_db_path)
|
||||
self.test_db.importRepository(buf_file, new_db_path)
|
||||
new_db = self.Client.open_generic_repository(new_db_path)
|
||||
new_db_data = new_db.getPackageData(idpackage)
|
||||
new_db.closeDB()
|
||||
@@ -488,7 +477,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
lic_txt = const_convert_to_rawstring('[3]\xab foo\n\n', 'utf-8')
|
||||
lic_name = const_convert_to_unicode('CCPL-Attribution-2.0')
|
||||
lic_data = {lic_name: lic_txt}
|
||||
self.test_db.insertLicenses(lic_data)
|
||||
self.test_db._insertLicenses(lic_data)
|
||||
db_lic_txt = self.test_db.retrieveLicenseText(lic_name)
|
||||
self.assertEqual(db_lic_txt, lic_txt)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class SecurityTest(unittest.TestCase):
|
||||
"""
|
||||
tearDown is run after each test
|
||||
"""
|
||||
self._entropy.destroy()
|
||||
self._entropy.shutdown()
|
||||
del self._entropy
|
||||
del self._repository
|
||||
del self._system
|
||||
|
||||
@@ -27,7 +27,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
fake_default_repo_desc = 'foo desc', fake_default_repo = True)
|
||||
foo_db = self.Server.open_server_repository(repo = self.default_repo,
|
||||
read_only = False, lock_remote = False, is_new = True)
|
||||
foo_db.initializeDatabase()
|
||||
foo_db.initializeRepository()
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
@@ -36,8 +36,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
"""
|
||||
sys.stdout.write("%s ran\n" % (self,))
|
||||
sys.stdout.flush()
|
||||
self.Server.Cacher.stop()
|
||||
self.Server.destroy()
|
||||
self.Server.shutdown()
|
||||
|
||||
def test_server_instance(self):
|
||||
self.assertEqual(self.default_repo, self.Server.default_repository)
|
||||
|
||||
@@ -28,7 +28,7 @@ class SpmTest(unittest.TestCase):
|
||||
"""
|
||||
sys.stdout.write("%s ran\n" % (self,))
|
||||
sys.stdout.flush()
|
||||
self.Client.destroy()
|
||||
self.Client.shutdown()
|
||||
|
||||
def test_init(self):
|
||||
spm = self.Client.Spm()
|
||||
|
||||
@@ -9,7 +9,7 @@ if __name__ == "__main__":
|
||||
|
||||
# test with zillions of atoms
|
||||
repo = cl.open_repository("sabayonlinux.org")
|
||||
atoms = [x[1] for x in repo.listAllDependencies()]
|
||||
atoms = [x[1] for x in repo._listAllDependencies()]
|
||||
atoms = [x for x in atoms if not x.startswith("!")]
|
||||
|
||||
graph = Graph()
|
||||
|
||||
@@ -43,7 +43,7 @@ class ToolsTest(unittest.TestCase):
|
||||
self.assertNotEqual(tmp_path, None)
|
||||
dbconn = client.open_generic_repository(tmp_path)
|
||||
dbconn.validateDatabase()
|
||||
dbconn.listAllIdpackages()
|
||||
dbconn.listAllPackageIds()
|
||||
dbconn.closeDB()
|
||||
|
||||
os.close(fd)
|
||||
|
||||
@@ -411,7 +411,7 @@ def repositories(options):
|
||||
|
||||
idpackages = set()
|
||||
if not myopts:
|
||||
allidpackages = dbconn.listAllIdpackages()
|
||||
allidpackages = dbconn.listAllPackageIds()
|
||||
for idpackage in allidpackages:
|
||||
if dbconn.isInjected(idpackage):
|
||||
idpackages.add(idpackage)
|
||||
@@ -487,7 +487,7 @@ def repositories(options):
|
||||
dbconn_old = Entropy.open_server_repository(read_only = True,
|
||||
no_upload = True, repo = repoid, use_branch = from_branch,
|
||||
do_treeupdates = False)
|
||||
pkglist = dbconn_old.listAllIdpackages()
|
||||
pkglist = dbconn_old.listAllPackageIds()
|
||||
|
||||
print_info(darkgreen(" * ")+"%s %s: %s %s" % (
|
||||
blue(_("These are the packages that would be marked")),
|
||||
|
||||
@@ -136,7 +136,7 @@ class TrackerMiner(dbus.service.Object):
|
||||
self.__system_changes_checker = None
|
||||
self.__quit_service_wd = None
|
||||
self.__quit_service_trigger = False
|
||||
self.__last_system_db_mtime = None
|
||||
self.__last_system_repo_checksum = None
|
||||
self.__trigger_system_changed = False
|
||||
|
||||
# start dbus service
|
||||
@@ -208,38 +208,36 @@ class TrackerMiner(dbus.service.Object):
|
||||
|
||||
entropy = Entropy()
|
||||
try:
|
||||
return entropy.installed_repository().listAllIdpackages()
|
||||
return entropy.installed_repository().listAllPackageIds()
|
||||
finally:
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
def __is_system_changed(self):
|
||||
with self.__is_working_mutex:
|
||||
|
||||
entropy = Entropy()
|
||||
locked = entropy.resources_locked()
|
||||
if locked:
|
||||
if DAEMON_DEBUG:
|
||||
write_output("__is_system_changed: resources locked!")
|
||||
entropy.destroy()
|
||||
return False # resources are locked, nothing changed yet :P
|
||||
entropy = Entropy()
|
||||
locked = entropy.resources_locked()
|
||||
if locked:
|
||||
if DAEMON_DEBUG:
|
||||
write_output("_is_system_changed: resources locked!")
|
||||
entropy.shutdown()
|
||||
return False # resources are locked, nothing changed yet :P
|
||||
|
||||
try:
|
||||
|
||||
last_mtime = self.__last_system_db_mtime
|
||||
dbfile = entropy.installed_repository().dbFile
|
||||
try:
|
||||
cur_mtime = os.path.getmtime(dbfile)
|
||||
except OSError:
|
||||
cur_mtime = 0.0
|
||||
|
||||
changed = last_mtime != cur_mtime
|
||||
if DAEMON_DEBUG and changed:
|
||||
write_output("__is_system_changed: system db mtime changed!")
|
||||
self.__last_system_db_mtime = cur_mtime
|
||||
return changed
|
||||
last_checksum = self.__last_system_repo_checksum
|
||||
cur_checksum = entropy.installed_repository().checksum(
|
||||
strict = False, strings = True)
|
||||
|
||||
finally:
|
||||
# say goodbye
|
||||
entropy.destroy()
|
||||
changed = last_checksum != cur_checksum
|
||||
if DAEMON_DEBUG and changed:
|
||||
write_output("_is_system_changed: system db checksum changed!")
|
||||
self.__last_system_repo_checksum = cur_checksum
|
||||
return changed
|
||||
|
||||
finally:
|
||||
# say goodbye
|
||||
entropy.shutdown()
|
||||
|
||||
@dbus.service.method ( "org.entropy.Client", in_signature = '',
|
||||
out_signature = '')
|
||||
|
||||
@@ -159,7 +159,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
self.__updates = []
|
||||
self.__updates_atoms = None
|
||||
self.__system_db_hash = None
|
||||
self.__last_system_db_mtime = None
|
||||
self.__last_system_repo_checksum = None
|
||||
self.__got_client_ping = True
|
||||
|
||||
# start dbus service
|
||||
@@ -343,7 +343,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
write_output("__run_fetcher: app. locked, skipping")
|
||||
else:
|
||||
write_output("__run_fetcher: app. locked during acquire")
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
return rc_fetch
|
||||
|
||||
# entropy resources locked?
|
||||
@@ -351,7 +351,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
if locked:
|
||||
if DAEMON_DEBUG:
|
||||
write_output("__run_fetcher: resources locked, skipping")
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
return rc_fetch
|
||||
|
||||
# acquire resources lock
|
||||
@@ -359,7 +359,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
if not acquired:
|
||||
if DAEMON_DEBUG:
|
||||
write_output("__run_fetcher: resources locked during acquire")
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
return rc_fetch
|
||||
|
||||
try:
|
||||
@@ -435,7 +435,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
# remove application lock
|
||||
const_remove_entropy_pid()
|
||||
# say goodbye
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
# compare repos status for updates
|
||||
@dbus.service.method ( "org.entropy.Client", in_signature = '',
|
||||
@@ -482,7 +482,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
|
||||
finally:
|
||||
if destroy:
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
@dbus.service.method ( "org.entropy.Client", in_signature = '',
|
||||
out_signature = '')
|
||||
@@ -521,7 +521,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
return self.__updates
|
||||
|
||||
finally:
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
def _is_system_changed(self):
|
||||
with self.__is_working_mutex:
|
||||
@@ -531,27 +531,24 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
if locked:
|
||||
if DAEMON_DEBUG:
|
||||
write_output("_is_system_changed: resources locked!")
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
return False # resources are locked, nothing changed yet :P
|
||||
|
||||
try:
|
||||
|
||||
last_mtime = self.__last_system_db_mtime
|
||||
dbfile = entropy.installed_repository().dbFile
|
||||
try:
|
||||
cur_mtime = os.path.getmtime(dbfile)
|
||||
except OSError:
|
||||
cur_mtime = 0.0
|
||||
last_checksum = self.__last_system_repo_checksum
|
||||
cur_checksum = entropy.installed_repository().checksum(
|
||||
strict = False, strings = True)
|
||||
|
||||
changed = last_mtime != cur_mtime
|
||||
changed = last_checksum != cur_checksum
|
||||
if DAEMON_DEBUG and changed:
|
||||
write_output("_is_system_changed: system db mtime changed!")
|
||||
self.__last_system_db_mtime = cur_mtime
|
||||
write_output("_is_system_changed: system db checksum changed!")
|
||||
self.__last_system_repo_checksum = cur_checksum
|
||||
return changed
|
||||
|
||||
finally:
|
||||
# say goodbye
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
@dbus.service.method("org.entropy.Client", in_signature = '',
|
||||
out_signature = 'b')
|
||||
@@ -580,7 +577,7 @@ class UpdatesDaemon(dbus.service.Object):
|
||||
return self.__updates_atoms
|
||||
|
||||
finally:
|
||||
entropy.destroy()
|
||||
entropy.shutdown()
|
||||
|
||||
|
||||
@dbus.service.method("org.entropy.Client", in_signature = '',
|
||||
|
||||
@@ -1474,7 +1474,7 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
|
||||
iddep = c_repo.searchDependency(dep)
|
||||
if iddep == -1:
|
||||
continue
|
||||
c_idpackages = c_repo.searchIdpackageFromIddependency(
|
||||
c_idpackages = c_repo.searchPackageIdFromDependencyId(
|
||||
iddep)
|
||||
for c_idpackage in c_idpackages:
|
||||
key, slot = c_repo.retrieveKeySlot(
|
||||
|
||||
@@ -1256,7 +1256,7 @@ class PkgInfoMenu(MenuSkel):
|
||||
dbconn = self.pkg.dbconn
|
||||
avail = False
|
||||
if dbconn:
|
||||
avail = dbconn.isIdpackageAvailable(pkg.matched_atom[0])
|
||||
avail = dbconn.isPackageIdAvailable(pkg.matched_atom[0])
|
||||
if not avail:
|
||||
return
|
||||
from_repo = True
|
||||
@@ -1352,7 +1352,7 @@ class PkgInfoMenu(MenuSkel):
|
||||
self.pkginfo_ui.chost.set_markup( "%s" % (chost,) )
|
||||
# masked ?
|
||||
masked = _("No")
|
||||
idpackage_masked, idmasking_reason = dbconn.idpackageValidator(pkg.matched_atom[0])
|
||||
idpackage_masked, idmasking_reason = dbconn.maskFilter(pkg.matched_atom[0])
|
||||
if idpackage_masked == -1:
|
||||
masked = '%s, %s' % (_("Yes"), self.Entropy.Settings()['pkg_masking_reasons'][idmasking_reason],)
|
||||
self.pkginfo_ui.masked.set_markup( "%s" % (masked,) )
|
||||
@@ -1378,7 +1378,7 @@ class PkgInfoMenu(MenuSkel):
|
||||
self.mirrorsReferenceModel.clear()
|
||||
self.mirrorsReferenceView.set_model(self.mirrorsReferenceModel)
|
||||
for mirror in mirrors:
|
||||
mirrorinfo = dbconn.retrieveMirrorInfo(mirror)
|
||||
mirrorinfo = dbconn.retrieveMirrorData(mirror)
|
||||
if mirrorinfo:
|
||||
# add parent
|
||||
parent = self.mirrorsReferenceModel.append(None, [mirror])
|
||||
@@ -3203,7 +3203,7 @@ class LicenseDialog:
|
||||
for package in packages:
|
||||
repoid = package[1]
|
||||
dbconn = self.Entropy.open_repository(repoid)
|
||||
if dbconn.isLicensedataKeyAvailable(license_identifier):
|
||||
if dbconn.isLicenseDataKeyAvailable(license_identifier):
|
||||
license_text = dbconn.retrieveLicenseText(license_identifier)
|
||||
break
|
||||
|
||||
|
||||
@@ -690,7 +690,7 @@ class SulfurApplicationEventsMixin:
|
||||
dbconn = self._entropy.installed_repository()
|
||||
else:
|
||||
dbconn = self._entropy.open_repository(repoid)
|
||||
if dbconn.isLicensedataKeyAvailable(license_identifier):
|
||||
if dbconn.isLicenseDataKeyAvailable(license_identifier):
|
||||
license_text = dbconn.retrieveLicenseText(license_identifier)
|
||||
found = True
|
||||
if found:
|
||||
|
||||
@@ -199,7 +199,7 @@ class EntropyPackage:
|
||||
if self.pkgset:
|
||||
return False
|
||||
|
||||
idpackage, idmask = self.dbconn.idpackageValidator(self.matched_id)
|
||||
idpackage, idmask = self.dbconn.maskFilter(self.matched_id)
|
||||
if idpackage != -1:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -722,8 +722,9 @@ class EntropyPackages:
|
||||
self.get_groups("installed")
|
||||
self.get_groups("reinstallable")
|
||||
|
||||
updates, remove, fine, spm_fine = self.Entropy.calculate_updates(
|
||||
critical_updates = False)
|
||||
with self.Entropy.Cacher():
|
||||
updates, remove, fine, spm_fine = self.Entropy.calculate_updates(
|
||||
critical_updates = False)
|
||||
# Filter out packages installed from unavailable repositories, this is
|
||||
# mainly required to allow 3rd party packages installation without
|
||||
# erroneously inform user about unavailability.
|
||||
@@ -735,7 +736,7 @@ class EntropyPackages:
|
||||
|
||||
def _pkg_get_installed(self):
|
||||
return [x for x in map(self.__inst_pkg_setup,
|
||||
self.Entropy.installed_repository().listAllIdpackages(order_by = 'atom')) if \
|
||||
self.Entropy.installed_repository().listAllPackageIds(order_by = 'atom')) if \
|
||||
not isinstance(x, int)]
|
||||
|
||||
def _pkg_get_queued(self):
|
||||
@@ -775,8 +776,9 @@ class EntropyPackages:
|
||||
return 0
|
||||
yp.action = 'i'
|
||||
return yp
|
||||
return [x for x in map(fm, self.Entropy.calculate_available_packages()) \
|
||||
if not isinstance(x, int)]
|
||||
with self.Entropy.Cacher():
|
||||
return [x for x in map(fm, self.Entropy.calculate_available_packages()) \
|
||||
if not isinstance(x, int)]
|
||||
|
||||
def _pkg_get_updates_raw(self):
|
||||
return self._pkg_get_updates(critical_updates = False)
|
||||
@@ -816,11 +818,13 @@ class EntropyPackages:
|
||||
remove = []
|
||||
fine = []
|
||||
spm_fine = []
|
||||
updates = self.Entropy.calculate_security_updates()
|
||||
with self.Entropy.Cacher():
|
||||
updates = self.Entropy.calculate_security_updates()
|
||||
else:
|
||||
updates, remove, fine, spm_fine = \
|
||||
self.Entropy.calculate_updates(
|
||||
critical_updates = critical_updates)
|
||||
with self.Entropy.Cacher():
|
||||
updates, remove, fine, spm_fine = \
|
||||
self.Entropy.calculate_updates(
|
||||
critical_updates = critical_updates)
|
||||
except SystemDatabaseError:
|
||||
# broken client db
|
||||
return []
|
||||
@@ -868,7 +872,7 @@ class EntropyPackages:
|
||||
dbconn.validateDatabase()
|
||||
except (RepositoryError, SystemDatabaseError):
|
||||
continue
|
||||
idpackages = dbconn.listAllIdpackages()
|
||||
idpackages = dbconn.listAllPackageIds()
|
||||
matches |= set(((x, repo) for x in idpackages if (x, repo) not in
|
||||
already_in))
|
||||
|
||||
@@ -1187,9 +1191,9 @@ class EntropyPackages:
|
||||
|
||||
for repoid in self.Entropy.repositories():
|
||||
dbconn = self.Entropy.open_repository(repoid)
|
||||
repodata = dbconn.listAllIdpackages(order_by = 'atom')
|
||||
repodata = dbconn.listAllPackageIds(order_by = 'atom')
|
||||
def fm(idpackage):
|
||||
idpackage_filtered, idreason = dbconn.idpackageValidator(
|
||||
idpackage_filtered, idreason = dbconn.maskFilter(
|
||||
idpackage)
|
||||
if idpackage_filtered == -1:
|
||||
return ((idpackage, repoid,), idreason)
|
||||
@@ -1255,7 +1259,7 @@ class EntropyPackages:
|
||||
|
||||
def fm(item):
|
||||
idpackage = mydata[item]
|
||||
idpackage, idreason = dbconn.idpackageValidator(idpackage)
|
||||
idpackage, idreason = dbconn.maskFilter(idpackage)
|
||||
if idpackage != -1:
|
||||
return (clientdata[item], (mydata[item], repoid,))
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user