* Revert "[stable-2.17] dnf: follow-up on is_newer_installed arches fix (#83556) (#83563)"

This reverts commit fa40503191.

* Revert "[stable-2.17] dnf - arches must be the same in the is_newer_installed check (#83417)"

This reverts commit 6966b53b5b.
pull/83567/head
Matt Davis 5 months ago committed by GitHub
parent fa40503191
commit 7a9f14b19e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,2 +0,0 @@
bugfixes:
- dnf - fix an issue where two packages of the same ``evr`` but different arch failed to install (https://github.com/ansible/ansible/issues/83406)

@ -0,0 +1,2 @@
bugfixes:
- dnf - reverted incomplete fix from 2.17.2rc1 (https://github.com/ansible/ansible/pull/83504)

@ -743,25 +743,18 @@ class DnfModule(YumDnf):
else: else:
return bool(installed_query) return bool(installed_query)
def _is_newer_version_installed(self, pkg_spec): def _is_newer_version_installed(self, pkg_name):
try: try:
if isinstance(pkg_spec, dnf.package.Package): if isinstance(pkg_name, dnf.package.Package):
installed = sorted(self.base.sack.query().installed().filter(name=pkg_spec.name, arch=pkg_spec.arch))[-1] available = pkg_name
return installed.evr_gt(pkg_spec)
else: else:
available = dnf.subject.Subject(pkg_spec).get_best_query(sack=self.base.sack).available() available = sorted(
installed = self.base.sack.query().installed().filter(name=available[0].name) dnf.subject.Subject(pkg_name).get_best_query(sack=self.base.sack).available().run()
for arch in sorted(set(p.arch for p in installed)): # select only from already-installed arches for this case )[-1]
installed_pkg = sorted(installed.filter(arch=arch))[-1] installed = sorted(self.base.sack.query().installed().filter(name=available.name).run())[-1]
try:
available_pkg = sorted(available.filter(arch=arch))[-1]
except IndexError:
continue # nothing currently available for this arch; keep going
if installed_pkg.evr_gt(available_pkg):
return True
return False
except IndexError: except IndexError:
return False return False
return installed > available
def _mark_package_install(self, pkg_spec, upgrade=False): def _mark_package_install(self, pkg_spec, upgrade=False):
"""Mark the package for install.""" """Mark the package for install."""

@ -542,60 +542,3 @@
dnf: dnf:
name: provides_foo* name: provides_foo*
state: absent state: absent
- name: test that only evr is compared, avoiding a situation when a specific arch would be considered as a "newer" package
block:
- dnf:
name: "{{ item }}"
state: present
loop:
- "dinginessentail-1.0-1.x86_64"
- "dinginessentail-1.0-1.i686"
register: dnf_results
- assert:
that:
- dnf_results["results"][0] is changed
- dnf_results["results"][1] is changed
always:
- name: Clean up
dnf:
name: dinginessentail
state: absent
- block:
- name: make sure dinginessentail is not installed
dnf:
name: dinginessentail
state: absent
- name: install dinginessentail both archs
dnf:
name:
- "{{ repodir }}/dinginessentail-1.1-1.x86_64.rpm"
- "{{ repodir_i686 }}/dinginessentail-1.1-1.i686.rpm"
state: present
disable_gpg_check: true
- name: try to install lower version of dinginessentail from rpm file, without allow_downgrade, just one arch
dnf:
name: "{{ repodir_i686 }}/dinginessentail-1.0-1.i686.rpm"
state: present
register: dnf_result
- name: check dinginessentail with rpm
shell: rpm -q dinginessentail
register: rpm_result
- name: verify installation
assert:
that:
- "not dnf_result.changed"
- "rpm_result.stdout_lines[0].startswith('dinginessentail-1.1-1')"
- "rpm_result.stdout_lines[1].startswith('dinginessentail-1.1-1')"
always:
- name: Clean up
dnf:
name: dinginessentail
state: absent
when: ansible_architecture == "x86_64"

Loading…
Cancel
Save