commit ee446b027adc62c9217b95d6cd8f2fc529fe13cb
Author: Jorge L. Florit <jlflorit@gmail.com>
Date:   Tue Jan 7 01:53:13 2014 +0000

    Add script to select additional packages only in compile time

diff --git a/Makefile b/Makefile
index 211269b..5add1a4 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,9 @@ MY_CONFIGS = $(BUILD_DIR)/configs
 IMAGES = images
 SHELL = bash
 QMP_FEED = package/feeds/qmp_packages
-COMMUNITY ?= qMp
 SCRIPTS_DIR= scripts
+COMMUNITY ?= qMp
+EXTRA_PACKS =
 J ?= 1
 V ?= 0
 T =
@@ -138,7 +139,7 @@ define kmenuconfig_owrt
 endef
 
 define pre_build
-	$(foreach SCRIPT, $(wildcard $(SCRIPTS_DIR)/*.script), $(shell $(SCRIPT) PRE_BUILD $(TBUILD) $(TARGET)) )
+	$(foreach SCRIPT, $(wildcard $(SCRIPTS_DIR)/*.script), $(shell $(SCRIPT) PRE_BUILD $(TBUILD) $(TARGET) $(EXTRA_PACKS)) )
 endef
 
 define post_build
@@ -154,7 +155,7 @@ define post_build
 	@[ -f $(IMAGES)/$(IM_NAME) ] || echo No output image configured in targets.mk
 	@echo $(IM_NAME)
 	$(if $(SYSUPGRADE),@echo $(SIM_NAME))
-	$(foreach SCRIPT, $(wildcard $(SCRIPTS_DIR)/*.script), $(shell $(SCRIPT) POST_BUILD $(TBUILD) $(TARGET)) )
+	$(foreach SCRIPT, $(wildcard $(SCRIPTS_DIR)/*.script), $(shell $(SCRIPT) POST_BUILD $(TBUILD) $(TARGET) $(EXTRA_PACKS)) )
 	@echo "qMp firmware compiled, you can find output files in $(IMAGES) directory."
 endef
 
diff --git a/nightlycompile.sh b/nightlycompile.sh
index 487c0c6..ed687cf 100755
--- a/nightlycompile.sh
+++ b/nightlycompile.sh
@@ -21,6 +21,10 @@ TARGETS=${TARGETS:-$(make list_targets)}
 # Targets which are not gonna be compiled
 NOTARGETS=${NOTARGETS:-}
 
+# Extra packages (separated by spaces)
+EXTRA_PACKS=${EXTRA_PACKS:-}
+
+
 # If FORCE is 1, compilation process will be forced
 [ -z "$FORCE" ] && FORCE=0
 
@@ -39,7 +43,7 @@ make update_all
 for t in $TARGETS; do
 	[[ "$NOTARGETS" =~ "$t" ]] && continue
 	echo "Compiling target $t"
-	nice -n 25 make T=$t build J=2 QMP_GIT_BRANCH=$BRANCH COMMUNITY=$COMMUNITY
+	nice -n 25 make T=$t build J=2 QMP_GIT_BRANCH=$BRANCH COMMUNITY=$COMMUNITY EXTRA_PACKS=$EXTRA_PACKS
 
 	[ $? -ne 0 ] && [ ! -z "$MAIL" ] && 
 	  echo "Error detected during QMP compilation process" | mail -s "[qMp] build system" $MAIL
diff --git a/scripts/extra-packages.script b/scripts/extra-packages.script
new file mode 100755
index 0000000..0dc2c7b
--- /dev/null
+++ b/scripts/extra-packages.script
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+PREPOST="$1"
+shift
+TBUILD="$1"
+shift
+shift
+EXTRA_PACKS="$@"
+FILE="build/$TBUILD/.config"
+[ -z "$TBUILD" ] || [ ! -d "build/$TBUILD" ] || [ -f "$FILE" ] && exit 1
+
+for i in $EXTRA_PACKS; do
+	[ "$PREPOST" = "PRE_BUILD" ] && AUX=$(grep $i $FILE) && sed -i -e s/"$AUX"/"CONFIG_PACKAGE_$i=y"/g $FILE	
+	[ "$PREPOST" = "POST_BUILD" ] && AUX=$(grep $i $FILE) && sed -i -e s/"$AUX"/"# CONFIG_PACKAGE_$i is not set"/g $FILE	
+done
+
