I would have added better defaults for when getent returns nothing for us to use, but my bash skills aren't up to par for that. I would love to get a better fallback for that. Currently it will just give a blank if you didn't set your full name in /etc/passwd I also didn't realize the hostname command wasn't included in base-devel. It didn't even occur to me to not have it. I can further fallback on uname -n like you suggested or even echo localhost A system configured according to the wiki will give even more distinctive and useful information with hostname --fqdn than it will with just uname -n, so I would keep it as the default and fallback to uname if it doesn't work. The On Tue, Jan 31, 2017, 7:47 PM Eli Schwartz, <eschwartz93@gmail.com> wrote:
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@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
--
Signed, Kieran Colford