libmakepkg: Use only /etc/makepkg.d/gitconfig

Globally set `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` so that we're
only loading `/etc/makepkg.d/gitconfig` (if it exists) and no other Git
config files.

Allow injecting another value via `MAKEPKG_GIT_CONFIG`.

Fixes: https://gitlab.archlinux.org/pacman/pacman/-/issues/193
This commit is contained in:
Jan Alexander Steffens (heftig) 2025-03-19 21:14:51 +01:00
parent 34f09204fa
commit f07d547cf1
No known key found for this signature in database
GPG key ID: B8AC08600F108CDF
3 changed files with 10 additions and 1 deletions

View file

@ -247,6 +247,11 @@ Environment Variables
Use an alternate config file instead of the +{sysconfdir}/makepkg.conf+
default.
**MAKEPKG_GIT_CONFIG=**"/path/to/file"::
Use an alternate config file for Git instead of the
+{sysconfdir}/makepkg.d/gitconfig+ default. makepkg always prevents Git
from loading any other config files.
**PKGDEST=**"/path/to/directory"::
Directory where the resulting packages will be stored. Overrides the
corresponding value defined in linkman:makepkg.conf[5].

View file

@ -433,6 +433,8 @@ configure_file(
configuration : substs,
install_dir : join_paths(SYSCONFDIR, 'makepkg.conf.d/'))
install_emptydir(join_paths(SYSCONFDIR, 'makepkg.d/'))
configure_file(
input : 'etc/pacman.conf.in',
output : 'pacman.conf',

View file

@ -28,6 +28,8 @@ source "$MAKEPKG_LIBRARY/util/error.sh"
source "$MAKEPKG_LIBRARY/util/message.sh"
source "$MAKEPKG_LIBRARY/util/pkgbuild.sh"
export GIT_CONFIG_GLOBAL=/dev/null
export GIT_CONFIG_SYSTEM=${MAKEPKG_GIT_CONFIG:-'@sysconfdir@/makepkg.d/gitconfig'}
download_git() {
# abort early if parent says not to fetch
@ -161,7 +163,7 @@ calc_checksum_git() {
case ${fragment%%=*} in
tag|commit)
fragval=${fragment##*=}
sum=$(GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null git -c core.abbrev=no -C "$dir" archive --format tar "$fragval" | "${integ}sum" 2>&1) || ret=1
sum=$(git -c core.abbrev=no -C "$dir" archive --format tar "$fragval" | "${integ}sum" 2>&1) || ret=1
sum="${sum%% *}"
;;
*)