mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-24 03:41:12 +00:00
britney -> util: Extract a "create_provides_map"
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
6de0c3408c
commit
ea166f5bd3
12
britney.py
12
britney.py
@ -205,7 +205,9 @@ from britney_util import (old_libraries_format, undo_changes,
|
||||
eval_uninst, newly_uninst, make_migrationitem,
|
||||
write_excuses, write_heidi_delta, write_controlfiles,
|
||||
old_libraries, is_nuninst_asgood_generous,
|
||||
clone_nuninst, check_installability)
|
||||
clone_nuninst, check_installability,
|
||||
create_provides_map,
|
||||
)
|
||||
from policies.policy import AgePolicy, RCBugPolicy, PolicyVerdict
|
||||
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
|
||||
SOURCE, SOURCEVER, ARCHITECTURE, CONFLICTS, DEPENDS,
|
||||
@ -1014,13 +1016,7 @@ class Britney(object):
|
||||
self.sources[distribution])
|
||||
|
||||
# create provides
|
||||
provides = defaultdict(set)
|
||||
|
||||
for pkg, dpkg in packages.items():
|
||||
# register virtual packages and real packages that provide
|
||||
# them
|
||||
for provided_pkg, provided_version, _ in dpkg[PROVIDES]:
|
||||
provides[provided_pkg].add((pkg, provided_version))
|
||||
provides = create_provides_map(packages)
|
||||
|
||||
# return a tuple with the list of real and virtual packages
|
||||
return (packages, provides)
|
||||
|
@ -21,6 +21,7 @@
|
||||
# GNU General Public License for more details.
|
||||
|
||||
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
from datetime import datetime
|
||||
from itertools import filterfalse
|
||||
@ -654,3 +655,21 @@ def possibly_compressed(path, permitted_compressesion=None):
|
||||
if os.path.exists(cpath):
|
||||
return cpath
|
||||
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
|
||||
|
||||
|
||||
def create_provides_map(packages):
|
||||
"""Create a provides map from a map binary package names and thier BinaryPackage objects
|
||||
|
||||
:param packages: A dict mapping binary package names to their BinaryPackage object
|
||||
:return: A provides map
|
||||
"""
|
||||
# create provides
|
||||
provides = defaultdict(set)
|
||||
|
||||
for pkg, dpkg in packages.items():
|
||||
# register virtual packages and real packages that provide
|
||||
# them
|
||||
for provided_pkg, provided_version, _ in dpkg[PROVIDES]:
|
||||
provides[provided_pkg].add((pkg, provided_version))
|
||||
|
||||
return provides
|
||||
|
Loading…
x
Reference in New Issue
Block a user