mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-12 20:01:08 +00:00
britney.py: Support compressed Packages/Sources
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
398c7a4959
commit
ccb473e19f
@ -200,7 +200,7 @@ from excuse import Excuse
|
||||
from migrationitem import MigrationItem
|
||||
from hints import HintParser
|
||||
from britney_util import (old_libraries_format, undo_changes,
|
||||
compute_reverse_tree,
|
||||
compute_reverse_tree, possibly_compressed,
|
||||
read_nuninst, write_nuninst, write_heidi,
|
||||
eval_uninst, newly_uninst, make_migrationitem,
|
||||
write_excuses, write_heidi_delta, write_controlfiles,
|
||||
@ -790,6 +790,7 @@ class Britney(object):
|
||||
sources = {}
|
||||
for component in self.options.components:
|
||||
filename = os.path.join(basedir, component, "source", "Sources")
|
||||
filename = possibly_compressed(filename)
|
||||
self._read_sources_file(filename, sources)
|
||||
else:
|
||||
filename = os.path.join(basedir, "Sources")
|
||||
@ -970,6 +971,7 @@ class Britney(object):
|
||||
for component in self.options.components:
|
||||
filename = os.path.join(basedir,
|
||||
component, "binary-%s" % arch, "Packages")
|
||||
filename = possibly_compressed(filename)
|
||||
self._read_packages_file(filename, arch,
|
||||
self.sources[distribution], packages)
|
||||
else:
|
||||
|
@ -27,6 +27,7 @@ from itertools import filterfalse
|
||||
import os
|
||||
import time
|
||||
import yaml
|
||||
import errno
|
||||
|
||||
from migrationitem import MigrationItem, UnversionnedMigrationItem
|
||||
|
||||
@ -626,3 +627,24 @@ def check_installability(inst_tester, binaries, arch, updates, affected, check_a
|
||||
nuninst[parch].discard(name)
|
||||
test_installability(inst_tester, name, pkg_id, broken, nuninst_arch)
|
||||
|
||||
|
||||
def possibly_compressed(path, permitted_compressesion=None):
|
||||
"""Find and select a (possibly compressed) variant of a path
|
||||
|
||||
If the given path exists, it will be returned
|
||||
|
||||
:param path The base path.
|
||||
:param permitted_compressesion An optional list of alternative extensions to look for.
|
||||
Defaults to "gz" and "xz".
|
||||
:returns The path given possibly with one of the permitted extensions. Will raise a
|
||||
FileNotFoundError
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
if permitted_compressesion is None:
|
||||
permitted_compressesion = ['gz', 'xz']
|
||||
for ext in permitted_compressesion:
|
||||
cpath = "%s.%s" % (path, ext)
|
||||
if os.path.exists(cpath):
|
||||
return cpath
|
||||
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user