Re: [pacman-dev] [PATCH v2] Provide a better guess about who the packager is.
On Thu, Feb 02, 2017 at 02:39:21AM +1000, Allan McRae wrote: > On 02/02/17 01:59, 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. 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> > This will not be included in makepkg. Any "guessing" will inevitably be > wrong at some stage and we will have more and more fixes requested on > top of this. Perhaps we should bail if PACKAGER isn't set, then. > We have a single place to configure this information. That is enough. > > Allan
Re: [pacman-dev] [PATCH v2] Provide a better guess about who the packager is.
On 02/02/17 01:59, 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. 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 ColfordThis will not be included in makepkg. Any "guessing" will inevitably be wrong at some stage and we will have more and more fixes requested on top of this. We have a single place to configure this information. That is enough. Allan
[pacman-dev] [PATCH v2] Provide a better guess about who the packager is.
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--- 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