mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-08 00:51:36 +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,
|
eval_uninst, newly_uninst, make_migrationitem,
|
||||||
write_excuses, write_heidi_delta, write_controlfiles,
|
write_excuses, write_heidi_delta, write_controlfiles,
|
||||||
old_libraries, is_nuninst_asgood_generous,
|
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 policies.policy import AgePolicy, RCBugPolicy, PolicyVerdict
|
||||||
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
|
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
|
||||||
SOURCE, SOURCEVER, ARCHITECTURE, CONFLICTS, DEPENDS,
|
SOURCE, SOURCEVER, ARCHITECTURE, CONFLICTS, DEPENDS,
|
||||||
@ -1014,13 +1016,7 @@ class Britney(object):
|
|||||||
self.sources[distribution])
|
self.sources[distribution])
|
||||||
|
|
||||||
# create provides
|
# create provides
|
||||||
provides = defaultdict(set)
|
provides = create_provides_map(packages)
|
||||||
|
|
||||||
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 a tuple with the list of real and virtual packages
|
# return a tuple with the list of real and virtual packages
|
||||||
return (packages, provides)
|
return (packages, provides)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from itertools import filterfalse
|
from itertools import filterfalse
|
||||||
@ -654,3 +655,21 @@ def possibly_compressed(path, permitted_compressesion=None):
|
|||||||
if os.path.exists(cpath):
|
if os.path.exists(cpath):
|
||||||
return cpath
|
return cpath
|
||||||
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
|
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