sereference: Makefile changes
Subsystems (2)
PATCH 1/1 sereference: Makefile changes
The attached patch makes it possible to change the on-off-module state of policy from the command line at build time. Rather then maintaining separate modules.conf for various similar builds, one can maintain a common modules.conf and tweak it when running make.
For example:
$make clean
$APPS_OFF="gpg" make
This will generate a policy without the gpg module. The options are APPS_OFF, APPS_ON, and APPS_MODS.
Thanks,
Spencer
Signature · 4 lines
Spencer Shimko Tresys Technology, LLC (410) 290 - 1411 ext. 125 [email protected]
Makefile +10 -2
@@ -165,9 +165,17 @@ # modules.conf setting for unused module MODUNUSED := off +# test for additional module configuration information from command line and check for confusing input +MOD_TEST = $(foreach var, $(APPS_OFF), $(findstring $(var), $(APPS_ON) $(APPS_MODS))) +MOD_TEST += $(foreach var, $(APPS_MODS), $(findstring $(var), $(APPS_ON))) +ifneq ($(strip $(MOD_TEST)),) + $(error Applications must be on, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!) +endif + # extract settings from modules.conf -BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)) -MOD_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)) +# strip out all additional module configuration information from command line, then add back in to avoid dupes +BASE_MODS := $(strip $(filter-out $(strip $(APPS_OFF) $(APPS_MODS) $(APPS_ON)), $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)))) $(addsuffix .te,$(APPS_ON)) +MOD_MODS := $(strip $(addsuffix .te, $(filter-out $(strip $(APPS_OFF) $(APPS_MODS) $(APPS_ON)), $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)))) $(addsuffix .te,$(APPS_MODS)) OFF_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null)) ########################################
Quoted 9 lines · Spencer Shimko
The attached patch makes it possible to change the on-off-module state of policy from the command line at build time. Rather then maintaining separate modules.conf for various similar builds, one can maintain a common modules.conf and tweak it when running make.
diff -urN refpolicy-old/Makefile refpolicy-new/Makefile
Makefile 2006-01-12 14:10:03.000000000 -0500 line 173
Quoted 9 lines
Makefile 2006-01-12 14:10:03.000000000 -0500 renamed from Makefile 2006-01-12 11:07:59.000000000 -0500 +6
-0@@ -165,9 +165,17 @@ # modules.conf setting for unused module MODUNUSED := off +# test for additional module configuration information from command line and check for confusing input +MOD_TEST = $(foreach var, $(APPS_OFF), $(findstring $(var), $(APPS_ON) $(APPS_MODS))) +MOD_TEST += $(foreach var, $(APPS_MODS), $(findstring $(var), $(APPS_ON))) +ifneq ($(strip $(MOD_TEST)),) + $(error Applications must be on, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!) +endif
I believe using filter instead of foreach+findstring will simplify the above part, since it returns the words in the text (APPS_ON and APPS_MODS) that match any of the words in the pattern (APPS_OFF).
Makefile 2006-01-12 14:10:03.000000000 -0500 line 179
Quoted 8 lines
Makefile 2006-01-12 14:10:03.000000000 -0500 renamed from Makefile 2006-01-12 11:07:59.000000000 -0500 +3
-2# extract settings from modules.conf -BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)) -MOD_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)) +# strip out all additional module configuration information from command line, then add back in to avoid dupes +BASE_MODS := $(strip $(filter-out $(strip $(APPS_OFF) $(APPS_MODS) $(APPS_ON)), $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)))) $(addsuffix .te,$(APPS_ON)) +MOD_MODS := $(strip $(addsuffix .te, $(filter-out $(strip $(APPS_OFF) $(APPS_MODS) $(APPS_ON)), $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)))) $(addsuffix .te,$(APPS_MODS)) OFF_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null))
Using sort might simplify this, as it removes duplicates, in addition to sorting the list.
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.