Subject: Re: [PATCH v4 0/5] meson: add corresponding target for Makefile's hdr-check

From: Phillip Wood <[email-masked]>
Date: Wed, 23 Apr 2025 11:04:48 +0100

On 22/04/2025 16:55, Junio C Hamano wrote:
> Phillip Wood <[email-masked]> writes:
> 
>> I'd be tempted to check for which package manager to use by using
>> `command -v`. That way the only distribution specific knowledge we
>> need is the package manager and we don't have to worry about the names
>> of the various release files in /etc.
>>
>> 	if command -v git
>> 	then
>> 		: nothing to do
>> 	elif command -v apk
>> 	then
>> 		apk add git
>> 	elif command -v dnf
>> 	then
>> 		dnf -y install git
>> 	else
>> 		apt-get -q -y install git
>> 	fi
> 
> OK.  "command -v" should be portable enough these days (in the past
> people used "type" and yelled at by portability sherriff).  And
> having one command line per package manager should be simpler than
> having one command line per distro, provided if two distros that
> share the same package manager name the "git" package the same way.
> We had trouble with "awk" recently ;-)

Oh, I'd not thought that different distributions might have different 
package names for git. We already have a few uses of "command -v" in our 
tests and ci scripts so I don't think using it here should be an issue.

> Curious that we do not check the availability of apt-get here (or
> just "apt").
It is a lazy way of erroring out if we add a new image that uses a 
different package manager to the matrix and forget to update the list 
here. We could instead check for apt-get and add an else clause that 
prints a proper message.

Best Wishes

Phillip

>> The commands above omit anything that updates the package cache as we
>> do that anyway in install-dependencies.sh and we only really care
>> about getting some version of git installed here. It also uses apt-get
>> to match what we do in install-dependencies.sh
> 
> OK.