Subject: What exatly is install_if in apk?

From: Pramod V U <[email-masked]>
Date: Thu, 15 May 2025 17:38:54 +0000

I'm extremely sorry, I couldn't find any documentation on it.

In the alpine testing repo, there's a service management suite named 66.
I will be packaging frontends (analogous to openrc initscripts) for 66, for alpine.
They will be the name of the binary "$pkgnam" with "-66" suffix; Named "$pkgnam-66"

In order to make these packages install by themselves, similar to "$pkgnam-openrc" if "openrc" is installed, I understood that there is a feature known as "install_if".
But I am unable to find any info on how to use it, or even what exactly is it.

Help will be appreciated.

Regards, Pramod V U

---

From: "fossdd" <[email-masked]>
Date: Thu, 15 May 2025 19:49:57 +0200

> I'm extremely sorry, I couldn't find any documentation on it.

Yeah, documentation is a bit missing in this case.

> They will be the name of the binary "$pkgnam" with "-66" suffix; Named "$pkgnam-66"\

Note that Alpine for now won't add new subpackages for various init
systems. Alternative init systems are not really supported at the
moment.

> But I am unable to find any info on how to use it, or even what exactly is it.

It's defining a "optional dependency" to the referenced package. If
`test-66` has a install if on `test 66`, test-66 gets installed if
`test` and `66` is installed, if there is only one package referenced,
it gets installed if the single package is installed.

But install_if's are not strict dependencies, as the usual apk
dependencies. For example, in this case we can still run `apk add
!test-66` to remove the package.

Often install_ifs are combined with subpackages which contain files only
relevant to a related other package:
	
	pkgname=someservice
	pkgver=1
	pkgrel=0
	subpackages="$pkgname-somethingelse"
	...

	somethingelse() {
		depends="$pkgname=$pkgver-r$pkgrel somethingelse"
		install_if="$pkgname=$pkgver-r$pkgrel somethingelse"
		
		amove ...
	}