The system usually has enough information in various places to guess the name and email of the person running the makepkg script. We can use this to make the defaults more intelligent. This particular implemenation should provide relatively good guess that's compatible with other programs (i.e. git). Signed-off-by: Kieran Colford <kieran@kcolford.com> --- scripts/makepkg.sh.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 29408929..b2a0b89a 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -613,12 +613,22 @@ write_kv_pair() { done } +default_packager() { + local user="${USER:-$(whoami)}" + # Try to find the user's real name is in the environment or + # the passwd databse. + local name="${NAME:-$(getent passwd "${user}" | cut -d : -f 5 | cut -d , -f 1)}" + # Try to find the user's email in the environment only. + local email="${EMAIL}" + echo "${name:-Unknown Packager}${email:+ <${email}>}" +} + write_pkginfo() { local builddate=$(date -u "+%s") if [[ -n $PACKAGER ]]; then local packager="$PACKAGER" else - local packager="Unknown Packager" + local packager="$(default_packager)" fi local size="$(@DUPATH@ @DUFLAGS@)" -- 2.11.0