Skip to content

Fix package manager decisions#419

Merged
xsuchy merged 5 commits intorpm-software-management:develfrom
praiskup:fix-package-manager-decisions
Nov 29, 2019
Merged

Fix package manager decisions#419
xsuchy merged 5 commits intorpm-software-management:develfrom
praiskup:fix-package-manager-decisions

Conversation

@praiskup
Copy link
Member

@praiskup praiskup commented Nov 15, 2019

Fixes #233.

From commits:

1) More careful package management choice

Previously we only warned when 'dnf' was expected for chroot
initialization, but wasn't available.  Now we detect this situation also
for other package managers (e.g. missing /bin/yum, etc.).

When installing bootstrap chroot, we aren't anymore that much picky
about host pkg manager.  This means that '/bin/yum' doesn't have to be
installed at all on host to install yum-based bootstrap, but more
importantly '/bin/dnf' doesn't have to exist on YUM based hosts when
installing DNF based chroots.  This should demotivate users from using
'--yum' option on YUM based options to install bootstrap (#233).

2)  Detect '/bin/yum' symlink to 'dnf'

In such case we actually talk to 'dnf', and it doesn't make any sense to
instantiate Yum class.  This is generalized to other package managers
as well, even though it is less likely to happen.

@pep8speaks
Copy link

pep8speaks commented Nov 15, 2019

Hello @praiskup! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-11-29 09:15:01 UTC

from .trace_decorator import traceLog, getLog

fallbacks = {
'dnf': ['dnf', 'yum', 'microdnf'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be ['dnf', 'microdnf', 'yum']?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yes, good point.

@praiskup praiskup force-pushed the fix-package-manager-decisions branch 2 times, most recently from 6823a18 to e1a57c3 Compare November 15, 2019 10:23
@Conan-Kudo
Copy link
Member

@praiskup Also, how do we handle for the YUM package manager preferring /usr/bin/yum-deprecated over /usr/bin/yum? Is that in here or handled elsewhere?

@praiskup
Copy link
Member Author

Meh, I forgot about that. I'll special-case that case, thank you!

option = '{}_command'.format(name)
pathname = config_opts[option]
if not os.path.isfile(pathname):
if pathname == '/usr/bin/yum':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can have yum-deprecated without yum by having the yum package installed and the dnf-yum package not installed. This should account for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pathname variable only contains "expected" location. This code doesn't
work with package name - so I think it should work just fine. Can you please
take another look?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the other problem, if there are both yum and dnf-yum packages installed. The check simply prefers '/usr/bin/yum' (which is dnf) and tells that there's no yum ... I'll fix this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be tested with mock from dnf copr enable praiskup/mock-fixes, if anyone wanted to try.

@praiskup praiskup force-pushed the fix-package-manager-decisions branch from 360223d to b554860 Compare November 15, 2019 11:12
self.builddep_command = ['/usr/bin/yum-builddep-deprecated']
# the command in bootstrap may not exists yet
if bootstrap_buildroot is None:
self._check_command()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'm not entirely sure that suggesting --dnf or --yum here is correct.



def package_manager_class(config_opts, buildroot, bootstrap_buildroot=None):
pm = config_opts.get('package_manager', 'yum')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default to 'dnf' several commits ago.


fallbacks = {
'dnf': ['dnf', 'microdnf', 'yum'],
'yum': ['yum', 'dnf', 'microdnf'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MicroDNF cannot actually work without DNF. Yet. So having microdnf in fallback for yum and dnf does not have sense. E.g. Microdnf cannot do 'builddep' command and execute dnf for that.

if distribution in util.RHEL_CLONES:
version = int(version.split('.')[0])
if version < 8:
if ('dnf_warning' not in config_opts or config_opts['dnf_warning']) and \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dnf_warning disappeared

@praiskup praiskup force-pushed the fix-package-manager-decisions branch 4 times, most recently from c027e0c to b229224 Compare November 27, 2019 14:48
@praiskup
Copy link
Member Author

praiskup commented Nov 27, 2019

PTAL, the output now is (on F31 with installed yum.rpm):

$ mock -r epel-7-x86_64 --shell
INFO: mock.py version 1.5.0 starting (python version = 3.7.5)...
WARNING: Not using '/usr/bin/yum', it is symlink to '/usr/bin/dnf-3'
INFO: Using 'dnf' instead of 'yum'
WARNING! WARNING! WARNING!
You are building package for distribution which uses YUM. However your system
does not support YUM. You can continue with DNF, which will likely succeed,
but the installed chroot may look a little different.
  1. Please consider --bootstrap-chroot option, or
  2. install YUM on your host system.
You can suppress this warning when you put
  config_opts['dnf_warning'] = False
in Mock config.
Press Enter to continue.ERROR: Exiting on user interrupt, <CTRL>-C

vs.

$ mock -r epel-7-x86_64 --shell --bootstrap-chroot 
INFO: mock.py version 1.5.0 starting (python version = 3.7.5)...
WARNING: Not using '/usr/bin/yum', it is symlink to '/usr/bin/dnf-3'
INFO: Using 'dnf' instead of 'yum' for bootstrap chroot
Start(bootstrap): init plugins
...

# config_opts['dnf_vars'] = { 'key': 'value', 'key2': 'value2' }
#
# Flip this if you want to get rid of warning message on systems which does not support DNF
# Flip this if you want to get rid of warning message on systems which does not support
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/does/do/

Previously we only warned when 'dnf' was expected for chroot
initialization, but wasn't available.  Now we detect this situation also
for other package managers (e.g. missing /bin/yum, etc.).

When installing bootstrap chroot, we aren't anymore that much picky
about host pkg manager.  This means that '/bin/yum' doesn't have to be
installed at all on host to install yum-based bootstrap, but more
importantly '/bin/dnf' doesn't have to exist on YUM based hosts when
installing DNF based chroots.  This should demotivate users from using
'--yum' option on YUM based options to install bootstrap (rpm-software-management#233).

Fixes: rpm-software-management#233
Detect '/bin/yum' symlink to 'dnf'

In such case we actually talk to 'dnf', and it doesn't make any sense to
instantiate Yum class.  This is generalized to other package managers
as well, even though it is less likely to happen.
Special-case searching for yum-deprecated binary on host

The Yum class code dealing with 'yum-deprecated' script isn't nice,
because it blindly overrides (possibly) user-specified
config_opts['yum_command'].  I don't want to change that part of code
now (too late, yum-deprecated is not likely to be seen on users' hosts
anyways).  So I only check if the /usr/bin/yum-deprecated exists, and
postpone all the important decisions to the Yum class logic.
yum: delay the check for /usr/bin/yum a bit

The check needs to be done once we detected that yum-deprecated needs to
be used instead.  This fails e.g. on F29 with 'yum' installed but
missing 'yum-dnf' (if yum-dnf get's installed it works fine, but yum-dnf
ins't used at all).
mock: default the pkg manager to dnf

The default should always be given by util.py anyways.
@praiskup praiskup force-pushed the fix-package-manager-decisions branch from b229224 to dcfe010 Compare November 29, 2019 09:14
@xsuchy xsuchy merged commit 7a3bdb2 into rpm-software-management:devel Nov 29, 2019
@praiskup praiskup deleted the fix-package-manager-decisions branch December 21, 2021 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--bootstrap-chroot --yum fails with EL8

4 participants