[PATCH v2 2/2] buildscript: support to choose the build variant

Tim Niemeyer tim at tn-x.org
So Feb 3 14:06:08 CET 2019


Signed-off-by: Tim Niemeyer <tim at tn-x.org>
Reviewed-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---

Changes in v2: None
Changes in v1:
- First version of this patch

 .gitignore                             |  1 +
 buildscript                            | 40 +++++++++++++++++++++++++++++++++-
 src/packages/fff/fff/Makefile          |  3 ++-
 src/packages/fff/fff/variant-layer3.mk | 15 +++++++++++++
 src/packages/fff/fff/variant-node.mk   | 15 +++++++++++++
 5 files changed, 72 insertions(+), 2 deletions(-)
 create mode 100644 src/packages/fff/fff/variant-layer3.mk
 create mode 100644 src/packages/fff/fff/variant-node.mk

diff --git a/.gitignore b/.gitignore
index 6fe0300..56d60b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 /selected_bsp
 /selected_community
+/selected_variant
 /build
 /bin*
 /src/dl
diff --git a/buildscript b/buildscript
index 3d5cefd..06edf17 100755
--- a/buildscript
+++ b/buildscript
@@ -140,6 +140,11 @@ prepare() {
 
     patch_target
 
+    # set the variant for this build
+    cp "./src/packages/fff/fff/variant-$(cat selected_variant).mk" "$target"/variant.mk
+    # force the reevaluation of this Makefile to make note of the new variant
+    touch ./src/packages/fff/fff/Makefile
+
     ## generate own feeds.conf
     #this local variable should be globally configure variable used in get_source and here
     local PACKAGEBASE=${PWD}/src/packages
@@ -344,6 +349,16 @@ loadBSP()
     . selected_bsp
 }
 
+loadVariant()
+{
+    echo "Working with build variant \"$(cat selected_variant)\""
+}
+
+setVariant()
+{
+    echo "$1" > selected_variant
+}
+
 setBSP()
 {
     /bin/rm -rf selected_bsp
@@ -364,13 +379,19 @@ if [ "$(/usr/bin/id -u)" -eq 0 ]; then
 	exit 1
 fi
 
-if [ "$1" != "selectbsp" ]; then
+if [ "$1" != "selectbsp" -a "$1" != "selectvariant" ]; then
     if [ ! -h selected_bsp ]; then
         echo "Please select a Board-Support-Package using:"
         echo "$0 selectbsp"
         exit
     fi
+    if [ ! -f selected_variant ]; then
+        echo "Please select a build variant using:"
+        echo "$0 selectvariant"
+        exit
+    fi
     loadBSP
+    loadVariant
     echo
 fi
 
@@ -391,6 +412,22 @@ case "$1" in
             fi
         fi
         ;;
+    "selectvariant")
+        if [ "$2" = "help" ] || [ "$2" = "" ]; then
+            echo "Select a build varaint:"
+            echo
+            echo "Usage: $0 $1 <name of variant>"
+            echo "available variants: "
+            /bin/ls src/packages/fff/fff/variant-*.mk | sed 's#.*/variant-\(.*\)\.mk#\1#g'
+            echo
+        else
+            if [ ! -f "src/packages/fff/fff/variant-$2.mk" ]; then
+                echo "Could not find variant $2"
+            else
+                setVariant $2
+            fi
+        fi
+        ;;
     "prepare")
         if [ "$2" = "help" ] || [ "$2" = "x" ]; then
             echo "This option fetches the sources for the images and configurates the build so that it can be compiled"
@@ -462,6 +499,7 @@ case "$1" in
         echo "Usage: $0 command"
         echo "command:"
         echo "  selectbsp <bsp-file>"
+        echo "  selectvariant <name of variant>"
         echo "  prepare"
         echo "  config openwrt"
         echo "  build [fast|debug]"
diff --git a/src/packages/fff/fff/Makefile b/src/packages/fff/fff/Makefile
index fd63433..9749ddc 100644
--- a/src/packages/fff/fff/Makefile
+++ b/src/packages/fff/fff/Makefile
@@ -35,7 +35,6 @@ endef
 
 define Package/fff-node
     $(call Package/fff/base)
-    DEFAULT:=y
     TITLE+=(Home node)
     DEPENDS+=+fff-fastd \
              +fff-firewall \
@@ -76,3 +75,5 @@ endef
 
 $(eval $(call BuildPackage,fff-node))
 $(eval $(call BuildPackage,fff-layer3))
+
+include $(TOPDIR)/variant.mk
diff --git a/src/packages/fff/fff/variant-layer3.mk b/src/packages/fff/fff/variant-layer3.mk
new file mode 100644
index 0000000..fb6dbc7
--- /dev/null
+++ b/src/packages/fff/fff/variant-layer3.mk
@@ -0,0 +1,15 @@
+define Package/fff-default
+    SECTION:=base
+    CATEGORY:=Freifunk
+    DEFAULT:=y
+    TITLE:=Freifunk-Franken Base default switcher
+    URL:=http://www.freifunk-franken.de
+    DEPENDS:=+fff-layer3
+endef
+
+define Package/fff-default/description
+    This package is used to switch on of the Freifunk Franken
+    package on per default
+endef
+
+$(eval $(call BuildPackage,fff-default))
diff --git a/src/packages/fff/fff/variant-node.mk b/src/packages/fff/fff/variant-node.mk
new file mode 100644
index 0000000..11b9734
--- /dev/null
+++ b/src/packages/fff/fff/variant-node.mk
@@ -0,0 +1,15 @@
+define Package/fff-default
+    SECTION:=base
+    CATEGORY:=Freifunk
+    DEFAULT:=y
+    TITLE:=Freifunk-Franken Base default switcher
+    URL:=http://www.freifunk-franken.de
+    DEPENDS:=+fff-node
+endef
+
+define Package/fff-default/description
+    This package is used to switch on of the Freifunk Franken
+    package on per default
+endef
+
+$(eval $(call BuildPackage,fff-default))
-- 
2.11.0



Mehr Informationen über die Mailingliste franken-dev