From: sparky Date: Sun, 23 Nov 2008 18:54:07 +0000 (+0000) Subject: - add _clean_env with _preserve_env support X-Git-Tag: auto/th/rpm-build-macros-1_498-1~6 X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm.git;a=commitdiff_plain;h=267cb3a3fa701384c4723941dae03d499794f652 - add _clean_env with _preserve_env support Changed files: rpm.macros -> 1.495 --- 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; \