[pacman-dev] [RFC] makepkg: allow make-style environment var overrides

Allan McRae allan at archlinux.org
Wed Jul 24 01:34:43 EDT 2013


On 24/07/13 03:18, Dave Reisner wrote:
> Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> ---
> Curious if folks think this is useful -- can definitely see myself using this
> now and then. It's different than prefixing makepkg with variables because of
> the order of evaluation. Prefixed vars are still subject to being overriden by
> config files because said file are sourced after the environment is parsed.
> This patch adds the variables as late as possible to give them the best chance
> in life of taking effect.

I'm going to reply here as well as on IRC because I really want all
pacman development discussion to be recorded here...

I was confused by the description above including configuration files
and was thinking this was for things like PKGDEST etc.

The example Dave gave on IRC is:
  makepkg CC=clang

which sounds perfectly fine to me.

Saying that, who has CC= defined in their makepkg.conf file?

Allan

>  scripts/makepkg.sh.in | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 06f7c25..0cf55a4 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -2624,6 +2624,15 @@ while true; do
>  	shift
>  done
>  
> +# attempt to parse any extra args (after the end-of-options delimiter) as
> +# environment vars.
> +while [[ $1 ]]; do
> +	if [[ $1 = ?(_[[:alpha:]])+([[:alnum:]_])=* ]]; then
> +		extra_env_vars+=("$1")
> +	fi
> +	shift
> +done
> +
>  # setup signal traps
>  trap 'clean_up' 0
>  for signal in TERM HUP QUIT; do
> @@ -2706,6 +2715,11 @@ if [[ ! -w $BUILDDIR ]]; then
>  	exit 1
>  fi
>  
> +# override settings from extra variables on commandline, if any
> +if (( ${#extra_env_vars[*]} )); then
> +	declare -x "${extra_env_vars[@]}"
> +fi
> +
>  PKGDEST=${_PKGDEST:-$PKGDEST}
>  PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
>  if (( ! (NOBUILD || GENINTEG) )) && [[ ! -w $PKGDEST ]]; then
> 



More information about the pacman-dev mailing list