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

Allan McRae allan at archlinux.org
Wed Jul 2 00:40:02 EDT 2014


On 02/07/14 02:01, 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 at kyriasis.com>
> ---
>  doc/makepkg.conf.5.txt | 4 ++--
>  scripts/makepkg.sh.in  | 7 +++++--
>  2 files changed, 7 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..f06cd6d 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -2788,8 +2788,11 @@ 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" && -r "$XDG_PACMAN_DIR/makepkg.conf" ]]
> +	source_safe "$XDG_PACMAN_DIR/makepkg.conf"
> +elif [[ $MAKEPKG_CONF = "$confdir/makepkg.conf" && -r "$HOME/.makepkg.conf" ]]; then
> +	source_safe "$HOME/.makepkg.conf"
>  fi
>  

Can we nest this?

if [[ $MAKEPKG_CONF = "$confdir/makepkg.conf"]]; then
	if [[ -r ${XDG_CONFIG_HOME:-$HOME/.config}/pacman/.makepkg.conf




More information about the pacman-dev mailing list