[pacman-dev] [PATCH v2] makepkg: Respect XDG_CONFIG_HOME
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@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 it. 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 Synopsis -------- -{sysconfdir}/makepkg.conf, ~/.makepkg.conf +{sysconfdir}/makepkg.conf, $XDG_CONFIG_HOME/pacman/makepkg.conf, ~/.makepkg.conf Description @@ -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 -~/.makepkg.conf. +$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 +XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman" +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 fi # set pacman command if not already defined -- 2.0.1
At Wed, 2 Jul 2014 17:04:13 +0200, Johannes Löthberg wrote:
If no $XDG_CONFIG_HOME/pacman/makepkg.conf file exists we fall back to sourcing $HOME/.makepkg.conf
# 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 +XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman" +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 fi
Is "falling back" the right thing? My gut sort of tells me that if they both exist, they should both be loaded, but that's just me. Happy hacking, ~ Luke Shumaker
On 06/07/14 08:33, Luke Shumaker wrote:
At Wed, 2 Jul 2014 17:04:13 +0200, Johannes Löthberg wrote:
If no $XDG_CONFIG_HOME/pacman/makepkg.conf file exists we fall back to sourcing $HOME/.makepkg.conf
# 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 +XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman" +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 fi
Is "falling back" the right thing? My gut sort of tells me that if they both exist, they should both be loaded, but that's just me.
By the looks of the who XDG crap specification, there are other directories defined and these are supposed to be on order. So I'm happy with the XDG_CONFIG_HOME file taking priority and will document that. Allan
On 03/07/14 01:04, Johannes Löthberg wrote:
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@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 it.
I don't really care. Pulled to my branch with minor change indicated below.
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
Synopsis -------- -{sysconfdir}/makepkg.conf, ~/.makepkg.conf +{sysconfdir}/makepkg.conf, $XDG_CONFIG_HOME/pacman/makepkg.conf, ~/.makepkg.conf
Description @@ -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 -~/.makepkg.conf. +$XDG_CONFIG_HOME/pacman/makepkg.conf or ~/.makepkg.conf.
Added ", with the former taking priority." Thanks, Allan
participants (3)
-
Allan McRae
-
Johannes Löthberg
-
Luke Shumaker