parent
e3f8e05ecb
commit
9ec9f18b13
3 changed files with 37 additions and 0 deletions
2
changelogs/fragments/50843.yaml
Normal file
2
changelogs/fragments/50843.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- dnf - allow to operate on file paths (https://github.com/ansible/ansible/issues/50843)
|
|
@ -747,6 +747,13 @@ class DnfModule(YumDnf):
|
|||
"results": []
|
||||
}
|
||||
|
||||
def _whatprovides(self, filepath):
|
||||
available = self.base.sack.query().available()
|
||||
pkg_spec = available.filter(provides=filepath).run()
|
||||
|
||||
if pkg_spec:
|
||||
return pkg_spec[0].name
|
||||
|
||||
def _parse_spec_group_file(self):
|
||||
pkg_specs, grp_specs, module_specs, filenames = [], [], [], []
|
||||
already_loaded_comps = False # Only load this if necessary, it's slow
|
||||
|
@ -758,6 +765,13 @@ class DnfModule(YumDnf):
|
|||
elif name.endswith(".rpm"):
|
||||
filenames.append(name)
|
||||
elif name.startswith("@") or ('/' in name):
|
||||
# like "dnf install /usr/bin/vi"
|
||||
if '/' in name:
|
||||
pkg_spec = self._whatprovides(name)
|
||||
if pkg_spec:
|
||||
pkg_specs.append(pkg_spec)
|
||||
continue
|
||||
|
||||
if not already_loaded_comps:
|
||||
self.base.read_comps()
|
||||
already_loaded_comps = True
|
||||
|
|
|
@ -664,3 +664,24 @@
|
|||
state: absent
|
||||
|
||||
# end test case where disable_excludes is supported
|
||||
|
||||
- name: Test "dnf install /usr/bin/vi"
|
||||
block:
|
||||
- name: Clean vim-minimal
|
||||
dnf:
|
||||
name: vim-minimal
|
||||
state: absent
|
||||
|
||||
- name: Install vim-minimal by specifying "/usr/bin/vi"
|
||||
dnf:
|
||||
name: /usr/bin/vi
|
||||
state: present
|
||||
|
||||
- name: Get rpm output
|
||||
command: rpm -q vim-minimal
|
||||
register: rpm_output
|
||||
|
||||
- name: Check installation was successful
|
||||
assert:
|
||||
that:
|
||||
- "'vim-minimal' in rpm_output.stdout"
|
||||
|
|
Loading…
Reference in a new issue