Install packages from prefered repositories.
* Yyoom tries to install packages from preferred repositories and, if packages were not found, tries to install them from default ones. * Preferred repositories are passed to yyoom from the dependency handler. Change-Id: Iede5ad1c58c105c2627ad1012e959f0f93c4a447
This commit is contained in:
parent
2051e05d05
commit
c765de2eb1
@ -38,11 +38,13 @@ def _parse_json(value):
|
|||||||
|
|
||||||
class Helper(object):
|
class Helper(object):
|
||||||
|
|
||||||
def __init__(self, log_dir):
|
def __init__(self, log_dir, repos):
|
||||||
# Executables we require to operate
|
# Executables we require to operate
|
||||||
self.yyoom_executable = sh.which("yyoom", ["tools/"])
|
self.yyoom_executable = sh.which("yyoom", ["tools/"])
|
||||||
# Executable logs will go into this directory
|
# Executable logs will go into this directory
|
||||||
self._log_dir = log_dir
|
self._log_dir = log_dir
|
||||||
|
# Preferred repositories names
|
||||||
|
self._repos = repos
|
||||||
# Caches of installed and available packages
|
# Caches of installed and available packages
|
||||||
self._installed = None
|
self._installed = None
|
||||||
self._available = None
|
self._available = None
|
||||||
@ -136,6 +138,9 @@ class Helper(object):
|
|||||||
for pkg in remove_pkgs:
|
for pkg in remove_pkgs:
|
||||||
cmdline.append('--erase')
|
cmdline.append('--erase')
|
||||||
cmdline.append(pkg)
|
cmdline.append(pkg)
|
||||||
|
for repo in self._repos:
|
||||||
|
cmdline.append('--prefer-repo')
|
||||||
|
cmdline.append(repo)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmd_type = 'transaction'
|
cmd_type = 'transaction'
|
||||||
|
@ -94,7 +94,7 @@ class YumDependencyHandler(base.DependencyHandler):
|
|||||||
self.rpmbuild_executable = sh.which("rpmbuild")
|
self.rpmbuild_executable = sh.which("rpmbuild")
|
||||||
self.specprint_executable = sh.which('specprint', ["tools/"])
|
self.specprint_executable = sh.which('specprint', ["tools/"])
|
||||||
# We inspect yum for packages, this helper allows us to do this.
|
# We inspect yum for packages, this helper allows us to do this.
|
||||||
self.helper = yum_helper.Helper(self.log_dir)
|
self.helper = yum_helper.Helper(self.log_dir, self.REPOS)
|
||||||
# See if we are requested to run at a higher make parallelism level
|
# See if we are requested to run at a higher make parallelism level
|
||||||
self._jobs = self.JOBS
|
self._jobs = self.JOBS
|
||||||
if 'jobs' in self.opts:
|
if 'jobs' in self.opts:
|
||||||
|
20
tools/yyoom
20
tools/yyoom
@ -254,19 +254,27 @@ def _run(yum_base, options):
|
|||||||
with _transaction(yum_base,
|
with _transaction(yum_base,
|
||||||
_OutputtingRPMCallback(options.skip_missing)) as cb:
|
_OutputtingRPMCallback(options.skip_missing)) as cb:
|
||||||
yum_map = build_yum_map(yum_base)
|
yum_map = build_yum_map(yum_base)
|
||||||
|
# erase packages
|
||||||
for pkg_name in options.erase or ():
|
for pkg_name in options.erase or ():
|
||||||
matches = _find_packages(yum_map, pkg_name)
|
matches = _find_packages(yum_map, pkg_name)
|
||||||
if matches is None:
|
if matches is None:
|
||||||
cb.yyoom_on_missing_package(pkg_name)
|
cb.yyoom_on_missing_package(pkg_name)
|
||||||
installed_packages = yum_base.rpmdb.returnPackages()
|
else:
|
||||||
for package in matches:
|
installed_packages = yum_base.rpmdb.returnPackages()
|
||||||
if package in installed_packages:
|
for package in matches:
|
||||||
yum_base.remove(package)
|
if package in installed_packages:
|
||||||
|
yum_base.remove(package)
|
||||||
|
# install packages
|
||||||
for pkg_name in options.install or ():
|
for pkg_name in options.install or ():
|
||||||
matches = _find_packages(yum_map, pkg_name)
|
matches = _find_packages(yum_map, pkg_name)
|
||||||
if matches is None:
|
if matches is None:
|
||||||
cb.yyoom_on_missing_package(pkg_name)
|
cb.yyoom_on_missing_package(pkg_name)
|
||||||
else:
|
else:
|
||||||
|
# try to install package from preferred repositories,
|
||||||
|
# if not found - install from default ones
|
||||||
|
repo_matches = [m for m in matches
|
||||||
|
if m.repoid in options.prefer_repo]
|
||||||
|
matches = repo_matches if repo_matches else matches
|
||||||
yum_base.install(max(matches))
|
yum_base.install(max(matches))
|
||||||
|
|
||||||
|
|
||||||
@ -353,6 +361,10 @@ def _parse_arguments(args):
|
|||||||
parser_run.add_argument('--skip-missing', action='store_true',
|
parser_run.add_argument('--skip-missing', action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help='do not fail on missing packages')
|
help='do not fail on missing packages')
|
||||||
|
parser_run.add_argument('--prefer-repo', '-r', action='append',
|
||||||
|
metavar='repository',
|
||||||
|
default=[],
|
||||||
|
help='preferred repository name')
|
||||||
parser_run.set_defaults(func=_run, operation='Transaction')
|
parser_run.set_defaults(func=_run, operation='Transaction')
|
||||||
|
|
||||||
# Arg: srpm
|
# Arg: srpm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user