[entropy.tools] start moving Entropy dependency handling functions to entropy.dep module
This commit is contained in:
+13
-12
@@ -19,6 +19,7 @@ from entropy.output import darkgreen, darkred, red, blue, \
|
||||
from entropy.misc import Lifo
|
||||
from entropy.client.interfaces import Client as EquoInterface
|
||||
from entropy.i18n import _
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
from entropy.db.exceptions import DatabaseError
|
||||
|
||||
@@ -176,10 +177,10 @@ def get_installed_packages(packages, dbconn = None, entropy_intf = None):
|
||||
for real_package in packages:
|
||||
pkg_data[real_package] = set()
|
||||
|
||||
slot = entropy.tools.dep_getslot(real_package)
|
||||
tag = entropy.tools.dep_gettag(real_package)
|
||||
package = entropy.tools.remove_slot(real_package)
|
||||
package = entropy.tools.remove_tag(package)
|
||||
slot = entropy.dep.dep_getslot(real_package)
|
||||
tag = entropy.dep.dep_gettag(real_package)
|
||||
package = entropy.dep.remove_slot(real_package)
|
||||
package = entropy.dep.remove_tag(package)
|
||||
|
||||
idpackages = repo_db.searchPackages(package, slot = slot, tag = tag,
|
||||
just_id = True, order_by = "atom")
|
||||
@@ -420,7 +421,7 @@ def _graph_package(match, package, entropy_intf, show_complete = False):
|
||||
stack_cache = set()
|
||||
# ensure package availability in graph, initialize now
|
||||
graph.add(start_item, [])
|
||||
depsorter = lambda x: entropy.tools.dep_getcpv(x[0])
|
||||
depsorter = lambda x: entropy.dep.dep_getcpv(x[0])
|
||||
|
||||
while stack.is_filled():
|
||||
|
||||
@@ -1067,7 +1068,7 @@ def list_installed_packages(Equo = None, dbconn = None):
|
||||
|
||||
for atom, idpackage, branch in inst_packages:
|
||||
if not etpUi['verbose']:
|
||||
atom = entropy.tools.dep_getkey(atom)
|
||||
atom = entropy.dep.dep_getkey(atom)
|
||||
branchinfo = ""
|
||||
sizeinfo = ""
|
||||
if etpUi['verbose']:
|
||||
@@ -1096,10 +1097,10 @@ def search_package(packages, Equo = None, get_results = False,
|
||||
def do_adv_search(dbconn, from_client = False):
|
||||
pkg_ids = set()
|
||||
for package in packages:
|
||||
slot = entropy.tools.dep_getslot(package)
|
||||
tag = entropy.tools.dep_gettag(package)
|
||||
package = entropy.tools.remove_slot(package)
|
||||
package = entropy.tools.remove_tag(package)
|
||||
slot = entropy.dep.dep_getslot(package)
|
||||
tag = entropy.dep.dep_gettag(package)
|
||||
package = entropy.dep.remove_slot(package)
|
||||
package = entropy.dep.remove_tag(package)
|
||||
|
||||
try:
|
||||
result = set(dbconn.searchPackages(package, slot = slot,
|
||||
@@ -1563,7 +1564,7 @@ def print_package_info(idpackage, dbconn, clientSearch = False,
|
||||
installedRev = _("N/A")
|
||||
try:
|
||||
pkginstalled = Equo.installed_repository().atomMatch(
|
||||
entropy.tools.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
entropy.dep.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
if pkginstalled[1] == 0:
|
||||
idx = pkginstalled[0]
|
||||
# found
|
||||
@@ -1629,7 +1630,7 @@ def print_package_info(idpackage, dbconn, clientSearch = False,
|
||||
pkgdigest = dbconn.retrieveDigest(idpackage)
|
||||
pkgdeps = dbconn.retrieveDependencies(idpackage, extended = True)
|
||||
pkgconflicts = dbconn.retrieveConflicts(idpackage)
|
||||
depsorter = lambda x: entropy.tools.dep_getcpv(x[0])
|
||||
depsorter = lambda x: entropy.dep.dep_getcpv(x[0])
|
||||
|
||||
toc.append((darkgreen(" %s:" % (_("Size"),) ),
|
||||
blue(str(pkgsize)),))
|
||||
|
||||
@@ -19,6 +19,7 @@ from entropy.output import red, bold, brown, blue, darkred, darkgreen, purple, \
|
||||
print_info, print_warning, print_error
|
||||
from entropy.exceptions import SystemDatabaseError
|
||||
from entropy.db.exceptions import OperationalError
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
from entropy.client.interfaces import Client
|
||||
from entropy.i18n import _
|
||||
@@ -435,7 +436,7 @@ def _database_spmsync(entropy_client):
|
||||
atom = entropy_client.installed_repository().retrieveAtom(x[1])
|
||||
add = True
|
||||
if atom:
|
||||
atomkey = entropy.tools.dep_getkey(atom)
|
||||
atomkey = entropy.dep.dep_getkey(atom)
|
||||
atomslot = entropy_client.installed_repository().retrieveSlot(x[1])
|
||||
add = True
|
||||
for pkgdata in to_be_added:
|
||||
@@ -444,7 +445,7 @@ def _database_spmsync(entropy_client):
|
||||
pkgdata[0], "SLOT")
|
||||
except KeyError:
|
||||
continue
|
||||
addkey = entropy.tools.dep_getkey(pkgdata[0])
|
||||
addkey = entropy.dep.dep_getkey(pkgdata[0])
|
||||
# workaround for ebuilds not having slot
|
||||
if addslot is None:
|
||||
addslot = '0'
|
||||
|
||||
@@ -21,6 +21,7 @@ from entropy.const import etpConst, etpUi
|
||||
from entropy.output import red, darkred, darkgreen, brown, bold, \
|
||||
print_info, print_error, print_warning
|
||||
from entropy.i18n import _
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
from text_tools import acquire_entropy_locks, release_entropy_locks
|
||||
@@ -269,7 +270,7 @@ def deflate_handler(mytbz2s, savedir):
|
||||
if not ext_rc:
|
||||
return 1
|
||||
tbz2name = os.path.basename(tbz2)[:-len(etpConst['packagesext'])]
|
||||
tbz2name = entropy.tools.remove_tag(tbz2name)+etpConst['packagesext']
|
||||
tbz2name = entropy.dep.remove_tag(tbz2name)+etpConst['packagesext']
|
||||
newtbz2 = os.path.dirname(tbz2)+os.path.sep+tbz2name
|
||||
print_info(darkgreen(" * ")+darkred("%s: " % (_("Deflated package"),))+newtbz2)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from entropy.output import print_info, print_generic, writechar, blue, red, \
|
||||
brown, darkblue, purple, teal, darkgreen, decolorize
|
||||
from entropy.i18n import _
|
||||
|
||||
import entropy.tools
|
||||
import entropy.dep
|
||||
|
||||
def acquire_entropy_locks(entropy_client):
|
||||
"""
|
||||
@@ -313,21 +313,21 @@ def enlightenatom(atom):
|
||||
@return: colorized string
|
||||
@rtype: string
|
||||
"""
|
||||
entropy_rev = entropy.tools.dep_get_entropy_revision(atom)
|
||||
entropy_rev = entropy.dep.dep_get_entropy_revision(atom)
|
||||
if entropy_rev is None:
|
||||
entropy_rev = ''
|
||||
else:
|
||||
entropy_rev = '~%s' % (str(entropy_rev),)
|
||||
entropy_tag = entropy.tools.dep_gettag(atom)
|
||||
entropy_tag = entropy.dep.dep_gettag(atom)
|
||||
if entropy_tag is None:
|
||||
entropy_tag = ''
|
||||
else:
|
||||
entropy_tag = '#%s' % (entropy_tag,)
|
||||
clean_atom = entropy.tools.remove_entropy_revision(atom)
|
||||
clean_atom = entropy.tools.remove_tag(clean_atom)
|
||||
only_cpv = entropy.tools.dep_getcpv(clean_atom)
|
||||
clean_atom = entropy.dep.remove_entropy_revision(atom)
|
||||
clean_atom = entropy.dep.remove_tag(clean_atom)
|
||||
only_cpv = entropy.dep.dep_getcpv(clean_atom)
|
||||
operator = clean_atom[:len(clean_atom)-len(only_cpv)]
|
||||
cat, name, pv, rev = entropy.tools.catpkgsplit(only_cpv)
|
||||
cat, name, pv, rev = entropy.dep.catpkgsplit(only_cpv)
|
||||
if rev == "r0":
|
||||
rev = ''
|
||||
else:
|
||||
|
||||
+7
-6
@@ -30,6 +30,7 @@ from entropy.i18n import _
|
||||
from text_tools import countdown, enlightenatom, acquire_entropy_locks, \
|
||||
release_entropy_locks
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
import entropy.dump
|
||||
|
||||
@@ -706,7 +707,7 @@ def _scan_packages_expand_tag(entropy_client, packages):
|
||||
inst_repo = entropy_client.installed_repository()
|
||||
|
||||
def expand_package(dep):
|
||||
tag = entropy.tools.dep_gettag(dep)
|
||||
tag = entropy.dep.dep_gettag(dep)
|
||||
if tag is not None:
|
||||
# do not override packages already providing a tag
|
||||
return dep
|
||||
@@ -730,7 +731,7 @@ def _scan_packages_expand_tag(entropy_client, packages):
|
||||
return dep
|
||||
tags.add(pkg_tag)
|
||||
|
||||
best_tag = entropy.tools.sort_entropy_package_tags(
|
||||
best_tag = entropy.dep.sort_entropy_package_tags(
|
||||
tags)[-1]
|
||||
|
||||
proposed_dep = "%s%s%s" % (dep, etpConst['entropytagprefix'], best_tag)
|
||||
@@ -850,7 +851,7 @@ def _show_package_info(entropy_client, found_pkg_atoms, deps, action_name = None
|
||||
installedRev = "NoRev"
|
||||
installedRepo = _("Not available")
|
||||
pkginstalled = entropy_client.installed_repository().atomMatch(
|
||||
entropy.tools.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
entropy.dep.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
if (pkginstalled[1] == 0):
|
||||
# found
|
||||
idx = pkginstalled[0]
|
||||
@@ -1078,7 +1079,7 @@ def _fetch_packages(entropy_client, run_queue, downdata, multifetch = 1,
|
||||
if myrepo not in downdata:
|
||||
downdata[myrepo] = set()
|
||||
for myatom in myrepo_data[myrepo]:
|
||||
downdata[myrepo].add(entropy.tools.dep_getkey(myatom))
|
||||
downdata[myrepo].add(entropy.dep.dep_getkey(myatom))
|
||||
|
||||
xterm_header = "equo ("+_("fetch")+") :: "+str(fetchqueue)+" of "+mytotalqueue+" ::"
|
||||
print_info(red(" :: ")+bold("(")+blue(str(fetchqueue))+"/"+ \
|
||||
@@ -1104,7 +1105,7 @@ def _fetch_packages(entropy_client, run_queue, downdata, multifetch = 1,
|
||||
myrepo = Package.pkgmeta['repository']
|
||||
if myrepo not in downdata:
|
||||
downdata[myrepo] = set()
|
||||
downdata[myrepo].add(entropy.tools.dep_getkey(Package.pkgmeta['atom']))
|
||||
downdata[myrepo].add(entropy.dep.dep_getkey(Package.pkgmeta['atom']))
|
||||
|
||||
xterm_header = "equo ("+_("fetch")+") :: "+str(fetchqueue)+" of "+totalqueue+" ::"
|
||||
print_info(red(" :: ")+bold("(")+blue(str(fetchqueue))+"/"+ \
|
||||
@@ -1297,7 +1298,7 @@ def install_packages(entropy_client,
|
||||
installedRev = 0
|
||||
installedRepo = None
|
||||
pkginstalled = entropy_client.installed_repository().atomMatch(
|
||||
entropy.tools.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
entropy.dep.dep_getkey(pkgatom), matchSlot = pkgslot)
|
||||
if pkginstalled[1] == 0:
|
||||
# found an installed package
|
||||
idx = pkginstalled[0]
|
||||
|
||||
@@ -29,6 +29,7 @@ from entropy.cache import EntropyCacher
|
||||
from entropy.i18n import _
|
||||
|
||||
import entropy.dump
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class ClientSystemSettingsPlugin(SystemSettingsPlugin):
|
||||
@@ -246,7 +247,7 @@ class ClientSystemSettingsPlugin(SystemSettingsPlugin):
|
||||
multiMatch = True)
|
||||
if m_r != 0:
|
||||
continue
|
||||
mykey = entropy.tools.dep_getkey(atom)
|
||||
mykey = entropy.dep.dep_getkey(atom)
|
||||
obj = mask_installed_keys.setdefault(mykey, set())
|
||||
for m_id in m_ids:
|
||||
if m_id in mc_cache:
|
||||
|
||||
@@ -24,7 +24,7 @@ from entropy.db.exceptions import IntegrityError, OperationalError, \
|
||||
DatabaseError, InterfaceError
|
||||
from entropy.db.skel import EntropyRepositoryBase
|
||||
|
||||
import entropy.tools
|
||||
import entropy.dep
|
||||
|
||||
class CalculatorsMixin:
|
||||
|
||||
@@ -95,7 +95,7 @@ class CalculatorsMixin:
|
||||
version_duplicates.add(version)
|
||||
versions.add(version)
|
||||
|
||||
newer_ver = entropy.tools.get_newer_version(list(versions))[0]
|
||||
newer_ver = entropy.dep.get_newer_version(list(versions))[0]
|
||||
# if no duplicates are found or newer version is not in duplicates we're done
|
||||
if (not version_duplicates) or (newer_ver not in version_duplicates):
|
||||
reponame = ver_info.get(newer_ver)
|
||||
@@ -121,9 +121,9 @@ class CalculatorsMixin:
|
||||
conflict_entries[repo]['revision'] = pkg_info[repo]['revision']
|
||||
|
||||
# tags will always be != []
|
||||
newerTag = entropy.tools.sort_entropy_package_tags(tags)[-1]
|
||||
if newerTag not in tags_duplicates:
|
||||
reponame = tagsInfo.get(newerTag)
|
||||
newer_tag = entropy.dep.sort_entropy_package_tags(tags)[-1]
|
||||
if newer_tag not in tags_duplicates:
|
||||
reponame = tagsInfo.get(newer_tag)
|
||||
return (results[reponame], reponame)
|
||||
|
||||
# in this case, we have >two packages with the same version and tag
|
||||
@@ -134,7 +134,7 @@ class CalculatorsMixin:
|
||||
revisions_duplicates = set()
|
||||
revisionInfo = {}
|
||||
for repo in conflict_entries:
|
||||
if conflict_entries[repo]['versiontag'] == newerTag:
|
||||
if conflict_entries[repo]['versiontag'] == newer_tag:
|
||||
conflictingRevisions[repo] = {}
|
||||
versionrev = conflict_entries[repo]['revision']
|
||||
if versionrev in revisions:
|
||||
@@ -197,7 +197,7 @@ class CalculatorsMixin:
|
||||
|
||||
# support match in repository from shell
|
||||
# atom@repo1,repo2,repo3
|
||||
atom, repos = entropy.tools.dep_get_match_in_repos(atom)
|
||||
atom, repos = entropy.dep.dep_get_match_in_repos(atom)
|
||||
if (match_repo is None) and (repos is not None):
|
||||
match_repo = repos
|
||||
|
||||
@@ -376,8 +376,8 @@ class CalculatorsMixin:
|
||||
satisfied_data = tmp_satisfied_data
|
||||
self._settings[satisfied_kw] = satisfied_data
|
||||
|
||||
etp_cmp = entropy.tools.entropy_compare_versions
|
||||
etp_get_rev = entropy.tools.dep_get_entropy_revision
|
||||
etp_cmp = entropy.dep.entropy_compare_versions
|
||||
etp_get_rev = entropy.dep.dep_get_entropy_revision
|
||||
|
||||
if depcache is None:
|
||||
depcache = {}
|
||||
@@ -446,14 +446,14 @@ class CalculatorsMixin:
|
||||
# check if dependency can be matched in available repos and
|
||||
# if it is a tagged package, in this case, we need to rewrite
|
||||
# the dependency string to restrict its scope
|
||||
dependency_tag = entropy.tools.dep_gettag(dependency)
|
||||
dependency_tag = entropy.dep.dep_gettag(dependency)
|
||||
if not dependency_tag:
|
||||
# also filter out empty tags (pkgs without tags)
|
||||
av_tags = [x for x in \
|
||||
_my_get_available_tags(dependency, None) if x]
|
||||
if av_tags:
|
||||
matching_tags = set()
|
||||
i_key = entropy.tools.dep_getkey(dependency)
|
||||
i_key = entropy.dep.dep_getkey(dependency)
|
||||
for a_tag in av_tags:
|
||||
a_dep_tag = i_key + \
|
||||
etpConst['entropytagprefix'] + a_tag
|
||||
@@ -465,7 +465,7 @@ class CalculatorsMixin:
|
||||
matching_tags.add(a_tag)
|
||||
|
||||
if matching_tags:
|
||||
best_tag = entropy.tools.sort_entropy_package_tags(
|
||||
best_tag = entropy.dep.sort_entropy_package_tags(
|
||||
matching_tags)[-1]
|
||||
dependency += etpConst['entropytagprefix'] + \
|
||||
best_tag
|
||||
@@ -499,7 +499,7 @@ class CalculatorsMixin:
|
||||
|
||||
# WARN: unfortunately, need to deal with Portage (and other
|
||||
# backends) old-style PROVIDE metadata
|
||||
if entropy.tools.dep_getcat(dependency) == \
|
||||
if entropy.dep.dep_getcat(dependency) == \
|
||||
EntropyRepositoryBase.VIRTUAL_META_PACKAGE_CATEGORY:
|
||||
provide_stop = False
|
||||
for c_id in c_ids:
|
||||
@@ -566,7 +566,7 @@ class CalculatorsMixin:
|
||||
# restrict dependency matching scope inside mutually available
|
||||
# package tags. Equals to tags available in both installed and
|
||||
# available repositories.
|
||||
dependency_tag = entropy.tools.dep_gettag(dependency)
|
||||
dependency_tag = entropy.dep.dep_gettag(dependency)
|
||||
installed_tags = [x[1] for x in client_data if x[1]]
|
||||
if installed_tags and not dependency_tag:
|
||||
|
||||
@@ -579,7 +579,7 @@ class CalculatorsMixin:
|
||||
# NOW, reset variables used here below to make them
|
||||
# pointing to proper tagged package, keeping scoped
|
||||
# handling.
|
||||
best_tag = entropy.tools.sort_entropy_package_tags(
|
||||
best_tag = entropy.dep.sort_entropy_package_tags(
|
||||
available_tags)[-1]
|
||||
|
||||
# also change "dependency" to make it pointing to a
|
||||
@@ -935,7 +935,7 @@ class CalculatorsMixin:
|
||||
return mydata
|
||||
|
||||
def _lookup_conflict_replacement(self, conflict_atom, client_idpackage, deep_deps):
|
||||
if entropy.tools.isjustname(conflict_atom):
|
||||
if entropy.dep.isjustname(conflict_atom):
|
||||
return
|
||||
|
||||
conflict_match = self.atom_match(conflict_atom)
|
||||
@@ -2047,8 +2047,8 @@ class CalculatorsMixin:
|
||||
matched = None
|
||||
if pkg_id != -1:
|
||||
myatom = self._installed_repository.retrieveAtom(pkg_id)
|
||||
mytag = entropy.tools.dep_gettag(myatom)
|
||||
myatom = entropy.tools.remove_tag(myatom)
|
||||
mytag = entropy.dep.dep_gettag(myatom)
|
||||
myatom = entropy.dep.remove_tag(myatom)
|
||||
myrev = self._installed_repository.retrieveRevision(pkg_id)
|
||||
pkg_match = "="+myatom+"~"+str(myrev)
|
||||
if mytag is not None:
|
||||
@@ -2057,7 +2057,7 @@ class CalculatorsMixin:
|
||||
deep_deps = deep)
|
||||
if pkg_unsatisfied:
|
||||
# does it really exist on current repos?
|
||||
pkg_key = entropy.tools.dep_getkey(myatom)
|
||||
pkg_key = entropy.dep.dep_getkey(myatom)
|
||||
f_pkg_id, pkg_repo = self.atom_match(pkg_key)
|
||||
if f_pkg_id != -1:
|
||||
found = True
|
||||
@@ -2090,7 +2090,7 @@ class CalculatorsMixin:
|
||||
dbconn = self.open_repository(repo_id)
|
||||
|
||||
pkgatom = dbconn.retrieveAtom(package_id)
|
||||
pkgkey = entropy.tools.dep_getkey(pkgatom)
|
||||
pkgkey = entropy.dep.dep_getkey(pkgatom)
|
||||
cl_set_plg = self.sys_settings_client_plugin_id
|
||||
mask_data = self._settings[cl_set_plg]['system_mask']
|
||||
mask_installed_keys = mask_data['repos_installed_keys']
|
||||
|
||||
@@ -1716,7 +1716,7 @@ class MatchMixin:
|
||||
pkgver, pkgtag, pkgrev = dbconn.getVersioningData(package_match[0])
|
||||
installed_ver, installed_tag, installed_rev = \
|
||||
self._installed_repository.getVersioningData(installed_idpackage)
|
||||
pkgcmp = entropy.tools.entropy_compare_versions(
|
||||
pkgcmp = entropy.dep.entropy_compare_versions(
|
||||
(pkgver, pkgtag, pkgrev),
|
||||
(installed_ver, installed_tag, installed_rev))
|
||||
if pkgcmp == 0:
|
||||
|
||||
@@ -28,6 +28,7 @@ from entropy.client.mirrors import StatusInterface
|
||||
from entropy.core.settings.base import SystemSettings
|
||||
from entropy.security import Repository as RepositorySecurity
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class Package:
|
||||
@@ -2829,7 +2830,7 @@ class Package:
|
||||
# -- of course, we need to drop versiontag before being able to look
|
||||
# for other pkgs with same atom but different tag (which is an
|
||||
# entropy-only metadatum)
|
||||
test_atom = entropy.tools.remove_tag(self.pkgmeta['removeatom'])
|
||||
test_atom = entropy.dep.remove_tag(self.pkgmeta['removeatom'])
|
||||
others_installed = self._entropy.installed_repository().getPackageIds(
|
||||
test_atom)
|
||||
|
||||
@@ -3389,7 +3390,7 @@ class Package:
|
||||
self.pkgmeta['merge_from'] = const_convert_to_unicode(mf)
|
||||
self.pkgmeta['removeconfig'] = remove_config
|
||||
|
||||
pkgkey = entropy.tools.dep_getkey(self.pkgmeta['atom'])
|
||||
pkgkey = entropy.dep.dep_getkey(self.pkgmeta['atom'])
|
||||
inst_idpackage, inst_rc = inst_repo.atomMatch(pkgkey,
|
||||
matchSlot = self.pkgmeta['slot'])
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from entropy.const import etpConst, const_setup_perms, const_convert_to_unicode
|
||||
from entropy.exceptions import InvalidPackageSet
|
||||
from entropy.core.settings.base import SystemSettings
|
||||
|
||||
import entropy.tools
|
||||
import entropy.dep
|
||||
|
||||
|
||||
class Sets:
|
||||
@@ -85,7 +85,7 @@ class Sets:
|
||||
|
||||
# support match in repository from shell
|
||||
# set@repo1,repo2,repo3
|
||||
package_set, repos = entropy.tools.dep_get_match_in_repos(
|
||||
package_set, repos = entropy.dep.dep_get_match_in_repos(
|
||||
package_set)
|
||||
if (match_repo is None) and (repos is not None):
|
||||
match_repo = repos
|
||||
|
||||
@@ -18,6 +18,7 @@ from entropy.const import etpConst, const_isunicode, etpSys, etpUi
|
||||
from entropy.output import brown, bold, darkred, red
|
||||
from entropy.i18n import _
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class Trigger:
|
||||
@@ -236,7 +237,7 @@ class Trigger:
|
||||
if const_isunicode(pv):
|
||||
pv = pv.encode('utf-8')
|
||||
|
||||
pr = entropy.tools.dep_get_spm_revision(pv)
|
||||
pr = entropy.dep.dep_get_spm_revision(pv)
|
||||
pvr = pv
|
||||
if pr == "r0":
|
||||
pvr += "-%s" % (pr,)
|
||||
@@ -258,7 +259,7 @@ class Trigger:
|
||||
slot = slot.encode('utf-8')
|
||||
|
||||
pkgatom = pkgdata.get('atom')
|
||||
pkgkey = entropy.tools.dep_getkey(pkgatom)
|
||||
pkgkey = entropy.dep.dep_getkey(pkgatom)
|
||||
pvrte = pkgatom[len(pkgkey)+1:]
|
||||
if const_isunicode(pvrte):
|
||||
pvrte = pvrte.encode('utf-8')
|
||||
|
||||
@@ -24,6 +24,7 @@ from entropy.exceptions import RepositoryPluginError
|
||||
from entropy.spm.plugins.factory import get_default_instance as get_spm
|
||||
from entropy.db.exceptions import OperationalError
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class EntropyRepositoryPlugin(object):
|
||||
@@ -475,7 +476,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
atom = doaction[1]
|
||||
from_slot = doaction[2]
|
||||
to_slot = doaction[3]
|
||||
atom_key = entropy.tools.dep_getkey(atom)
|
||||
atom_key = entropy.dep.dep_getkey(atom)
|
||||
category = atom_key.split("/")[0]
|
||||
matches, sm_rc = self.atomMatch(atom, matchSlot = from_slot,
|
||||
multiMatch = True)
|
||||
@@ -502,14 +503,14 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
dep_atoms = self.searchDependency(atom_key, like = True,
|
||||
multi = True, strings = True)
|
||||
dep_atoms = [x for x in dep_atoms if x.endswith(":"+from_slot) \
|
||||
and entropy.tools.dep_getkey(x) == atom_key]
|
||||
and entropy.dep.dep_getkey(x) == atom_key]
|
||||
if dep_atoms:
|
||||
new_actions.append(action)
|
||||
|
||||
elif doaction[0] == "move":
|
||||
|
||||
atom = doaction[1] # usually a key
|
||||
atom_key = entropy.tools.dep_getkey(atom)
|
||||
atom_key = entropy.dep.dep_getkey(atom)
|
||||
category = atom_key.split("/")[0]
|
||||
matches, m_rc = self.atomMatch(atom, multiMatch = True)
|
||||
if m_rc == 1:
|
||||
@@ -532,7 +533,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
dep_atoms = self.searchDependency(atom_key, like = True,
|
||||
multi = True, strings = True)
|
||||
dep_atoms = [x for x in dep_atoms if \
|
||||
entropy.tools.dep_getkey(x) == atom_key]
|
||||
entropy.dep.dep_getkey(x) == atom_key]
|
||||
if dep_atoms:
|
||||
new_actions.append(action)
|
||||
|
||||
@@ -1552,7 +1553,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
@rtype: list
|
||||
"""
|
||||
dep_from = move_command[0]
|
||||
key_from = entropy.tools.dep_getkey(dep_from)
|
||||
key_from = entropy.dep.dep_getkey(dep_from)
|
||||
key_to = move_command[1]
|
||||
cat_to = key_to.split("/")[0]
|
||||
name_to = key_to.split("/")[1]
|
||||
@@ -1590,7 +1591,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
for iddep in iddeps:
|
||||
# update string
|
||||
mydep = self.getDependency(iddep)
|
||||
mydep_key = entropy.tools.dep_getkey(mydep)
|
||||
mydep_key = entropy.dep.dep_getkey(mydep)
|
||||
# avoid changing wrong atoms -> dev-python/qscintilla-python would
|
||||
# become x11-libs/qscintilla if we don't do this check
|
||||
if mydep_key != key_from:
|
||||
@@ -1643,7 +1644,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
@rtype: list
|
||||
"""
|
||||
atom = slotmove_command[0]
|
||||
atomkey = entropy.tools.dep_getkey(atom)
|
||||
atomkey = entropy.dep.dep_getkey(atom)
|
||||
slot_from = slotmove_command[1]
|
||||
slot_to = slotmove_command[2]
|
||||
matches = self.atomMatch(atom, multiMatch = True)
|
||||
@@ -1666,7 +1667,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
for iddep in iddeps:
|
||||
# update string
|
||||
mydep = self.getDependency(iddep)
|
||||
mydep_key = entropy.tools.dep_getkey(mydep)
|
||||
mydep_key = entropy.dep.dep_getkey(mydep)
|
||||
if mydep_key != atomkey:
|
||||
continue
|
||||
if not mydep.endswith(":"+slot_from): # probably slotted dep
|
||||
@@ -1717,7 +1718,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
|
||||
key = command[1]
|
||||
category, name = key.split("/", 1)
|
||||
dep_key = entropy.tools.dep_getkey(key)
|
||||
dep_key = entropy.dep.dep_getkey(key)
|
||||
|
||||
try:
|
||||
spm = get_spm(self)
|
||||
@@ -1733,7 +1734,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
|
||||
mydirs = [os.path.join(pkg_path, x) for x in \
|
||||
os.listdir(pkg_path) if \
|
||||
entropy.tools.dep_getkey(os.path.join(category, x)) \
|
||||
entropy.dep.dep_getkey(os.path.join(category, x)) \
|
||||
== dep_key]
|
||||
mydirs = [x for x in mydirs if os.path.isdir(x)]
|
||||
|
||||
@@ -4039,29 +4040,29 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
if rc == 0:
|
||||
return data, rc
|
||||
|
||||
matchTag = entropy.tools.dep_gettag(atom)
|
||||
matchTag = entropy.dep.dep_gettag(atom)
|
||||
try:
|
||||
matchUse = entropy.tools.dep_getusedeps(atom)
|
||||
matchUse = entropy.dep.dep_getusedeps(atom)
|
||||
except InvalidAtom:
|
||||
matchUse = ()
|
||||
atomSlot = entropy.tools.dep_getslot(atom)
|
||||
matchRevision = entropy.tools.dep_get_entropy_revision(atom)
|
||||
atomSlot = entropy.dep.dep_getslot(atom)
|
||||
matchRevision = entropy.dep.dep_get_entropy_revision(atom)
|
||||
if isinstance(matchRevision, int):
|
||||
if matchRevision < 0:
|
||||
matchRevision = None
|
||||
|
||||
# use match
|
||||
scan_atom = entropy.tools.remove_usedeps(atom)
|
||||
scan_atom = entropy.dep.remove_usedeps(atom)
|
||||
# tag match
|
||||
scan_atom = entropy.tools.remove_tag(scan_atom)
|
||||
scan_atom = entropy.dep.remove_tag(scan_atom)
|
||||
|
||||
# slot match
|
||||
scan_atom = entropy.tools.remove_slot(scan_atom)
|
||||
scan_atom = entropy.dep.remove_slot(scan_atom)
|
||||
if (matchSlot is None) and (atomSlot is not None):
|
||||
matchSlot = atomSlot
|
||||
|
||||
# revision match
|
||||
scan_atom = entropy.tools.remove_entropy_revision(scan_atom)
|
||||
scan_atom = entropy.dep.remove_entropy_revision(scan_atom)
|
||||
|
||||
direction = ''
|
||||
justname = True
|
||||
@@ -4077,24 +4078,24 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
|
||||
while True:
|
||||
# check for direction
|
||||
scan_cpv = entropy.tools.dep_getcpv(scan_atom)
|
||||
scan_cpv = entropy.dep.dep_getcpv(scan_atom)
|
||||
stripped_atom = scan_cpv
|
||||
if scan_atom.endswith("*"):
|
||||
stripped_atom += "*"
|
||||
direction = scan_atom[0:-len(stripped_atom)]
|
||||
|
||||
justname = entropy.tools.isjustname(stripped_atom)
|
||||
justname = entropy.dep.isjustname(stripped_atom)
|
||||
pkgkey = stripped_atom
|
||||
if justname == 0:
|
||||
# get version
|
||||
data = entropy.tools.catpkgsplit(scan_cpv)
|
||||
data = entropy.dep.catpkgsplit(scan_cpv)
|
||||
if data is None:
|
||||
break # badly formatted
|
||||
wildcard = ""
|
||||
if scan_atom.endswith("*"):
|
||||
wildcard = "*"
|
||||
pkgversion = data[2]+wildcard+"-"+data[3]
|
||||
pkgkey = entropy.tools.dep_getkey(stripped_atom)
|
||||
pkgkey = entropy.dep.dep_getkey(stripped_atom)
|
||||
|
||||
splitkey = pkgkey.split("/")
|
||||
if (len(splitkey) == 2):
|
||||
@@ -4236,7 +4237,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
versions = set(((ver, tag, rev) for ver, tag, rev in versions \
|
||||
if not tag))
|
||||
|
||||
newer = entropy.tools.get_entropy_newer_version(list(versions))[0]
|
||||
newer = entropy.dep.get_entropy_newer_version(list(versions))[0]
|
||||
x = pkgdata[newer]
|
||||
if extendedResults:
|
||||
x = (x, 0, newer[0], newer[1], newer[2])
|
||||
@@ -4373,21 +4374,21 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
# remove gentoo revision (-r0 if none)
|
||||
if (direction == "="):
|
||||
if (pkgversion.split("-")[-1] == "r0"):
|
||||
pkgversion = entropy.tools.remove_revision(
|
||||
pkgversion = entropy.dep.remove_revision(
|
||||
pkgversion)
|
||||
|
||||
if (direction == "~"):
|
||||
pkgrevision = entropy.tools.dep_get_spm_revision(
|
||||
pkgrevision = entropy.dep.dep_get_spm_revision(
|
||||
pkgversion)
|
||||
pkgversion = entropy.tools.remove_revision(pkgversion)
|
||||
pkgversion = entropy.dep.remove_revision(pkgversion)
|
||||
|
||||
for package_id in found_ids:
|
||||
|
||||
dbver = self.retrieveVersion(package_id)
|
||||
if (direction == "~"):
|
||||
myrev = entropy.tools.dep_get_spm_revision(
|
||||
myrev = entropy.dep.dep_get_spm_revision(
|
||||
dbver)
|
||||
myver = entropy.tools.remove_revision(dbver)
|
||||
myver = entropy.dep.remove_revision(dbver)
|
||||
if myver == pkgversion and pkgrevision <= myrev:
|
||||
# found
|
||||
dbpkginfo.add((package_id, dbver))
|
||||
@@ -4410,7 +4411,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
# remove revision (-r0 if none)
|
||||
if pkgversion.endswith("r0"):
|
||||
# remove
|
||||
entropy.tools.remove_revision(pkgversion)
|
||||
entropy.dep.remove_revision(pkgversion)
|
||||
|
||||
for package_id in found_ids:
|
||||
|
||||
@@ -4425,7 +4426,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore, object)
|
||||
tagcmp = const_cmp(matchTag, dbtag)
|
||||
|
||||
dbver = self.retrieveVersion(package_id)
|
||||
pkgcmp = entropy.tools.compare_versions(
|
||||
pkgcmp = entropy.dep.compare_versions(
|
||||
pkgversion, dbver)
|
||||
|
||||
if pkgcmp is None:
|
||||
|
||||
@@ -0,0 +1,717 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Entropy miscellaneous tools module
|
||||
"""
|
||||
|
||||
@author: Fabio Erculiani <lxnay@sabayon.org>
|
||||
@contact: lxnay@sabayon.org
|
||||
@copyright: Fabio Erculiani
|
||||
@license: GPL-2
|
||||
|
||||
B{Entropy dependency functions module}.
|
||||
This module contains Entropy package dependency manipulation functions.
|
||||
|
||||
"""
|
||||
import re
|
||||
from entropy.exceptions import InvalidAtom
|
||||
from entropy.const import etpConst, const_cmp
|
||||
|
||||
# Imported from Gentoo portage_dep.py
|
||||
# Copyright 1999-2010 Gentoo Foundation
|
||||
|
||||
# 2.1.1 A category name may contain any of the characters [A-Za-z0-9+_.-].
|
||||
# It must not begin with a hyphen or a dot.
|
||||
_cat = r'[\w+][\w+.-]*'
|
||||
|
||||
# 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-].
|
||||
# It must not begin with a hyphen,
|
||||
# and must not end in a hyphen followed by one or more digits.
|
||||
_pkg = r'[\w+][\w+-]*?'
|
||||
|
||||
_v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)'
|
||||
_rev = r'\d+'
|
||||
_vr = _v + '(-r(' + _rev + '))?'
|
||||
|
||||
_cp = '(' + _cat + '/' + _pkg + '(-' + _vr + ')?)'
|
||||
_cpv = '(' + _cp + '-' + _vr + ')'
|
||||
_pv = '(?P<pn>' + _pkg + '(?P<pn_inval>-' + _vr + ')?)' + '-(?P<ver>' + _v + ')(-r(?P<rev>' + _rev + '))?'
|
||||
|
||||
ver_regexp = re.compile("^" + _vr + "$")
|
||||
suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
|
||||
suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
|
||||
endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
|
||||
|
||||
valid_category = re.compile("^\w[\w-]*")
|
||||
invalid_atom_chars_regexp = re.compile("[()|@]")
|
||||
|
||||
def _ververify(myver):
|
||||
if myver.endswith("*"):
|
||||
m = ver_regexp.match(myver[:-1])
|
||||
else:
|
||||
m = ver_regexp.match(myver)
|
||||
if m:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _isspecific(mypkg):
|
||||
"""
|
||||
Checks to see if a package is in category/package-version or package-version format,
|
||||
possibly returning a cached result.
|
||||
|
||||
Example usage:
|
||||
>>> _isspecific('media-libs/test')
|
||||
False
|
||||
>>> _isspecific('media-libs/test-3.0')
|
||||
True
|
||||
|
||||
@param mypkg: the package depstring to check against
|
||||
@type mypkg: string
|
||||
@rtype: int
|
||||
@return: One of the following:
|
||||
1) False if the package string is not specific
|
||||
2) True if it is
|
||||
"""
|
||||
mysplit = mypkg.split("/")
|
||||
if not isjustname(mysplit[-1]):
|
||||
return True
|
||||
return False
|
||||
|
||||
_pv_re = re.compile('^' + _pv + '$', re.VERBOSE)
|
||||
def _pkgsplit(mypkg):
|
||||
"""
|
||||
@param mypkg: pv
|
||||
@return:
|
||||
1. None if input is invalid.
|
||||
2. (pn, ver, rev) if input is pv
|
||||
"""
|
||||
m = _pv_re.match(mypkg)
|
||||
if m is None:
|
||||
return None
|
||||
|
||||
if m.group('pn_inval') is not None:
|
||||
# package name appears to have a version-like suffix
|
||||
return None
|
||||
|
||||
rev = m.group('rev')
|
||||
if rev is None:
|
||||
rev = '0'
|
||||
rev = 'r' + rev
|
||||
|
||||
return (m.group('pn'), m.group('ver'), rev)
|
||||
|
||||
def _generic_sorter(inputlist, cmp_func):
|
||||
|
||||
inputs = inputlist[:]
|
||||
if len(inputs) < 2:
|
||||
return inputs
|
||||
max_idx = len(inputs)
|
||||
|
||||
while True:
|
||||
changed = False
|
||||
for idx in range(max_idx):
|
||||
second_idx = idx+1
|
||||
if second_idx == max_idx:
|
||||
continue
|
||||
str_a = inputs[idx]
|
||||
str_b = inputs[second_idx]
|
||||
if cmp_func(str_a, str_b) < 0:
|
||||
inputs[idx] = str_b
|
||||
inputs[second_idx] = str_a
|
||||
changed = True
|
||||
if not changed:
|
||||
break
|
||||
|
||||
return inputs
|
||||
|
||||
def isjustname(mypkg):
|
||||
"""
|
||||
Checks to see if the depstring is only the package name (no version parts)
|
||||
|
||||
Example usage:
|
||||
>>> isjustname('media-libs/test-3.0')
|
||||
False
|
||||
>>> isjustname('test')
|
||||
True
|
||||
>>> isjustname('media-libs/test')
|
||||
True
|
||||
|
||||
@param mypkg: the package atom to check
|
||||
@param mypkg: string
|
||||
@rtype: int
|
||||
@return: if the package string is not just the package name
|
||||
"""
|
||||
for chunk in mypkg.split('-')[-2:]:
|
||||
if _ververify(chunk):
|
||||
return False
|
||||
return True
|
||||
|
||||
def catpkgsplit(mydata):
|
||||
"""
|
||||
Takes a Category/Package-Version-Rev and returns a list of each.
|
||||
|
||||
@param mydata: data to split
|
||||
@type mydata: string
|
||||
@rype: tuple
|
||||
@return:
|
||||
1. If each exists, it returns (cat, pkgname, version, rev)
|
||||
2. If cat is not specificed in mydata, cat will be "null"
|
||||
3. if rev does not exist it will be '-r0'
|
||||
"""
|
||||
|
||||
# Categories may contain a-zA-z0-9+_- but cannot start with -
|
||||
mysplit = mydata.split("/")
|
||||
p_split = None
|
||||
if len(mysplit) == 1:
|
||||
retval = ("null",)
|
||||
p_split = _pkgsplit(mydata)
|
||||
elif len(mysplit) == 2:
|
||||
retval = (mysplit[0],)
|
||||
p_split = _pkgsplit(mysplit[1])
|
||||
if not p_split:
|
||||
return None
|
||||
retval += p_split
|
||||
return retval
|
||||
|
||||
def dep_getkey(mydep):
|
||||
"""
|
||||
Return the category/package-name of a depstring.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getkey('media-libs/test-3.0')
|
||||
'media-libs/test'
|
||||
|
||||
@param mydep: the depstring to retrieve the category/package-name of
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the package category/package-version
|
||||
"""
|
||||
if not mydep:
|
||||
return mydep
|
||||
mydep = remove_tag(mydep)
|
||||
mydep = remove_usedeps(mydep)
|
||||
|
||||
mydep = dep_getcpv(mydep)
|
||||
if mydep and _isspecific(mydep):
|
||||
mysplit = catpkgsplit(mydep)
|
||||
if not mysplit:
|
||||
return mydep
|
||||
return mysplit[0] + "/" + mysplit[1]
|
||||
|
||||
return mydep
|
||||
|
||||
def dep_getcat(mydep):
|
||||
"""
|
||||
Extract package category from dependency.
|
||||
"""
|
||||
return dep_getkey(mydep).split("/")[0]
|
||||
|
||||
def dep_getcpv(mydep):
|
||||
"""
|
||||
Return the category-package-version with any operators/slot specifications stripped off
|
||||
|
||||
Example usage:
|
||||
>>> dep_getcpv('>=media-libs/test-3.0')
|
||||
'media-libs/test-3.0'
|
||||
|
||||
@param mydep: the depstring
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the depstring with the operator removed
|
||||
"""
|
||||
if mydep and mydep[0] == "*":
|
||||
mydep = mydep[1:]
|
||||
if mydep and mydep[-1] == "*":
|
||||
mydep = mydep[:-1]
|
||||
if mydep and mydep[0] == "!":
|
||||
mydep = mydep[1:]
|
||||
if mydep[:2] in [">=", "<="]:
|
||||
mydep = mydep[2:]
|
||||
elif mydep[:1] in "=<>~":
|
||||
mydep = mydep[1:]
|
||||
colon = mydep.rfind(":")
|
||||
if colon != -1:
|
||||
mydep = mydep[:colon]
|
||||
|
||||
return mydep
|
||||
|
||||
def dep_getslot(mydep):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
|
||||
Retrieve the slot on a depend.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getslot('app-misc/test:3')
|
||||
'3'
|
||||
|
||||
@param mydep: the depstring to retrieve the slot of
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the slot
|
||||
"""
|
||||
colon = mydep.find(":")
|
||||
if colon != -1:
|
||||
bracket = mydep.find("[", colon)
|
||||
if bracket == -1:
|
||||
return mydep[colon+1:]
|
||||
else:
|
||||
return mydep[colon+1:bracket]
|
||||
return None
|
||||
|
||||
def dep_getusedeps(depend):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
|
||||
Pull a listing of USE Dependencies out of a dep atom.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getusedeps('app-misc/test:3[foo,-bar]')
|
||||
('foo', '-bar')
|
||||
|
||||
@param depend: The depstring to process
|
||||
@type depend: String
|
||||
@rtype: List
|
||||
@return: List of use flags ( or [] if no flags exist )
|
||||
"""
|
||||
use_list = []
|
||||
open_bracket = depend.find('[')
|
||||
# -1 = failure (think c++ string::npos)
|
||||
comma_separated = False
|
||||
bracket_count = 0
|
||||
while( open_bracket != -1 ):
|
||||
bracket_count += 1
|
||||
if bracket_count > 1:
|
||||
InvalidAtom("USE Dependency with more " + \
|
||||
"than one set of brackets: %s" % (depend,))
|
||||
close_bracket = depend.find(']', open_bracket )
|
||||
if close_bracket == -1:
|
||||
InvalidAtom("USE Dependency with no closing bracket: %s" % depend )
|
||||
use = depend[open_bracket + 1: close_bracket]
|
||||
# foo[1:1] may return '' instead of None, we don't want '' in the result
|
||||
if not use:
|
||||
InvalidAtom("USE Dependency with " + \
|
||||
"no use flag ([]): %s" % depend )
|
||||
if not comma_separated:
|
||||
comma_separated = "," in use
|
||||
|
||||
if comma_separated and bracket_count > 1:
|
||||
InvalidAtom("USE Dependency contains a mixture of " + \
|
||||
"comma and bracket separators: %s" % depend )
|
||||
|
||||
if comma_separated:
|
||||
for x in use.split(","):
|
||||
if x:
|
||||
use_list.append(x)
|
||||
else:
|
||||
InvalidAtom("USE Dependency with no use " + \
|
||||
"flag next to comma: %s" % depend )
|
||||
else:
|
||||
use_list.append(use)
|
||||
|
||||
# Find next use flag
|
||||
open_bracket = depend.find( '[', open_bracket+1 )
|
||||
|
||||
return tuple(use_list)
|
||||
|
||||
def remove_usedeps(depend):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param depend:
|
||||
@type depend:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
new_depend = ""
|
||||
skip = 0
|
||||
for char in depend:
|
||||
if char == "[":
|
||||
skip += 1
|
||||
elif char == "]":
|
||||
skip -= 1
|
||||
continue
|
||||
if skip == 0:
|
||||
new_depend += char
|
||||
|
||||
return new_depend
|
||||
|
||||
def remove_slot(mydep):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
|
||||
Removes dep components from the right side of an atom:
|
||||
* slot
|
||||
* use
|
||||
* repo
|
||||
"""
|
||||
colon = mydep.find(":")
|
||||
if colon != -1:
|
||||
mydep = mydep[:colon]
|
||||
else:
|
||||
bracket = mydep.find("[")
|
||||
if bracket != -1:
|
||||
mydep = mydep[:bracket]
|
||||
return mydep
|
||||
|
||||
# input must be a valid package version or a full atom
|
||||
def remove_revision(ver):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param ver:
|
||||
@type ver:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
myver = ver.split("-")
|
||||
if myver[-1][0] == "r":
|
||||
return '-'.join(myver[:-1])
|
||||
return ver
|
||||
|
||||
def remove_tag(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
colon = mydep.rfind(etpConst['entropytagprefix'])
|
||||
if colon == -1:
|
||||
return mydep
|
||||
return mydep[:colon]
|
||||
|
||||
def remove_entropy_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
dep = remove_package_operators(mydep)
|
||||
operators = mydep[:-len(dep)]
|
||||
colon = dep.rfind("~")
|
||||
if colon == -1:
|
||||
return mydep
|
||||
return operators+dep[:colon]
|
||||
|
||||
def dep_get_entropy_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
#dep = remove_package_operators(mydep)
|
||||
colon = mydep.rfind("~")
|
||||
if colon != -1:
|
||||
myrev = mydep[colon+1:]
|
||||
try:
|
||||
myrev = int(myrev)
|
||||
except ValueError:
|
||||
return None
|
||||
return myrev
|
||||
return None
|
||||
|
||||
def dep_split_or_deps(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
dep = mydep.rstrip(etpConst['entropyordepquestion'])
|
||||
return dep.split(etpConst['entropyordepsep'])
|
||||
|
||||
dep_revmatch = re.compile('^r[0-9]')
|
||||
def dep_get_spm_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
myver = mydep.split("-")
|
||||
myrev = myver[-1]
|
||||
if dep_revmatch.match(myrev):
|
||||
return myrev
|
||||
else:
|
||||
return "r0"
|
||||
|
||||
def dep_get_match_in_repos(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
colon = mydep.rfind("@")
|
||||
if colon != -1:
|
||||
mydata = mydep[colon+1:]
|
||||
mydata = mydata.split(",")
|
||||
if not mydata:
|
||||
mydata = None
|
||||
return mydep[:colon], mydata
|
||||
else:
|
||||
return mydep, None
|
||||
|
||||
def dep_gettag(mydep):
|
||||
|
||||
"""
|
||||
Retrieve the slot on a depend.
|
||||
|
||||
Example usage:
|
||||
>>> dep_gettag('app-misc/test#2.6.23-sabayon-r1')
|
||||
'2.6.23-sabayon-r1'
|
||||
|
||||
"""
|
||||
dep = mydep[:]
|
||||
dep = remove_entropy_revision(dep)
|
||||
colon = dep.rfind(etpConst['entropytagprefix'])
|
||||
if colon != -1:
|
||||
mydep = dep[colon+1:]
|
||||
rslt = remove_slot(mydep)
|
||||
return rslt
|
||||
return None
|
||||
|
||||
def remove_package_operators(atom):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param atom:
|
||||
@type atom:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
return atom.lstrip("><=~")
|
||||
|
||||
def compare_versions(ver1, ver2):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param ver1:
|
||||
@type ver1:
|
||||
@param ver2:
|
||||
@type ver2:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
if ver1 == ver2:
|
||||
return 0
|
||||
match1 = None
|
||||
match2 = None
|
||||
if ver1:
|
||||
match1 = ver_regexp.match(ver1)
|
||||
if ver2:
|
||||
match2 = ver_regexp.match(ver2)
|
||||
|
||||
# checking that the versions are valid
|
||||
invalid = False
|
||||
invalid_rc = 0
|
||||
if not match1:
|
||||
invalid = True
|
||||
elif not match1.groups():
|
||||
invalid = True
|
||||
elif not match2:
|
||||
invalid_rc = 1
|
||||
invalid = True
|
||||
elif not match2.groups():
|
||||
invalid_rc = 1
|
||||
invalid = True
|
||||
if invalid:
|
||||
return invalid_rc
|
||||
|
||||
# building lists of the version parts before the suffix
|
||||
# first part is simple
|
||||
list1 = [int(match1.group(2))]
|
||||
list2 = [int(match2.group(2))]
|
||||
|
||||
# this part would greatly benefit from a fixed-length version pattern
|
||||
if len(match1.group(3)) or len(match2.group(3)):
|
||||
vlist1 = match1.group(3)[1:].split(".")
|
||||
vlist2 = match2.group(3)[1:].split(".")
|
||||
for i in range(0, max(len(vlist1), len(vlist2))):
|
||||
# Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
|
||||
# would be ambiguous if two versions that aren't literally equal
|
||||
# are given the same value (in sorting, for example).
|
||||
if len(vlist1) <= i or len(vlist1[i]) == 0:
|
||||
list1.append(-1)
|
||||
list2.append(int(vlist2[i]))
|
||||
elif len(vlist2) <= i or len(vlist2[i]) == 0:
|
||||
list1.append(int(vlist1[i]))
|
||||
list2.append(-1)
|
||||
# Let's make life easy and use integers unless we're forced to use floats
|
||||
elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"):
|
||||
list1.append(int(vlist1[i]))
|
||||
list2.append(int(vlist2[i]))
|
||||
# now we have to use floats so 1.02 compares correctly against 1.1
|
||||
else:
|
||||
list1.append(float("0."+vlist1[i]))
|
||||
list2.append(float("0."+vlist2[i]))
|
||||
|
||||
# and now the final letter
|
||||
if len(match1.group(5)):
|
||||
list1.append(ord(match1.group(5)))
|
||||
if len(match2.group(5)):
|
||||
list2.append(ord(match2.group(5)))
|
||||
|
||||
for i in range(0, max(len(list1), len(list2))):
|
||||
if len(list1) <= i:
|
||||
return -1
|
||||
elif len(list2) <= i:
|
||||
return 1
|
||||
elif list1[i] != list2[i]:
|
||||
return list1[i] - list2[i]
|
||||
|
||||
# main version is equal, so now compare the _suffix part
|
||||
list1 = match1.group(6).split("_")[1:]
|
||||
list2 = match2.group(6).split("_")[1:]
|
||||
|
||||
for i in range(0, max(len(list1), len(list2))):
|
||||
if len(list1) <= i:
|
||||
s1 = ("p", "0")
|
||||
else:
|
||||
s1 = suffix_regexp.match(list1[i]).groups()
|
||||
if len(list2) <= i:
|
||||
s2 = ("p", "0")
|
||||
else:
|
||||
s2 = suffix_regexp.match(list2[i]).groups()
|
||||
if s1[0] != s2[0]:
|
||||
return suffix_value[s1[0]] - suffix_value[s2[0]]
|
||||
if s1[1] != s2[1]:
|
||||
# it's possible that the s(1|2)[1] == ''
|
||||
# in such a case, fudge it.
|
||||
try:
|
||||
r1 = int(s1[1])
|
||||
except ValueError:
|
||||
r1 = 0
|
||||
try:
|
||||
r2 = int(s2[1])
|
||||
except ValueError:
|
||||
r2 = 0
|
||||
return r1 - r2
|
||||
|
||||
# the suffix part is equal to, so finally check the revision
|
||||
if match1.group(10):
|
||||
r1 = int(match1.group(10))
|
||||
else:
|
||||
r1 = 0
|
||||
if match2.group(10):
|
||||
r2 = int(match2.group(10))
|
||||
else:
|
||||
r2 = 0
|
||||
return r1 - r2
|
||||
|
||||
tag_regexp = re.compile("^([A-Za-z0-9+_.-]+)?$")
|
||||
def is_valid_package_tag(tag):
|
||||
"""
|
||||
Return whether string is a valid package tag.
|
||||
|
||||
@param tag: package tag to test
|
||||
@type tag: string
|
||||
@return: True, if valid
|
||||
@rtype: bool
|
||||
"""
|
||||
match = tag_regexp.match(tag)
|
||||
if not match:
|
||||
return False
|
||||
if not match.groups():
|
||||
return False
|
||||
return True
|
||||
|
||||
def entropy_compare_package_tags(tag_a, tag_b):
|
||||
"""
|
||||
Compare two Entropy package tags using builtin cmp().
|
||||
|
||||
@param tag_a: Entropy package tag
|
||||
@type tag_a: string
|
||||
@param tag_b: Entropy package tag
|
||||
@type tag_b: string
|
||||
return: negative number if tag_a < tag_b, positive number if tag_a > tag_b.
|
||||
zero if tag_a == tag_b.
|
||||
rtype: int
|
||||
"""
|
||||
return const_cmp(tag_a, tag_b)
|
||||
|
||||
def sort_entropy_package_tags(tags):
|
||||
"""
|
||||
Return a sorted list of Entropy package tags.
|
||||
|
||||
@param tags: list of Entropy package tags
|
||||
@type tags: list
|
||||
@return: sorted list of Entropy package tags
|
||||
@rtype: list
|
||||
"""
|
||||
return sorted(tags)
|
||||
|
||||
def entropy_compare_versions(ver_data, ver_data2):
|
||||
"""
|
||||
@description: compare two lists composed by
|
||||
[version,tag,revision] and [version,tag,revision]
|
||||
if ver_data > ver_data2 --> positive number
|
||||
if ver_data == ver_data2 --> 0
|
||||
if ver_data < ver_data2 --> negative number
|
||||
@input package: ver_data[version,tag,rev] and ver_data2[version,tag,rev]
|
||||
@output: integer number
|
||||
"""
|
||||
a_ver, a_tag, a_rev = ver_data
|
||||
b_ver, b_tag, b_rev = ver_data2
|
||||
|
||||
# if both are tagged, check tag first
|
||||
rc = 0
|
||||
if a_tag and b_tag:
|
||||
rc = const_cmp(a_tag, b_tag)
|
||||
if rc == 0:
|
||||
rc = compare_versions(a_ver, b_ver)
|
||||
|
||||
if rc == 0:
|
||||
# check tag
|
||||
tag_cmp = entropy_compare_package_tags(a_tag, b_tag)
|
||||
if tag_cmp < 0:
|
||||
return -1
|
||||
elif tag_cmp > 0:
|
||||
return 1
|
||||
else:
|
||||
# check rev
|
||||
if a_rev > b_rev:
|
||||
return 1
|
||||
elif a_rev < b_rev:
|
||||
return -1
|
||||
return 0
|
||||
|
||||
return rc
|
||||
|
||||
def get_newer_version(versions):
|
||||
"""
|
||||
Return a sorted list of versions
|
||||
|
||||
@param versions: input version list
|
||||
@type versions: list
|
||||
@return: sorted version list
|
||||
@rtype: list
|
||||
"""
|
||||
return _generic_sorter(versions, compare_versions)
|
||||
|
||||
def get_entropy_newer_version(versions):
|
||||
"""
|
||||
Sort a list of entropy package versions.
|
||||
|
||||
@param versions: list of package versions
|
||||
@type versions: list
|
||||
@return: sorted list
|
||||
@rtype: list
|
||||
"""
|
||||
return _generic_sorter(versions, entropy_compare_versions)
|
||||
@@ -41,6 +41,7 @@ from entropy.security import Repository as RepositorySecurity
|
||||
from entropy.db.exceptions import ProgrammingError
|
||||
from entropy.client.interfaces import Client as _Client
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
import entropy.dump
|
||||
|
||||
@@ -3252,7 +3253,7 @@ class ServerQAMixin:
|
||||
count = (count, length),
|
||||
header = darkred(" @@ ")
|
||||
)
|
||||
key, slot = (entropy.tools.dep_getkey(installed_package),
|
||||
key, slot = (entropy.dep.dep_getkey(installed_package),
|
||||
self.Spm().get_installed_package_metadata(installed_package,
|
||||
"SLOT"),)
|
||||
pkg_atom = "%s%s%s" % (key, ":", slot,)
|
||||
@@ -3502,7 +3503,7 @@ class ServerQAMixin:
|
||||
)
|
||||
|
||||
pkgstring_list = sorted(["%s%s%s" % (
|
||||
entropy.tools.dep_getkey(x[0]), etpConst['entropyslotprefix'],
|
||||
entropy.dep.dep_getkey(x[0]), etpConst['entropyslotprefix'],
|
||||
x[1],) for x in sorted(packages)])
|
||||
if pkg_list_path is not None:
|
||||
with open(pkg_list_path, "w") as pkg_f:
|
||||
@@ -4064,10 +4065,10 @@ class ServerRepositoryMixin:
|
||||
if not restricted_pkgs:
|
||||
return False
|
||||
|
||||
pkg_key = entropy.tools.dep_getkey(pkg_atom)
|
||||
pkg_key = entropy.dep.dep_getkey(pkg_atom)
|
||||
for r_dep in restricted_pkgs:
|
||||
r_key, r_slot = entropy.tools.dep_getkey(r_dep), \
|
||||
entropy.tools.dep_getslot(r_dep)
|
||||
r_key, r_slot = entropy.dep.dep_getkey(r_dep), \
|
||||
entropy.dep.dep_getslot(r_dep)
|
||||
if r_slot is None:
|
||||
r_slot = pkg_slot
|
||||
|
||||
@@ -4677,15 +4678,15 @@ class ServerMiscMixin:
|
||||
|
||||
dorm = False
|
||||
atom = dbconn.retrieveAtom(idpackage)
|
||||
atomkey = entropy.tools.dep_getkey(atom)
|
||||
atomtag = entropy.tools.dep_gettag(atom)
|
||||
atomkey = entropy.dep.dep_getkey(atom)
|
||||
atomtag = entropy.dep.dep_gettag(atom)
|
||||
atomslot = dbconn.retrieveSlot(idpackage)
|
||||
|
||||
add = True
|
||||
for spm_atom, spm_counter in to_be_added:
|
||||
addslot = self.Spm().get_installed_package_metadata(
|
||||
spm_atom, "SLOT")
|
||||
addkey = entropy.tools.dep_getkey(spm_atom)
|
||||
addkey = entropy.dep.dep_getkey(spm_atom)
|
||||
# workaround for ebuilds not having slot
|
||||
if addslot is None:
|
||||
addslot = '0'
|
||||
|
||||
@@ -20,6 +20,7 @@ from entropy.i18n import _
|
||||
from entropy.transceivers import EntropyTransceiver
|
||||
from entropy.server.interfaces.rss import ServerRssMetadata
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
def seek_till_newline(f):
|
||||
@@ -301,7 +302,7 @@ class Base:
|
||||
for atom in atoms:
|
||||
|
||||
try:
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
category = key.split("/")[0]
|
||||
except:
|
||||
continue
|
||||
@@ -330,7 +331,7 @@ class Base:
|
||||
package_data = {}
|
||||
for package in packages:
|
||||
try:
|
||||
key = entropy.tools.dep_getkey(package)
|
||||
key = entropy.dep.dep_getkey(package)
|
||||
category = key.split("/")[0]
|
||||
except:
|
||||
continue
|
||||
@@ -351,7 +352,7 @@ class Base:
|
||||
package_data = {}
|
||||
for package in packages:
|
||||
try:
|
||||
key = entropy.tools.dep_getkey(package)
|
||||
key = entropy.dep.dep_getkey(package)
|
||||
category = key.split("/")[0]
|
||||
except:
|
||||
continue
|
||||
@@ -1211,7 +1212,7 @@ class Base:
|
||||
def _get_spm_pkginfo(self, matched_atom, from_installed = False):
|
||||
data = {}
|
||||
data['atom'] = matched_atom
|
||||
data['key'] = entropy.tools.dep_getkey(matched_atom)
|
||||
data['key'] = entropy.dep.dep_getkey(matched_atom)
|
||||
spm = self.SystemManagerExecutor.SystemInterface.Entropy.Spm()
|
||||
try:
|
||||
if from_installed:
|
||||
|
||||
@@ -31,6 +31,7 @@ from entropy.i18n import _
|
||||
from entropy.core.settings.base import SystemSettings
|
||||
from entropy.misc import LogFile
|
||||
from entropy.spm.plugins.skel import SpmPlugin
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
from entropy.spm.plugins.interfaces.portage_plugin import xpak
|
||||
from entropy.spm.plugins.interfaces.portage_plugin import xpaktools
|
||||
@@ -769,7 +770,7 @@ class PortagePlugin(SpmPlugin):
|
||||
if kern_vermagic is None:
|
||||
continue
|
||||
|
||||
if not entropy.tools.is_valid_package_tag(kern_vermagic):
|
||||
if not entropy.dep.is_valid_package_tag(kern_vermagic):
|
||||
# argh! wtf, this is invalid!
|
||||
continue
|
||||
|
||||
@@ -784,7 +785,7 @@ class PortagePlugin(SpmPlugin):
|
||||
owner_data = None
|
||||
k_atom = None
|
||||
for k_atom, k_slot in owners:
|
||||
k_cat, k_name, k_ver, k_rev = entropy.tools.catpkgsplit(k_atom)
|
||||
k_cat, k_name, k_ver, k_rev = entropy.dep.catpkgsplit(k_atom)
|
||||
if k_cat == PortagePlugin.KERNEL_CATEGORY:
|
||||
owner_data = (k_cat, k_name, k_ver, k_rev,)
|
||||
break
|
||||
@@ -913,7 +914,7 @@ class PortagePlugin(SpmPlugin):
|
||||
|
||||
# workout pf
|
||||
pf_atom = os.path.join(data['category'], data['pf'])
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.tools.catpkgsplit(
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.dep.catpkgsplit(
|
||||
pf_atom)
|
||||
if pkgrev != "r0":
|
||||
pkgver += "-%s" % (pkgrev,)
|
||||
@@ -1124,7 +1125,7 @@ class PortagePlugin(SpmPlugin):
|
||||
|
||||
# write only if it's a systempackage
|
||||
data['systempackage'] = False
|
||||
system_packages = [entropy.tools.dep_getkey(x) for x in \
|
||||
system_packages = [entropy.dep.dep_getkey(x) for x in \
|
||||
self.get_system_packages()]
|
||||
if data['category'] + "/" + data['name'] in system_packages:
|
||||
data['systempackage'] = True
|
||||
@@ -1223,7 +1224,7 @@ class PortagePlugin(SpmPlugin):
|
||||
matched_slot = self.get_package_metadata(matched_atom, "SLOT")
|
||||
try:
|
||||
inst_key = "%s%s%s" % (
|
||||
entropy.tools.dep_getkey(package),
|
||||
entropy.dep.dep_getkey(package),
|
||||
etpConst['entropyslotprefix'],
|
||||
matched_slot,
|
||||
)
|
||||
@@ -1568,8 +1569,8 @@ class PortagePlugin(SpmPlugin):
|
||||
"""
|
||||
Reimplemented from SpmPlugin class.
|
||||
"""
|
||||
spm_name = entropy.tools.remove_tag(entropy_package_name)
|
||||
spm_name = entropy.tools.remove_entropy_revision(spm_name)
|
||||
spm_name = entropy.dep.remove_tag(entropy_package_name)
|
||||
spm_name = entropy.dep.remove_entropy_revision(spm_name)
|
||||
return spm_name
|
||||
|
||||
def assign_uid_to_installed_package(self, package, root = None):
|
||||
@@ -2216,7 +2217,7 @@ class PortagePlugin(SpmPlugin):
|
||||
if mymatch[0] == -1:
|
||||
continue
|
||||
myatom = repo_db.retrieveAtom(mymatch[0])
|
||||
myatom = entropy.tools.remove_tag(myatom)
|
||||
myatom = entropy.dep.remove_tag(myatom)
|
||||
runatoms.add(myatom)
|
||||
|
||||
for myatom in runatoms:
|
||||
@@ -2611,7 +2612,7 @@ class PortagePlugin(SpmPlugin):
|
||||
"""
|
||||
atomsfound = set()
|
||||
spm_package = PortagePlugin._pkg_compose_atom(package_metadata)
|
||||
key = entropy.tools.dep_getkey(spm_package)
|
||||
key = entropy.dep.dep_getkey(spm_package)
|
||||
category = key.split("/")[0]
|
||||
|
||||
build = self.get_installed_package_build_script_path(spm_package)
|
||||
@@ -2624,7 +2625,7 @@ class PortagePlugin(SpmPlugin):
|
||||
os.listdir(cat_dir)]
|
||||
# filter by key
|
||||
real_findings = [x for x in my_findings if \
|
||||
key == entropy.tools.dep_getkey(x)]
|
||||
key == entropy.dep.dep_getkey(x)]
|
||||
atomsfound.update(real_findings)
|
||||
|
||||
myslot = package_metadata['slot']
|
||||
@@ -2780,10 +2781,10 @@ class PortagePlugin(SpmPlugin):
|
||||
"""
|
||||
Reimplemented from SpmPlugin class.
|
||||
"""
|
||||
atom = entropy.tools.remove_tag(package_metadata['removeatom'])
|
||||
atom = entropy.dep.remove_tag(package_metadata['removeatom'])
|
||||
remove_build = self.get_installed_package_build_script_path(atom)
|
||||
remove_path = os.path.dirname(remove_build)
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
|
||||
with self._PortageVdbLocker(self):
|
||||
|
||||
@@ -3673,22 +3674,22 @@ class PortagePlugin(SpmPlugin):
|
||||
|
||||
for raw_dependency in dependencies:
|
||||
|
||||
split_deps = entropy.tools.dep_split_or_deps(raw_dependency)
|
||||
split_deps = entropy.dep.dep_split_or_deps(raw_dependency)
|
||||
filtered_deps = []
|
||||
for depstring in split_deps:
|
||||
|
||||
use_deps = entropy.tools.dep_getusedeps(depstring)
|
||||
use_deps = entropy.dep.dep_getusedeps(depstring)
|
||||
if use_deps:
|
||||
|
||||
new_use_deps = filter_use_deps(depstring)
|
||||
|
||||
if new_use_deps:
|
||||
depstring = "%s[%s]" % (
|
||||
entropy.tools.remove_usedeps(depstring),
|
||||
entropy.dep.remove_usedeps(depstring),
|
||||
','.join(new_use_deps),
|
||||
)
|
||||
else:
|
||||
depstring = entropy.tools.remove_usedeps(depstring)
|
||||
depstring = entropy.dep.remove_usedeps(depstring)
|
||||
|
||||
filtered_deps.append(depstring)
|
||||
|
||||
@@ -4235,7 +4236,7 @@ responsible in any way.
|
||||
tag = tags[-1]
|
||||
tag = tag.split("=")[-1].strip('"').strip("'").strip()
|
||||
|
||||
if not entropy.tools.is_valid_package_tag(tag):
|
||||
if not entropy.dep.is_valid_package_tag(tag):
|
||||
# invalid
|
||||
mytxt = "%s: %s: %s" % (
|
||||
bold(_("QA")),
|
||||
|
||||
+102
-656
@@ -30,7 +30,7 @@ import traceback
|
||||
from entropy.output import print_generic
|
||||
from entropy.const import etpConst, const_kill_threads, const_islive, \
|
||||
const_isunicode, const_convert_to_unicode, const_convert_to_rawstring, \
|
||||
const_cmp, const_israwstring, const_cmp
|
||||
const_israwstring
|
||||
from entropy.exceptions import FileNotFound, InvalidAtom, DirectoryNotFound
|
||||
|
||||
def is_root():
|
||||
@@ -1390,711 +1390,157 @@ def generic_file_content_parser(filepath, comment_tag = "#",
|
||||
data.append(line)
|
||||
return data
|
||||
|
||||
# Imported from Gentoo portage_dep.py
|
||||
# Copyright 1999-2010 Gentoo Foundation
|
||||
|
||||
# 2.1.1 A category name may contain any of the characters [A-Za-z0-9+_.-].
|
||||
# It must not begin with a hyphen or a dot.
|
||||
_cat = r'[\w+][\w+.-]*'
|
||||
|
||||
# 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-].
|
||||
# It must not begin with a hyphen,
|
||||
# and must not end in a hyphen followed by one or more digits.
|
||||
_pkg = r'[\w+][\w+-]*?'
|
||||
|
||||
_v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)'
|
||||
_rev = r'\d+'
|
||||
_vr = _v + '(-r(' + _rev + '))?'
|
||||
|
||||
_cp = '(' + _cat + '/' + _pkg + '(-' + _vr + ')?)'
|
||||
_cpv = '(' + _cp + '-' + _vr + ')'
|
||||
_pv = '(?P<pn>' + _pkg + '(?P<pn_inval>-' + _vr + ')?)' + '-(?P<ver>' + _v + ')(-r(?P<rev>' + _rev + '))?'
|
||||
|
||||
ver_regexp = re.compile("^" + _vr + "$")
|
||||
suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
|
||||
suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
|
||||
endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
|
||||
|
||||
valid_category = re.compile("^\w[\w-]*")
|
||||
invalid_atom_chars_regexp = re.compile("[()|@]")
|
||||
|
||||
def _ververify(myver):
|
||||
if myver.endswith("*"):
|
||||
m = ver_regexp.match(myver[:-1])
|
||||
else:
|
||||
m = ver_regexp.match(myver)
|
||||
if m:
|
||||
return True
|
||||
return False
|
||||
import entropy.dep
|
||||
|
||||
def isjustname(mypkg):
|
||||
"""
|
||||
Checks to see if the depstring is only the package name (no version parts)
|
||||
|
||||
Example usage:
|
||||
>>> isjustname('media-libs/test-3.0')
|
||||
False
|
||||
>>> isjustname('test')
|
||||
True
|
||||
>>> isjustname('media-libs/test')
|
||||
True
|
||||
|
||||
@param mypkg: the package atom to check
|
||||
@param mypkg: string
|
||||
@rtype: int
|
||||
@return: if the package string is not just the package name
|
||||
"""
|
||||
for chunk in mypkg.split('-')[-2:]:
|
||||
if _ververify(chunk):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _isspecific(mypkg):
|
||||
"""
|
||||
Checks to see if a package is in category/package-version or package-version format,
|
||||
possibly returning a cached result.
|
||||
|
||||
Example usage:
|
||||
>>> _isspecific('media-libs/test')
|
||||
False
|
||||
>>> _isspecific('media-libs/test-3.0')
|
||||
True
|
||||
|
||||
@param mypkg: the package depstring to check against
|
||||
@type mypkg: string
|
||||
@rtype: int
|
||||
@return: One of the following:
|
||||
1) False if the package string is not specific
|
||||
2) True if it is
|
||||
"""
|
||||
mysplit = mypkg.split("/")
|
||||
if not isjustname(mysplit[-1]):
|
||||
return True
|
||||
return False
|
||||
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.isjustname(mypkg)
|
||||
|
||||
def catpkgsplit(mydata):
|
||||
"""
|
||||
Takes a Category/Package-Version-Rev and returns a list of each.
|
||||
|
||||
@param mydata: data to split
|
||||
@type mydata: string
|
||||
@rype: tuple
|
||||
@return:
|
||||
1. If each exists, it returns (cat, pkgname, version, rev)
|
||||
2. If cat is not specificed in mydata, cat will be "null"
|
||||
3. if rev does not exist it will be '-r0'
|
||||
"""
|
||||
|
||||
# Categories may contain a-zA-z0-9+_- but cannot start with -
|
||||
mysplit = mydata.split("/")
|
||||
p_split = None
|
||||
if len(mysplit) == 1:
|
||||
retval = ("null",)
|
||||
p_split = _pkgsplit(mydata)
|
||||
elif len(mysplit) == 2:
|
||||
retval = (mysplit[0],)
|
||||
p_split = _pkgsplit(mysplit[1])
|
||||
if not p_split:
|
||||
return None
|
||||
retval += p_split
|
||||
return retval
|
||||
|
||||
_pv_re = re.compile('^' + _pv + '$', re.VERBOSE)
|
||||
def _pkgsplit(mypkg):
|
||||
"""
|
||||
@param mypkg: pv
|
||||
@return:
|
||||
1. None if input is invalid.
|
||||
2. (pn, ver, rev) if input is pv
|
||||
"""
|
||||
m = _pv_re.match(mypkg)
|
||||
if m is None:
|
||||
return None
|
||||
|
||||
if m.group('pn_inval') is not None:
|
||||
# package name appears to have a version-like suffix
|
||||
return None
|
||||
|
||||
rev = m.group('rev')
|
||||
if rev is None:
|
||||
rev = '0'
|
||||
rev = 'r' + rev
|
||||
|
||||
return (m.group('pn'), m.group('ver'), rev)
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.catpkgsplit(mydata)
|
||||
|
||||
def dep_getkey(mydep):
|
||||
"""
|
||||
Return the category/package-name of a depstring.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getkey('media-libs/test-3.0')
|
||||
'media-libs/test'
|
||||
|
||||
@param mydep: the depstring to retrieve the category/package-name of
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the package category/package-version
|
||||
"""
|
||||
if not mydep:
|
||||
return mydep
|
||||
mydep = remove_tag(mydep)
|
||||
mydep = remove_usedeps(mydep)
|
||||
|
||||
mydep = dep_getcpv(mydep)
|
||||
if mydep and _isspecific(mydep):
|
||||
mysplit = catpkgsplit(mydep)
|
||||
if not mysplit:
|
||||
return mydep
|
||||
return mysplit[0] + "/" + mysplit[1]
|
||||
|
||||
return mydep
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_getkey(mydep)
|
||||
|
||||
def dep_getcat(mydep):
|
||||
"""
|
||||
Extract package category from dependency.
|
||||
"""
|
||||
return dep_getkey(mydep).split("/")[0]
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_getcat(mydep)
|
||||
|
||||
def dep_getcpv(mydep):
|
||||
"""
|
||||
Return the category-package-version with any operators/slot specifications stripped off
|
||||
|
||||
Example usage:
|
||||
>>> dep_getcpv('>=media-libs/test-3.0')
|
||||
'media-libs/test-3.0'
|
||||
|
||||
@param mydep: the depstring
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the depstring with the operator removed
|
||||
"""
|
||||
if mydep and mydep[0] == "*":
|
||||
mydep = mydep[1:]
|
||||
if mydep and mydep[-1] == "*":
|
||||
mydep = mydep[:-1]
|
||||
if mydep and mydep[0] == "!":
|
||||
mydep = mydep[1:]
|
||||
if mydep[:2] in [">=", "<="]:
|
||||
mydep = mydep[2:]
|
||||
elif mydep[:1] in "=<>~":
|
||||
mydep = mydep[1:]
|
||||
colon = mydep.rfind(":")
|
||||
if colon != -1:
|
||||
mydep = mydep[:colon]
|
||||
|
||||
return mydep
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_getcpv(mydep)
|
||||
|
||||
def dep_getslot(mydep):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
|
||||
Retrieve the slot on a depend.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getslot('app-misc/test:3')
|
||||
'3'
|
||||
|
||||
@param mydep: the depstring to retrieve the slot of
|
||||
@type mydep: string
|
||||
@rtype: string
|
||||
@return: the slot
|
||||
"""
|
||||
colon = mydep.find(":")
|
||||
if colon != -1:
|
||||
bracket = mydep.find("[", colon)
|
||||
if bracket == -1:
|
||||
return mydep[colon+1:]
|
||||
else:
|
||||
return mydep[colon+1:bracket]
|
||||
return None
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_getslot(mydep)
|
||||
|
||||
def dep_getusedeps(depend):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
|
||||
Pull a listing of USE Dependencies out of a dep atom.
|
||||
|
||||
Example usage:
|
||||
>>> dep_getusedeps('app-misc/test:3[foo,-bar]')
|
||||
('foo', '-bar')
|
||||
|
||||
@param depend: The depstring to process
|
||||
@type depend: String
|
||||
@rtype: List
|
||||
@return: List of use flags ( or [] if no flags exist )
|
||||
"""
|
||||
use_list = []
|
||||
open_bracket = depend.find('[')
|
||||
# -1 = failure (think c++ string::npos)
|
||||
comma_separated = False
|
||||
bracket_count = 0
|
||||
while( open_bracket != -1 ):
|
||||
bracket_count += 1
|
||||
if bracket_count > 1:
|
||||
InvalidAtom("USE Dependency with more " + \
|
||||
"than one set of brackets: %s" % (depend,))
|
||||
close_bracket = depend.find(']', open_bracket )
|
||||
if close_bracket == -1:
|
||||
InvalidAtom("USE Dependency with no closing bracket: %s" % depend )
|
||||
use = depend[open_bracket + 1: close_bracket]
|
||||
# foo[1:1] may return '' instead of None, we don't want '' in the result
|
||||
if not use:
|
||||
InvalidAtom("USE Dependency with " + \
|
||||
"no use flag ([]): %s" % depend )
|
||||
if not comma_separated:
|
||||
comma_separated = "," in use
|
||||
|
||||
if comma_separated and bracket_count > 1:
|
||||
InvalidAtom("USE Dependency contains a mixture of " + \
|
||||
"comma and bracket separators: %s" % depend )
|
||||
|
||||
if comma_separated:
|
||||
for x in use.split(","):
|
||||
if x:
|
||||
use_list.append(x)
|
||||
else:
|
||||
InvalidAtom("USE Dependency with no use " + \
|
||||
"flag next to comma: %s" % depend )
|
||||
else:
|
||||
use_list.append(use)
|
||||
|
||||
# Find next use flag
|
||||
open_bracket = depend.find( '[', open_bracket+1 )
|
||||
|
||||
return tuple(use_list)
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_getusedeps(depend)
|
||||
|
||||
def remove_usedeps(depend):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param depend:
|
||||
@type depend:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
new_depend = ""
|
||||
skip = 0
|
||||
for char in depend:
|
||||
if char == "[":
|
||||
skip += 1
|
||||
elif char == "]":
|
||||
skip -= 1
|
||||
continue
|
||||
if skip == 0:
|
||||
new_depend += char
|
||||
|
||||
return new_depend
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_usedeps(depend)
|
||||
|
||||
def remove_slot(mydep):
|
||||
"""
|
||||
# Imported from portage.dep
|
||||
# $Id: dep.py 11281 2008-07-30 06:12:19Z zmedico $
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_slot(mydep)
|
||||
|
||||
Removes dep components from the right side of an atom:
|
||||
* slot
|
||||
* use
|
||||
* repo
|
||||
"""
|
||||
colon = mydep.find(":")
|
||||
if colon != -1:
|
||||
mydep = mydep[:colon]
|
||||
else:
|
||||
bracket = mydep.find("[")
|
||||
if bracket != -1:
|
||||
mydep = mydep[:bracket]
|
||||
return mydep
|
||||
|
||||
# input must be a valid package version or a full atom
|
||||
def remove_revision(ver):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param ver:
|
||||
@type ver:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
myver = ver.split("-")
|
||||
if myver[-1][0] == "r":
|
||||
return '-'.join(myver[:-1])
|
||||
return ver
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_revision(ver)
|
||||
|
||||
def remove_tag(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
colon = mydep.rfind(etpConst['entropytagprefix'])
|
||||
if colon == -1:
|
||||
return mydep
|
||||
return mydep[:colon]
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_tag(mydep)
|
||||
|
||||
def remove_entropy_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
dep = remove_package_operators(mydep)
|
||||
operators = mydep[:-len(dep)]
|
||||
colon = dep.rfind("~")
|
||||
if colon == -1:
|
||||
return mydep
|
||||
return operators+dep[:colon]
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_entropy_revision(mydep)
|
||||
|
||||
def dep_get_entropy_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
#dep = remove_package_operators(mydep)
|
||||
colon = mydep.rfind("~")
|
||||
if colon != -1:
|
||||
myrev = mydep[colon+1:]
|
||||
try:
|
||||
myrev = int(myrev)
|
||||
except ValueError:
|
||||
return None
|
||||
return myrev
|
||||
return None
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_get_entropy_revision(mydep)
|
||||
|
||||
def dep_split_or_deps(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_split_or_deps(mydep)
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
dep = mydep.rstrip(etpConst['entropyordepquestion'])
|
||||
return dep.split(etpConst['entropyordepsep'])
|
||||
|
||||
dep_revmatch = re.compile('^r[0-9]')
|
||||
def dep_get_spm_revision(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
myver = mydep.split("-")
|
||||
myrev = myver[-1]
|
||||
if dep_revmatch.match(myrev):
|
||||
return myrev
|
||||
else:
|
||||
return "r0"
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_get_spm_revision(mydep)
|
||||
|
||||
def dep_get_match_in_repos(mydep):
|
||||
"""
|
||||
docstring_title
|
||||
|
||||
@param mydep:
|
||||
@type mydep:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
colon = mydep.rfind("@")
|
||||
if colon != -1:
|
||||
mydata = mydep[colon+1:]
|
||||
mydata = mydata.split(",")
|
||||
if not mydata:
|
||||
mydata = None
|
||||
return mydep[:colon], mydata
|
||||
else:
|
||||
return mydep, None
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_get_match_in_repos(mydep)
|
||||
|
||||
def dep_gettag(mydep):
|
||||
|
||||
"""
|
||||
Retrieve the slot on a depend.
|
||||
|
||||
Example usage:
|
||||
>>> dep_gettag('app-misc/test#2.6.23-sabayon-r1')
|
||||
'2.6.23-sabayon-r1'
|
||||
|
||||
"""
|
||||
dep = mydep[:]
|
||||
dep = remove_entropy_revision(dep)
|
||||
colon = dep.rfind(etpConst['entropytagprefix'])
|
||||
if colon != -1:
|
||||
mydep = dep[colon+1:]
|
||||
rslt = remove_slot(mydep)
|
||||
return rslt
|
||||
return None
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.dep_gettag(mydep)
|
||||
|
||||
def remove_package_operators(atom):
|
||||
"""
|
||||
docstring_title
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.remove_package_operators(atom)
|
||||
|
||||
@param atom:
|
||||
@type atom:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
return atom.lstrip("><=~")
|
||||
|
||||
# Version compare function taken from portage_versions.py
|
||||
# portage_versions.py -- core Portage functionality
|
||||
# Copyright 1998-2006 Gentoo Foundation
|
||||
def compare_versions(ver1, ver2):
|
||||
"""
|
||||
docstring_title
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.compare_versions(ver1, ver2)
|
||||
|
||||
@param ver1:
|
||||
@type ver1:
|
||||
@param ver2:
|
||||
@type ver2:
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
if ver1 == ver2:
|
||||
return 0
|
||||
#mykey=ver1+":"+ver2
|
||||
match1 = None
|
||||
match2 = None
|
||||
if ver1:
|
||||
match1 = ver_regexp.match(ver1)
|
||||
if ver2:
|
||||
match2 = ver_regexp.match(ver2)
|
||||
|
||||
# checking that the versions are valid
|
||||
invalid = False
|
||||
invalid_rc = 0
|
||||
if not match1:
|
||||
invalid = True
|
||||
elif not match1.groups():
|
||||
invalid = True
|
||||
elif not match2:
|
||||
invalid_rc = 1
|
||||
invalid = True
|
||||
elif not match2.groups():
|
||||
invalid_rc = 1
|
||||
invalid = True
|
||||
if invalid:
|
||||
return invalid_rc
|
||||
|
||||
# building lists of the version parts before the suffix
|
||||
# first part is simple
|
||||
list1 = [int(match1.group(2))]
|
||||
list2 = [int(match2.group(2))]
|
||||
|
||||
# this part would greatly benefit from a fixed-length version pattern
|
||||
if len(match1.group(3)) or len(match2.group(3)):
|
||||
vlist1 = match1.group(3)[1:].split(".")
|
||||
vlist2 = match2.group(3)[1:].split(".")
|
||||
for i in range(0, max(len(vlist1), len(vlist2))):
|
||||
# Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
|
||||
# would be ambiguous if two versions that aren't literally equal
|
||||
# are given the same value (in sorting, for example).
|
||||
if len(vlist1) <= i or len(vlist1[i]) == 0:
|
||||
list1.append(-1)
|
||||
list2.append(int(vlist2[i]))
|
||||
elif len(vlist2) <= i or len(vlist2[i]) == 0:
|
||||
list1.append(int(vlist1[i]))
|
||||
list2.append(-1)
|
||||
# Let's make life easy and use integers unless we're forced to use floats
|
||||
elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"):
|
||||
list1.append(int(vlist1[i]))
|
||||
list2.append(int(vlist2[i]))
|
||||
# now we have to use floats so 1.02 compares correctly against 1.1
|
||||
else:
|
||||
list1.append(float("0."+vlist1[i]))
|
||||
list2.append(float("0."+vlist2[i]))
|
||||
|
||||
# and now the final letter
|
||||
if len(match1.group(5)):
|
||||
list1.append(ord(match1.group(5)))
|
||||
if len(match2.group(5)):
|
||||
list2.append(ord(match2.group(5)))
|
||||
|
||||
for i in range(0, max(len(list1), len(list2))):
|
||||
if len(list1) <= i:
|
||||
return -1
|
||||
elif len(list2) <= i:
|
||||
return 1
|
||||
elif list1[i] != list2[i]:
|
||||
return list1[i] - list2[i]
|
||||
|
||||
# main version is equal, so now compare the _suffix part
|
||||
list1 = match1.group(6).split("_")[1:]
|
||||
list2 = match2.group(6).split("_")[1:]
|
||||
|
||||
for i in range(0, max(len(list1), len(list2))):
|
||||
if len(list1) <= i:
|
||||
s1 = ("p", "0")
|
||||
else:
|
||||
s1 = suffix_regexp.match(list1[i]).groups()
|
||||
if len(list2) <= i:
|
||||
s2 = ("p", "0")
|
||||
else:
|
||||
s2 = suffix_regexp.match(list2[i]).groups()
|
||||
if s1[0] != s2[0]:
|
||||
return suffix_value[s1[0]] - suffix_value[s2[0]]
|
||||
if s1[1] != s2[1]:
|
||||
# it's possible that the s(1|2)[1] == ''
|
||||
# in such a case, fudge it.
|
||||
try:
|
||||
r1 = int(s1[1])
|
||||
except ValueError:
|
||||
r1 = 0
|
||||
try:
|
||||
r2 = int(s2[1])
|
||||
except ValueError:
|
||||
r2 = 0
|
||||
return r1 - r2
|
||||
|
||||
# the suffix part is equal to, so finally check the revision
|
||||
if match1.group(10):
|
||||
r1 = int(match1.group(10))
|
||||
else:
|
||||
r1 = 0
|
||||
if match2.group(10):
|
||||
r2 = int(match2.group(10))
|
||||
else:
|
||||
r2 = 0
|
||||
return r1 - r2
|
||||
|
||||
tag_regexp = re.compile("^([A-Za-z0-9+_.-]+)?$")
|
||||
def is_valid_package_tag(tag):
|
||||
"""
|
||||
Return whether string is a valid package tag.
|
||||
|
||||
@param tag: package tag to test
|
||||
@type tag: string
|
||||
@return: True, if valid
|
||||
@rtype: bool
|
||||
"""
|
||||
match = tag_regexp.match(tag)
|
||||
if not match:
|
||||
return False
|
||||
if not match.groups():
|
||||
return False
|
||||
return True
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.is_valid_package_tag(tag)
|
||||
|
||||
def entropy_compare_package_tags(tag_a, tag_b):
|
||||
"""
|
||||
Compare two Entropy package tags using builtin cmp().
|
||||
|
||||
@param tag_a: Entropy package tag
|
||||
@type tag_a: string
|
||||
@param tag_b: Entropy package tag
|
||||
@type tag_b: string
|
||||
return: negative number if tag_a < tag_b, positive number if tag_a > tag_b.
|
||||
zero if tag_a == tag_b.
|
||||
rtype: int
|
||||
"""
|
||||
return const_cmp(tag_a, tag_b)
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.entropy_compare_package_tags(tag_a, tag_b)
|
||||
|
||||
def sort_entropy_package_tags(tags):
|
||||
"""
|
||||
Return a sorted list of Entropy package tags.
|
||||
|
||||
@param tags: list of Entropy package tags
|
||||
@type tags: list
|
||||
@return: sorted list of Entropy package tags
|
||||
@rtype: list
|
||||
"""
|
||||
return sorted(tags)
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.sort_entropy_package_tags(tags)
|
||||
|
||||
def entropy_compare_versions(ver_data, ver_data2):
|
||||
"""
|
||||
@description: compare two lists composed by
|
||||
[version,tag,revision] and [version,tag,revision]
|
||||
if ver_data > ver_data2 --> positive number
|
||||
if ver_data == ver_data2 --> 0
|
||||
if ver_data < ver_data2 --> negative number
|
||||
@input package: ver_data[version,tag,rev] and ver_data2[version,tag,rev]
|
||||
@output: integer number
|
||||
"""
|
||||
a_ver, a_tag, a_rev = ver_data
|
||||
b_ver, b_tag, b_rev = ver_data2
|
||||
|
||||
# if both are tagged, check tag first
|
||||
rc = 0
|
||||
if a_tag and b_tag:
|
||||
rc = const_cmp(a_tag, b_tag)
|
||||
if rc == 0:
|
||||
rc = compare_versions(a_ver, b_ver)
|
||||
|
||||
if rc == 0:
|
||||
# check tag
|
||||
tag_cmp = entropy_compare_package_tags(a_tag, b_tag)
|
||||
if tag_cmp < 0:
|
||||
return -1
|
||||
elif tag_cmp > 0:
|
||||
return 1
|
||||
else:
|
||||
# check rev
|
||||
if a_rev > b_rev:
|
||||
return 1
|
||||
elif a_rev < b_rev:
|
||||
return -1
|
||||
return 0
|
||||
|
||||
return rc
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.entropy_compare_versions(ver_data, ver_data2)
|
||||
|
||||
def get_newer_version(versions):
|
||||
"""
|
||||
Return a sorted list of versions
|
||||
|
||||
@param versions: input version list
|
||||
@type versions: list
|
||||
@return: sorted version list
|
||||
@rtype: list
|
||||
"""
|
||||
return _generic_sorter(versions, compare_versions)
|
||||
|
||||
def _generic_sorter(inputlist, cmp_func):
|
||||
|
||||
inputs = inputlist[:]
|
||||
if len(inputs) < 2:
|
||||
return inputs
|
||||
max_idx = len(inputs)
|
||||
|
||||
while True:
|
||||
changed = False
|
||||
for idx in range(max_idx):
|
||||
second_idx = idx+1
|
||||
if second_idx == max_idx:
|
||||
continue
|
||||
str_a = inputs[idx]
|
||||
str_b = inputs[second_idx]
|
||||
if cmp_func(str_a, str_b) < 0:
|
||||
inputs[idx] = str_b
|
||||
inputs[second_idx] = str_a
|
||||
changed = True
|
||||
if not changed:
|
||||
break
|
||||
|
||||
return inputs
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.get_newer_version(versions)
|
||||
|
||||
def get_entropy_newer_version(versions):
|
||||
"""
|
||||
Sort a list of entropy package versions.
|
||||
|
||||
@param versions: list of package versions
|
||||
@type versions: list
|
||||
@return: sorted list
|
||||
@rtype: list
|
||||
"""
|
||||
return _generic_sorter(versions, entropy_compare_versions)
|
||||
"""@deprecated"""
|
||||
import warnings
|
||||
warnings.warn("deprecated, please use entropy.dep module")
|
||||
return entropy.dep.get_entropy_newer_version(versions)
|
||||
|
||||
def isnumber(x):
|
||||
"""
|
||||
|
||||
@@ -13,6 +13,7 @@ from entropy.misc import ParallelTask
|
||||
from entropy.db import EntropyRepository
|
||||
import tests._misc as _misc
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class EntropyRepositoryTest(unittest.TestCase):
|
||||
@@ -479,7 +480,7 @@ class EntropyRepositoryTest(unittest.TestCase):
|
||||
f_match = (1, 0)
|
||||
|
||||
for atom, pkg_id, branch in self.test_db.listAllPackages():
|
||||
pkg_key = entropy.tools.dep_getkey(atom)
|
||||
pkg_key = entropy.dep.dep_getkey(atom)
|
||||
self.assertEqual(f_match, self.test_db.atomMatch(pkg_key))
|
||||
self.assertEqual(f_match, self.test_db.atomMatch(atom))
|
||||
self.assertEqual(f_match, self.test_db.atomMatch("~"+atom))
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, '.')
|
||||
sys.path.insert(0, '../')
|
||||
import unittest
|
||||
from entropy.const import const_convert_to_rawstring, const_convert_to_unicode
|
||||
from entropy.client.interfaces import Client
|
||||
from entropy.output import print_generic
|
||||
import tests._misc as _misc
|
||||
import tempfile
|
||||
import subprocess
|
||||
import shutil
|
||||
import stat
|
||||
import entropy.dep as et
|
||||
|
||||
class DepTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
sys.stdout.write("%s called\n" % (self,))
|
||||
sys.stdout.flush()
|
||||
self.test_pkg = _misc.get_test_entropy_package()
|
||||
self.test_pkg2 = _misc.get_test_entropy_package2()
|
||||
self.test_pkg3 = _misc.get_test_entropy_package3()
|
||||
self.test_pkgs = [self.test_pkg, self.test_pkg2, self.test_pkg3]
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
tearDown is run after each test
|
||||
"""
|
||||
sys.stdout.write("%s ran\n" % (self,))
|
||||
sys.stdout.flush()
|
||||
|
||||
def test_valid_package_tag(self):
|
||||
valid = "ciao"
|
||||
invalids = ["òpl", "hello,hello", "#hello"]
|
||||
self.assert_(et.is_valid_package_tag(valid))
|
||||
for invalid in invalids:
|
||||
self.assert_(not et.is_valid_package_tag(invalid))
|
||||
|
||||
def test_isjustname(self):
|
||||
self.assert_(not et.isjustname("app-foo/foo-1.2.3"))
|
||||
self.assert_(et.isjustname("app-foo/foo"))
|
||||
|
||||
def test_catpkgsplit(self):
|
||||
data = {
|
||||
'app-foo/foo-1.2.3': ("app-foo", "foo", "1.2.3", "r0"),
|
||||
'www-apps/389-foo-1.2.3': ("www-apps", "389-foo", "1.2.3", "r0"),
|
||||
}
|
||||
for atom, split_data in data.items():
|
||||
pkgsplit = et.catpkgsplit(atom)
|
||||
self.assertEqual(split_data, pkgsplit)
|
||||
|
||||
def test_dep_getkey(self):
|
||||
pkg = "app-foo/foo-1.2.3"
|
||||
key = "app-foo/foo"
|
||||
self.assertEqual(key, et.dep_getkey(pkg))
|
||||
|
||||
def test_dep_getcpv(self):
|
||||
pkg = ">=app-foo/foo-1.2.3"
|
||||
cpv = "app-foo/foo-1.2.3"
|
||||
self.assertEqual(cpv, et.dep_getcpv(pkg))
|
||||
|
||||
def test_dep_getslot(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
slot = "2.3.4"
|
||||
self.assertEqual(slot, et.dep_getslot(pkg))
|
||||
|
||||
def test_dep_getusedeps(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4[ciao,come,va]"
|
||||
usedeps = ("ciao", "come", "va")
|
||||
self.assertEqual(usedeps, et.dep_getusedeps(pkg))
|
||||
|
||||
def test_remove_usedeps(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4[ciao,come,va]"
|
||||
result = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
self.assertEqual(result, et.remove_usedeps(pkg))
|
||||
|
||||
def test_remove_slot(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
result = ">=app-foo/foo-1.2.3"
|
||||
self.assertEqual(result, et.remove_slot(pkg))
|
||||
|
||||
def test_remove_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1"
|
||||
result = "app-foo/foo-1.2.3"
|
||||
self.assertEqual(result, et.remove_revision(pkg))
|
||||
|
||||
def test_remove_tag(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo"
|
||||
result = "app-foo/foo-1.2.3-r1"
|
||||
self.assertEqual(result, et.remove_tag(pkg))
|
||||
|
||||
def test_remove_entropy_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = "app-foo/foo-1.2.3-r1#2.2.2-foo"
|
||||
self.assertEqual(result, et.remove_entropy_revision(pkg))
|
||||
|
||||
def test_dep_get_entropy_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = 1
|
||||
self.assertEqual(result, et.dep_get_entropy_revision(pkg))
|
||||
|
||||
def test_dep_get_spm_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1"
|
||||
result = "r1"
|
||||
self.assertEqual(result, et.dep_get_spm_revision(pkg))
|
||||
|
||||
def test_dep_get_match_in_repos(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1@foorepo"
|
||||
result = ("app-foo/foo-1.2.3-r1", ["foorepo"])
|
||||
self.assertEqual(result, et.dep_get_match_in_repos(pkg))
|
||||
|
||||
def test_dep_gettag(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = "2.2.2-foo"
|
||||
self.assertEqual(result, et.dep_gettag(pkg))
|
||||
|
||||
def test_remove_package_operators(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4~1"
|
||||
result = "app-foo/foo-1.2.3:2.3.4~1"
|
||||
self.assertEqual(result, et.remove_package_operators(pkg))
|
||||
|
||||
def test_compare_versions(self):
|
||||
ver_a = ("1.0.0", "1.0.0", 0,)
|
||||
ver_b = ("1.0.1", "1.0.0", 0.10000000000000001,)
|
||||
ver_c = ("1.0.0", "1.0.1", -0.10000000000000001,)
|
||||
|
||||
self.assertEqual(et.compare_versions(ver_a[0], ver_a[1]), ver_a[2])
|
||||
self.assertEqual(et.compare_versions(ver_b[0], ver_b[1]), ver_b[2])
|
||||
self.assertEqual(et.compare_versions(ver_c[0], ver_c[1]), ver_c[2])
|
||||
|
||||
def test_get_newer_version(self):
|
||||
vers = ["1.0", "3.4", "0.5", "999", "9999", "10.0"]
|
||||
out_vers = ['9999', '999', '10.0', '3.4', '1.0', '0.5']
|
||||
self.assertEqual(et.get_newer_version(vers), out_vers)
|
||||
|
||||
def test_get_entropy_newer_version(self):
|
||||
vers = [("1.0", "2222", 1,), ("3.4", "2222", 0,), ("1.0", "2223", 1,),
|
||||
("1.0", "2223", 3,)]
|
||||
out_vers = [('1.0', '2223', 3), ('1.0', '2223', 1),
|
||||
('3.4', '2222', 0), ('1.0', '2222', 1)]
|
||||
self.assertEqual(et.get_entropy_newer_version(vers), out_vers)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if "--debug" in sys.argv:
|
||||
sys.argv.remove("--debug")
|
||||
from entropy.const import etpUi
|
||||
etpUi['debug'] = True
|
||||
unittest.main()
|
||||
et.kill_threads()
|
||||
raise SystemExit(0)
|
||||
+2
-2
@@ -19,12 +19,12 @@ if "--debug" in sys.argv:
|
||||
sys.argv.remove("--debug")
|
||||
etpUi['debug'] = True
|
||||
|
||||
from tests import db, client, server, misc, fetchers, tools, i18n, spm, \
|
||||
from tests import db, client, server, misc, fetchers, tools, dep, i18n, spm, \
|
||||
qa, core, security, const
|
||||
rc = 0
|
||||
|
||||
# Add to the list the module to test
|
||||
mods = [db, client, server, misc, fetchers, tools, i18n, spm, qa, core,
|
||||
mods = [db, client, server, misc, fetchers, tools, dep, i18n, spm, qa, core,
|
||||
security, const]
|
||||
|
||||
tests = []
|
||||
|
||||
@@ -112,15 +112,6 @@ class ToolsTest(unittest.TestCase):
|
||||
self.assert_(et.is_valid_ascii(valid))
|
||||
self.assert_(not et.is_valid_ascii(non_valid))
|
||||
|
||||
|
||||
def test_valid_package_tag(self):
|
||||
valid = "ciao"
|
||||
invalids = ["òpl", "hello,hello", "#hello"]
|
||||
self.assert_(et.is_valid_package_tag(valid))
|
||||
for invalid in invalids:
|
||||
self.assert_(not et.is_valid_package_tag(invalid))
|
||||
|
||||
|
||||
def test_is_valid_unicode(self):
|
||||
valid = "ciao"
|
||||
valid2 = const_convert_to_unicode("òèàò", 'utf-8')
|
||||
@@ -405,110 +396,6 @@ class ToolsTest(unittest.TestCase):
|
||||
out_str = et.md5string(mystring)
|
||||
self.assertEqual(out_str, "6e6bc4e49dd477ebc98ef4046c067b5f")
|
||||
|
||||
def test_isjustname(self):
|
||||
self.assert_(not et.isjustname("app-foo/foo-1.2.3"))
|
||||
self.assert_(et.isjustname("app-foo/foo"))
|
||||
|
||||
def test_catpkgsplit(self):
|
||||
data = {
|
||||
'app-foo/foo-1.2.3': ("app-foo", "foo", "1.2.3", "r0"),
|
||||
'www-apps/389-foo-1.2.3': ("www-apps", "389-foo", "1.2.3", "r0"),
|
||||
}
|
||||
for atom, split_data in data.items():
|
||||
pkgsplit = et.catpkgsplit(atom)
|
||||
self.assertEqual(split_data, pkgsplit)
|
||||
|
||||
def test_dep_getkey(self):
|
||||
pkg = "app-foo/foo-1.2.3"
|
||||
key = "app-foo/foo"
|
||||
self.assertEqual(key, et.dep_getkey(pkg))
|
||||
|
||||
def test_dep_getcpv(self):
|
||||
pkg = ">=app-foo/foo-1.2.3"
|
||||
cpv = "app-foo/foo-1.2.3"
|
||||
self.assertEqual(cpv, et.dep_getcpv(pkg))
|
||||
|
||||
def test_dep_getslot(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
slot = "2.3.4"
|
||||
self.assertEqual(slot, et.dep_getslot(pkg))
|
||||
|
||||
def test_dep_getusedeps(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4[ciao,come,va]"
|
||||
usedeps = ("ciao", "come", "va")
|
||||
self.assertEqual(usedeps, et.dep_getusedeps(pkg))
|
||||
|
||||
def test_remove_usedeps(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4[ciao,come,va]"
|
||||
result = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
self.assertEqual(result, et.remove_usedeps(pkg))
|
||||
|
||||
def test_remove_slot(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4"
|
||||
result = ">=app-foo/foo-1.2.3"
|
||||
self.assertEqual(result, et.remove_slot(pkg))
|
||||
|
||||
def test_remove_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1"
|
||||
result = "app-foo/foo-1.2.3"
|
||||
self.assertEqual(result, et.remove_revision(pkg))
|
||||
|
||||
def test_remove_tag(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo"
|
||||
result = "app-foo/foo-1.2.3-r1"
|
||||
self.assertEqual(result, et.remove_tag(pkg))
|
||||
|
||||
def test_remove_entropy_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = "app-foo/foo-1.2.3-r1#2.2.2-foo"
|
||||
self.assertEqual(result, et.remove_entropy_revision(pkg))
|
||||
|
||||
def test_dep_get_entropy_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = 1
|
||||
self.assertEqual(result, et.dep_get_entropy_revision(pkg))
|
||||
|
||||
def test_dep_get_spm_revision(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1"
|
||||
result = "r1"
|
||||
self.assertEqual(result, et.dep_get_spm_revision(pkg))
|
||||
|
||||
def test_dep_get_match_in_repos(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1@foorepo"
|
||||
result = ("app-foo/foo-1.2.3-r1", ["foorepo"])
|
||||
self.assertEqual(result, et.dep_get_match_in_repos(pkg))
|
||||
|
||||
def test_dep_gettag(self):
|
||||
pkg = "app-foo/foo-1.2.3-r1#2.2.2-foo~1"
|
||||
result = "2.2.2-foo"
|
||||
self.assertEqual(result, et.dep_gettag(pkg))
|
||||
|
||||
def test_remove_package_operators(self):
|
||||
pkg = ">=app-foo/foo-1.2.3:2.3.4~1"
|
||||
result = "app-foo/foo-1.2.3:2.3.4~1"
|
||||
self.assertEqual(result, et.remove_package_operators(pkg))
|
||||
|
||||
def test_compare_versions(self):
|
||||
ver_a = ("1.0.0", "1.0.0", 0,)
|
||||
ver_b = ("1.0.1", "1.0.0", 0.10000000000000001,)
|
||||
ver_c = ("1.0.0", "1.0.1", -0.10000000000000001,)
|
||||
|
||||
self.assertEqual(et.compare_versions(ver_a[0], ver_a[1]), ver_a[2])
|
||||
self.assertEqual(et.compare_versions(ver_b[0], ver_b[1]), ver_b[2])
|
||||
self.assertEqual(et.compare_versions(ver_c[0], ver_c[1]), ver_c[2])
|
||||
|
||||
def test_get_newer_version(self):
|
||||
vers = ["1.0", "3.4", "0.5", "999", "9999", "10.0"]
|
||||
out_vers = ['9999', '999', '10.0', '3.4', '1.0', '0.5']
|
||||
self.assertEqual(et.get_newer_version(vers), out_vers)
|
||||
|
||||
def test_get_entropy_newer_version(self):
|
||||
vers = [("1.0", "2222", 1,), ("3.4", "2222", 0,), ("1.0", "2223", 1,),
|
||||
("1.0", "2223", 3,)]
|
||||
out_vers = [('1.0', '2223', 3), ('1.0', '2223', 1),
|
||||
('3.4', '2222', 0), ('1.0', '2222', 1)]
|
||||
self.assertEqual(et.get_entropy_newer_version(vers), out_vers)
|
||||
|
||||
def test_istextfile(self):
|
||||
fd, tmp_path = tempfile.mkstemp()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ from magneto.gtk.components import AppletNoticeWindow, AppletIconPixbuf
|
||||
|
||||
# Entropy imports
|
||||
from entropy.i18n import _
|
||||
import entropy.tools
|
||||
import entropy.dep
|
||||
|
||||
class Magneto(MagnetoCore):
|
||||
|
||||
@@ -183,12 +183,12 @@ class Magneto(MagnetoCore):
|
||||
packages = []
|
||||
for atom in self.package_updates:
|
||||
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
avail_rev = entropy.tools.dep_get_entropy_revision(atom)
|
||||
avail_tag = entropy.tools.dep_gettag(atom)
|
||||
my_pkg = entropy.tools.remove_entropy_revision(atom)
|
||||
my_pkg = entropy.tools.remove_tag(my_pkg)
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.tools.catpkgsplit(my_pkg)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
avail_rev = entropy.dep.dep_get_entropy_revision(atom)
|
||||
avail_tag = entropy.dep.dep_gettag(atom)
|
||||
my_pkg = entropy.dep.remove_entropy_revision(atom)
|
||||
my_pkg = entropy.dep.remove_tag(my_pkg)
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.dep.catpkgsplit(my_pkg)
|
||||
ver = pkgver
|
||||
if pkgrev != "r0":
|
||||
ver += "-%s" % (pkgrev,)
|
||||
|
||||
@@ -26,7 +26,7 @@ from magneto.kde.components import AppletNoticeWindow, AppletIconPixbuf
|
||||
|
||||
# Entropy imports
|
||||
from entropy.i18n import _
|
||||
import entropy.tools
|
||||
import entropy.dep
|
||||
|
||||
|
||||
class Magneto(MagnetoCore):
|
||||
@@ -218,12 +218,12 @@ class Magneto(MagnetoCore):
|
||||
packages = []
|
||||
for atom in self.package_updates:
|
||||
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
avail_rev = entropy.tools.dep_get_entropy_revision(atom)
|
||||
avail_tag = entropy.tools.dep_gettag(atom)
|
||||
my_pkg = entropy.tools.remove_entropy_revision(atom)
|
||||
my_pkg = entropy.tools.remove_tag(my_pkg)
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.tools.catpkgsplit(my_pkg)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
avail_rev = entropy.dep.dep_get_entropy_revision(atom)
|
||||
avail_tag = entropy.dep.dep_gettag(atom)
|
||||
my_pkg = entropy.dep.remove_entropy_revision(atom)
|
||||
my_pkg = entropy.dep.remove_tag(my_pkg)
|
||||
pkgcat, pkgname, pkgver, pkgrev = entropy.dep.catpkgsplit(my_pkg)
|
||||
ver = pkgver
|
||||
if pkgrev != "r0":
|
||||
ver += "-%s" % (pkgrev,)
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
../libraries/entropy/cache.py
|
||||
../libraries/entropy/const.py
|
||||
../libraries/entropy/debug.py
|
||||
../libraries/entropy/dep.py
|
||||
../libraries/entropy/dump.py
|
||||
../libraries/entropy/exceptions.py
|
||||
../libraries/entropy/fetchers.py
|
||||
|
||||
@@ -20,6 +20,7 @@ from entropy.server.interfaces import Server
|
||||
from entropy.core.settings.base import SystemSettings
|
||||
from entropy.i18n import _
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
Entropy = Server(community_repo = etpConst['community']['mode'])
|
||||
SYS_SET = SystemSettings()
|
||||
@@ -832,7 +833,7 @@ def update(options):
|
||||
|
||||
|
||||
# this is a spm atom
|
||||
spm_key = entropy.tools.dep_getkey(item)
|
||||
spm_key = entropy.dep.dep_getkey(item)
|
||||
try:
|
||||
spm_slot = Entropy.Spm().get_installed_package_metadata(
|
||||
item, "SLOT")
|
||||
@@ -1034,7 +1035,7 @@ def spm_compile_categories(options, do_list = False):
|
||||
oldslots_meta = {}
|
||||
for package in packages:
|
||||
pkg_slot = spm.get_package_metadata(package, "SLOT")
|
||||
pkg_key = entropy.tools.dep_getkey(package)
|
||||
pkg_key = entropy.dep.dep_getkey(package)
|
||||
obj = oldslots_meta.setdefault(pkg_key, set())
|
||||
obj.add((pkg_slot, package,))
|
||||
del packages[:]
|
||||
|
||||
@@ -23,7 +23,9 @@ from entropy.exceptions import *
|
||||
from entropy.const import *
|
||||
from entropy.misc import TimeScheduled, ParallelTask
|
||||
from entropy.output import print_generic
|
||||
import entropy.dep
|
||||
import entropy.dump
|
||||
import entropy.tools
|
||||
|
||||
from sulfur.core import UI
|
||||
from sulfur.setup import const, cleanMarkupString, fakeoutfile, fakeinfile
|
||||
@@ -2265,7 +2267,7 @@ class RepositoryManagerMenu(MenuSkel):
|
||||
|
||||
add_cats_data = {}
|
||||
for spm_atom, spm_counter in data['add_data']:
|
||||
cat = entropy.tools.dep_getkey(spm_atom).split("/")[0]
|
||||
cat = entropy.dep.dep_getkey(spm_atom).split("/")[0]
|
||||
if cat not in add_cats_data:
|
||||
add_cats_data[cat] = []
|
||||
item = data['add_data'][(spm_atom, spm_counter,)]
|
||||
@@ -2993,7 +2995,7 @@ class RepositoryManagerMenu(MenuSkel):
|
||||
if data['atoms']:
|
||||
categories = []
|
||||
for atom in data['atoms']:
|
||||
categories.append(entropy.tools.dep_getkey(atom).split("/")[0])
|
||||
categories.append(entropy.dep.dep_getkey(atom).split("/")[0])
|
||||
if clear: self.clear_data_store_and_view()
|
||||
self.run_get_spm_atoms_info(categories, data['atoms'], clear)
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ from entropy.output import decolorize
|
||||
from entropy.exceptions import *
|
||||
from entropy.const import *
|
||||
from entropy.misc import ParallelTask
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
from sulfur.event import SulfurSignals
|
||||
@@ -1262,7 +1263,7 @@ class PkgInfoMenu(MenuSkel):
|
||||
pkgatom = pkg.name
|
||||
self.vote = int(pkg.vote)
|
||||
self.repository = pkg.repoid
|
||||
self.pkgkey = entropy.tools.dep_getkey(pkgatom)
|
||||
self.pkgkey = entropy.dep.dep_getkey(pkgatom)
|
||||
self.set_stars_from_repository()
|
||||
self.pkginfo_ui.pkgImage.set_from_file(self.pkg_pixmap)
|
||||
self.pkginfo_ui.ugcSmallIcon.set_from_file(self.ugc_small_pixmap)
|
||||
|
||||
@@ -35,6 +35,7 @@ from entropy.client.mirrors import StatusInterface
|
||||
from entropy.exceptions import RepositoryError
|
||||
from entropy.db.exceptions import OperationalError, IntegrityError
|
||||
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
class QueueExecutor:
|
||||
@@ -163,7 +164,7 @@ class QueueExecutor:
|
||||
if myrepo not in mykeys:
|
||||
mykeys[myrepo] = set()
|
||||
mykeys[myrepo].add(
|
||||
entropy.tools.dep_getkey(pkg.pkgmeta['atom']))
|
||||
entropy.dep.dep_getkey(pkg.pkgmeta['atom']))
|
||||
|
||||
self._entropy.output(
|
||||
fetch_string+pkg.pkgmeta['atom'],
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
from entropy.const import *
|
||||
from entropy.i18n import _
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
from sulfur.entropyapi import Equo
|
||||
@@ -255,7 +256,7 @@ class EntropyPackage:
|
||||
atom = self.get_name()
|
||||
repo = self.get_repository()
|
||||
repo_clean = self.get_repository_clean()
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
desc = self.get_description(markup = False)
|
||||
ver_str = self._get_nameDesc_get_installed_ver()
|
||||
self.__cache['get_nameDesc'] = atom, repo, repo_clean, key, desc, \
|
||||
@@ -264,7 +265,7 @@ class EntropyPackage:
|
||||
if atom is None: # wtf!
|
||||
return 'N/A'
|
||||
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
downloads = ENTROPY.UGC.UGCCache.get_package_downloads(repo_clean, key)
|
||||
ugc_string = '<small>[%s|<span foreground="%s">%s</span>]</small> ' % (
|
||||
downloads, SulfurConf.color_title2, repo_clean,)
|
||||
@@ -506,7 +507,7 @@ class EntropyPackage:
|
||||
if self.pkgset:
|
||||
return self.set_name
|
||||
|
||||
key = entropy.tools.dep_getkey(
|
||||
key = entropy.dep.dep_getkey(
|
||||
self.dbconn.retrieveAtom(self.matched_id))
|
||||
self.__cache['get_key'] = key
|
||||
return key
|
||||
@@ -580,7 +581,7 @@ class EntropyPackage:
|
||||
if not atom:
|
||||
return None
|
||||
return ENTROPY.UGC.UGCCache.get_package_vote(
|
||||
self.get_repository_clean(), entropy.tools.dep_getkey(atom))
|
||||
self.get_repository_clean(), entropy.dep.dep_getkey(atom))
|
||||
|
||||
def get_ugc_package_vote_int(self):
|
||||
if self.pkgset:
|
||||
@@ -589,7 +590,7 @@ class EntropyPackage:
|
||||
if not atom:
|
||||
return 0
|
||||
vote = ENTROPY.UGC.UGCCache.get_package_vote(
|
||||
self.get_repository_clean(), entropy.tools.dep_getkey(atom))
|
||||
self.get_repository_clean(), entropy.dep.dep_getkey(atom))
|
||||
if not isinstance(vote, float):
|
||||
return 0
|
||||
return int(vote)
|
||||
@@ -601,7 +602,7 @@ class EntropyPackage:
|
||||
if not atom:
|
||||
return 0.0
|
||||
vote = ENTROPY.UGC.UGCCache.get_package_vote(
|
||||
self.get_repository_clean(), entropy.tools.dep_getkey(atom))
|
||||
self.get_repository_clean(), entropy.dep.dep_getkey(atom))
|
||||
if not isinstance(vote, float):
|
||||
return 0.0
|
||||
return vote
|
||||
@@ -615,7 +616,7 @@ class EntropyPackage:
|
||||
atom = self.get_name()
|
||||
if not atom:
|
||||
return 0
|
||||
key = entropy.tools.dep_getkey(atom)
|
||||
key = entropy.dep.dep_getkey(atom)
|
||||
return ENTROPY.UGC.UGCCache.get_package_downloads(
|
||||
self.get_repository_clean(), key)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user