Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support yum and dnf python bindings #271

Merged
merged 1 commit into from
Sep 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
from optparse import OptionParser
from urllib import urlencode
from ConfigParser import SafeConfigParser
import yum # pylint:disable=import-error
try:
import yum # pylint:disable=import-error
USE_YUM = True
except ImportError:
import dnf # pylint:disable=import-error
USE_YUM = False
import rpm # pylint:disable=import-error
import rpmUtils.miscutils # pylint:disable=import-error

Expand Down Expand Up @@ -197,16 +202,25 @@ def install_prereqs():
if options.deps_repository_url:
print_generic("Enabling %s as a repository for dependency RPMs" % options.deps_repository_url)
setup_yum_repo(options.deps_repository_url, options.deps_repository_gpg_key)
yum_base = yum.YumBase()
pkg_list = yum_base.doPackageLists(patterns=['subscription-manager'])
if USE_YUM:
yum_base = yum.YumBase()
pkg_list = yum_base.doPackageLists(patterns=['subscription-manager'])
subman_installed = pkg_list.installed
subman_available = pkg_list.available
else:
dnf_base = dnf.Base()
dnf_base.fill_sack()
pkg_list = dnf_base.sack.query().filter(name='subscription-manager')
subman_installed = pkg_list.installed().run()
subman_available = pkg_list.available().run()
call_yum("remove", "subscription-manager-gnome")
if pkg_list.installed:
if subman_installed:
if check_rhn_registration() and 'migration' not in options.skip:
print_generic("installing subscription-manager-migration")
call_yum("install", "'subscription-manager-migration-*'", False)
print_generic("subscription-manager is installed already. Attempting update")
call_yum("update", "subscription-manager 'subscription-manager-migration-*'", False)
elif pkg_list.available:
elif subman_available:
print_generic("subscription-manager NOT installed. Installing.")
call_yum("install", "subscription-manager 'subscription-manager-migration-*'")
else:
Expand Down