SOURCES: rpm.macros - add _clean_env with _preserve_env support

sparky sparky at pld-linux.org
Sun Nov 23 19:54:12 CET 2008


Author: sparky                       Date: Sun Nov 23 18:54:12 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- add _clean_env with _preserve_env support

---- Files affected:
SOURCES:
   rpm.macros (1.494 -> 1.495) 

---- Diffs:

================================================================
Index: SOURCES/rpm.macros
diff -u SOURCES/rpm.macros:1.494 SOURCES/rpm.macros:1.495
--- SOURCES/rpm.macros:1.494	Thu Nov 13 21:13:03 2008
+++ SOURCES/rpm.macros	Sun Nov 23 19:54:07 2008
@@ -122,6 +122,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; \
  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/rpm.macros?r1=1.494&r2=1.495&f=u



More information about the pld-cvs-commit mailing list