Subpackage installed by "install_if" never gets removed
Version: 2.12.0
Overview
apk upgrade
does not remove implicitly installed subpackages by install_if
, even if the subpackage does not exist anymore in any APKINDEX.
Furthermore, it is impossible to remove the package manually.
Example
- APKBUILD of subpkg-test with install_if subpackage
pkgname="subpkg-test"
pkgver=1
pkgrel=0
subpackages="$pkgname-subpkg"
package() {
mkdir -p "$pkgdir"
}
subpkg() {
install_if="$pkgname alpine-base"
mkdir -p "$subpkgdir"
}
- Installing the package above
# apk add subpkg-test
(1/2) Installing subpkg-test (1-r0)
(2/2) Installing subpkg-test-subpkg (1-r0)
OK: 213 MiB in 61 packages
- APKBUILD of upgraded subpkg-test with subpackage removed
pkgname="subpkg-test"
pkgver=2
pkgrel=0
package() {
mkdir -p "$pkgdir"
}
- Output of
apk upgrade
, after building the new package and removing the subpackage from APKINDEX. It does not purgesubpkg-test-subpkg
:
# apk upgrade
(1/1) Upgrading subpkg-test (1-r0 -> 2-r0)
OK: 213 MiB in 61 packages
- Trying to remove it manually doesn't work:
# apk del subpkg-test-subpkg
World updated, but the following packages are not removed due to:
subpkg-test-subpkg: subpkg-test alpine-base
OK: 213 MiB in 61 packages
# apk del --force-broken-world subpkg-test-subpkg
World updated, but the following packages are not removed due to:
subpkg-test-subpkg: subpkg-test alpine-base
OK: 213 MiB in 61 packages
Workaround
Add provides="$pkgname-subpkg=$pkgver-r$pkgrel"
to the APKBUILD.
pkgname="subpkg-test"
pkgver=2
pkgrel=0
provides="$pkgname-subpkg=$pkgver-r$pkgrel"
package() {
mkdir -p "$pkgdir"
}
# apk upgrade
(1/2) Purging subpkg-test-subpkg (1-r0)
(2/2) Upgrading subpkg-test (1-r0 -> 2-r0)
OK: 213 MiB in 60 packages
FWIW, the subpackage can also be added back again when using this workaround.
Reproducer
https://gitlab.com/ollieparanoid/reproducers/-/tree/master/apk-subpkg
What needs to be fixed
I think apk should purge subpkg-test-subpkg if it disappears, unless it was explicitly installed with apk add subpkg-test-subpkg
.
Is that accurate, or am I missing something?