[pacman-dev] [PATCH] Provide a better guess about who the packager is.

Eli Schwartz eschwartz93 at gmail.com
Wed Feb 1 00:46:52 UTC 2017

On 01/31/2017 05:10 PM, Kieran Colford wrote:
> The system usually has enough information in various places to guess
> the name and email of the person running the makepkg script. Use these
> instead of defaulting to "Unknown Packager" to minimize configuration
> necessary by the user.  This particular implemenation should provide
> relatively good guess that's compatible with other programs
> (i.e. git).
> Signed-off-by: Kieran Colford <kieran at kcolford.com>
> ---
>  scripts/makepkg.sh.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 29408929..65114862 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -618,7 +618,7 @@ write_pkginfo() {
>  	if [[ -n $PACKAGER ]]; then
>  		local packager="$PACKAGER"
>  	else
> -		local packager="Unknown Packager"
> +		local packager="${NAME:-$(getent passwd ${USER:-$(whoami)} | cut -d : -f 5 | cut -d , -f 1)} <${EMAIL:-${USER:-$(whoami)}@$(hostname --fqdn)}>"

What happens when someone initially created their user without making
use of the "useradd --comment" option? I know I didn't bother...
Do you have a fallback for when that is empty?

More: what about building in a clean chroot? This will invariably
produce nothing but "bash: hostname: command not found" on stderr. (But
the "$NAME" would evaluate to "builduser" anyway. I am not entirely sure
why that field is even filled out with that much in the first place, but
that is another matter entirely...)

That would be because "hostname" is provided by inetutils, which is not
installed as part of base-devel.

Warning: Personal opinion follows.
I personally dislike its useless output of "localhost.localdomain" too,
even when git uses that. (I would much prefer using the local machine
name at least, available through e.g. uname -n which is at least
guaranteed available as part of coreutils, besides being 100% more
distinctive for the average home system.)

>  	fi
>  	local size="$(@DUPATH@ @DUFLAGS@)"

Trying to scrape information from the OS in order to get better defaults
is not a terrible idea, but getting rid of any fallback whatsoever in
the process doesn't strike me as useful.

I also think everyone, without exception, should be configuring their
makepkg.conf to provide an *actual* email, rather than falling back to
the machine name. For the same reason that git users should do so (and
git redeems itself by verbosely warning you every time you rely on that
autodetected value). Unless of course they simply don't care about that
field, in which case we can probably use "flbkoaasdfklpopefevq" instead
of "Unknown Packager", and they'd never notice the difference.
Though as I have no actual power here, I probably cannot get *that*
enforced. :(

Eli Schwartz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20170131/5bdfa774/attachment.asc>

More information about the pacman-dev mailing list