[pacman-dev] [PATCH v2] makepkg: Respect XDG_CONFIG_HOME

Johannes Löthberg johannes at kyriasis.com
Wed Jul 2 11:04:13 EDT 2014

Add support for following the XDG Base Directory Specification when
reading the user-specific configuration file.

If no $XDG_CONFIG_HOME/pacman/makepkg.conf file exists we fall back to
sourcing $HOME/.makepkg.conf

Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
Was unsure if you wanted me to remove the variable or not, but it looked quite 
messy when I removed it so kept it in. Can re-send if you do want me to remove 

 doc/makepkg.conf.5.txt | 4 ++--
 scripts/makepkg.sh.in  | 9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index b15f026..dade39a 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -11,7 +11,7 @@ makepkg.conf - makepkg configuration file
-{sysconfdir}/makepkg.conf, ~/.makepkg.conf
+{sysconfdir}/makepkg.conf, $XDG_CONFIG_HOME/pacman/makepkg.conf, ~/.makepkg.conf
@@ -27,7 +27,7 @@ variables. Some of them are non-standard.
 The system-wide configuration file is found in {sysconfdir}/makepkg.conf.
 Individual options can be overridden (or added to) on a per-user basis in
+$XDG_CONFIG_HOME/pacman/makepkg.conf or ~/.makepkg.conf.
 The default file is fairly well commented, so it may be easiest to simply
 follow directions given there for customization.
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index e20b707..089e92d 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2788,8 +2788,13 @@ fi
 # Source user-specific makepkg.conf overrides, but only if no override config
 # file was specified
-if [[ $MAKEPKG_CONF = "$confdir/makepkg.conf" && -r ~/.makepkg.conf ]]; then
-	source_safe ~/.makepkg.conf
+if [[ "$MAKEPKG_CONF" = "$confdir/makepkg.conf" ]]; then
+	if [[ -r "$XDG_PACMAN_DIR/makepkg.conf" ]]; then
+		source_safe "$XDG_PACMAN_DIR/makepkg.conf"
+	elif [[ -r "$HOME/.makepkg.conf" ]]; then
+		source_safe "$HOME/.makepkg.conf"
+	fi
 # set pacman command if not already defined

More information about the pacman-dev mailing list