From 267cb3a3fa701384c4723941dae03d499794f652 Mon Sep 17 00:00:00 2001 From: sparky Date: Sun, 23 Nov 2008 18:54:07 +0000 Subject: [PATCH] - add _clean_env with _preserve_env support Changed files: rpm.macros -> 1.495 --- rpm.macros | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rpm.macros b/rpm.macros index 62a2b46..b334e6d 100644 --- a/rpm.macros +++ b/rpm.macros @@ -121,6 +121,30 @@ }; }') +#----------------------------------------------------------------- +# +# Generate a command which cleans environment, leaving only the +# most important variables. +# If any spec requires any additional environment it should +# redefine %_preserve_env in following manner: +# +# # ADDITIONAL_VAR is required because [a good reason here] +# %{expand:%%define _preserve_env %_preserve_env ADDITIONAL_VAR} + +%_preserve_env HOME TMP TMPDIR + +%_clean_env env -i %(awk 'BEGIN { + split("%{?_preserve_env:%_preserve_env}",P); + for ( i in P ) { + p = P[ i ]; + if ( ENVIRON[ p ] ) { + val = ENVIRON[ p ]; + gsub( /[\\\\"$`]/, "\\\\\\&", val ); + printf( "\\"" p "=" val "\\" "); + } + } +}') + #----------------------------------------------------------------- %configure2_13 { \ if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \ -- 2.43.0