-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pacman: Fix removing locally installed packages (#4464)
* pacman: Fix removing locally installed packages Without this, using `absent` state for a locally installed package (for example from AUR, or from a package that was dropped from repositories) would return that package is already removed, despite remaining installed * Undo unwanted whitespace removal * Add changelog fragment * Update changelogs/fragments/4464-pacman-fix-local-remove.yaml Co-authored-by: Felix Fontein <[email protected]> * Add test. Co-authored-by: Felix Fontein <[email protected]>
- Loading branch information
1 parent
fe4bbc5
commit 3c515dd
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- pacman - fixed bug where ``absent`` state did not work for locally installed packages (https://github.com/ansible-collections/community.general/pull/4464). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ skip/freebsd | |
skip/osx | ||
skip/macos | ||
skip/rhel | ||
needs/root |
81 changes: 81 additions & 0 deletions
81
tests/integration/targets/pacman/tasks/locally_installed_package.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
- vars: | ||
package_name: ansible-test-foo | ||
username: ansible-regular-user | ||
block: | ||
- name: Install fakeroot | ||
pacman: | ||
state: present | ||
name: | ||
- fakeroot | ||
|
||
- name: Create user | ||
user: | ||
name: '{{ username }}' | ||
home: '/home/{{ username }}' | ||
create_home: true | ||
|
||
- name: Create directory | ||
file: | ||
path: '/home/{{ username }}/{{ package_name }}' | ||
state: directory | ||
owner: '{{ username }}' | ||
|
||
- name: Create PKGBUILD | ||
copy: | ||
dest: '/home/{{ username }}/{{ package_name }}/PKGBUILD' | ||
content: | | ||
pkgname=('{{ package_name }}') | ||
pkgver=1.0.0 | ||
pkgrel=1 | ||
pkgdesc="Test removing a local package not in the repositories" | ||
arch=('any') | ||
license=('GPL v3+') | ||
owner: '{{ username }}' | ||
|
||
- name: Build package | ||
command: | ||
cmd: su {{ username }} -c "makepkg -srf" | ||
chdir: '/home/{{ username }}/{{ package_name }}' | ||
|
||
- name: Install package | ||
pacman: | ||
state: present | ||
name: | ||
- '/home/{{ username }}/{{ package_name }}/{{ package_name }}-1.0.0-1-any.pkg.tar.zst' | ||
|
||
- name: Remove package (check mode) | ||
pacman: | ||
state: absent | ||
name: | ||
- '{{ package_name }}' | ||
check_mode: true | ||
register: remove_1 | ||
|
||
- name: Remove package | ||
pacman: | ||
state: absent | ||
name: | ||
- '{{ package_name }}' | ||
register: remove_2 | ||
|
||
- name: Remove package (idempotent) | ||
pacman: | ||
state: absent | ||
name: | ||
- '{{ package_name }}' | ||
register: remove_3 | ||
|
||
- name: Check conditions | ||
assert: | ||
that: | ||
- remove_1 is changed | ||
- remove_2 is changed | ||
- remove_3 is not changed | ||
|
||
always: | ||
- name: Remove directory | ||
file: | ||
path: '{{ remote_tmp_dir }}/{{ package_name }}' | ||
state: absent | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters