From 1946aaca878fafc11d832682790731ba46b0b6b6 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Sat, 30 Jan 2021 20:17:08 +0100 Subject: [PATCH] fff: create proper package variants instead of copying file So far, we ensure the selection of a specific variant by copying included Make files. This not only breaks if the packages are used as a feed, but also is against the concept of how packages are used. In this patch, the fff package is converted into a set of variants that allow selection via a FFF_VARIANT variable that is exported by buildscript. If no export happens, e.g. when using packages in a feed, no package is selected. Since the names fff-node and fff-layer3 are not available anymore, the packages for the variants are called (though irrelevant for the user): * fff-variant-layer3 * fff-variant-node The only drawback is that we now have to specify the list of available variants in the buildscript. However, these values are hardcoded in several other places as well, and the former code based on file names was not really appealing anyway. Signed-off-by: Adrian Schmutzler Tested-by: Robert Langhammer Reviewed-by: Robert Langhammer --- buildscript | 11 +++-- src/packages/fff/fff/Makefile | 64 +++++++++++++++++--------- src/packages/fff/fff/variant-layer3.mk | 16 ------- src/packages/fff/fff/variant-node.mk | 16 ------- 4 files changed, 49 insertions(+), 58 deletions(-) delete mode 100644 src/packages/fff/fff/variant-layer3.mk delete mode 100644 src/packages/fff/fff/variant-node.mk diff --git a/buildscript b/buildscript index f7889e92..030d043c 100755 --- a/buildscript +++ b/buildscript @@ -25,6 +25,8 @@ OPENWRT_PKGS="gpioctl-sysfs libugpio fastd haserl micrond mtr bmon" ROUTING_PKGS="kmod-batman-adv batctl alfred babeld" GLUON_PKGS="simple-tc uradvd" +FFF_VARIANTS="node layer3" + OPENWRTURL="https://git.openwrt.org/openwrt/openwrt.git" ## Feed definition [0]: name aka directory, [1]: url, [2]: revision @@ -149,7 +151,7 @@ prepare() { apply_variant() { # set the variant for this build - cp "./src/packages/fff/fff/variant-$(cat selected_variant).mk" "$builddir"/variant.mk + export FFF_VARIANT=$(cat selected_variant) # force the reevaluation of this Makefile to make note of the new variant touch ./src/packages/fff/fff/Makefile } @@ -441,14 +443,13 @@ case "$1" in ;; "selectvariant") if [ "$2" = "help" ] || [ "$2" = "" ]; then - echo "Select a build varaint:" + echo "Select a build variant:" echo echo "Usage: $0 $1 " - echo "available variants: " - /bin/ls src/packages/fff/fff/variant-*.mk | sed 's#.*/variant-\(.*\)\.mk#\1#g' + echo "available variants: $FFF_VARIANTS" echo else - if [ ! -f "src/packages/fff/fff/variant-$2.mk" ]; then + if ! echo "$FFF_VARIANTS" | grep -q "\b$2\b"; then echo "Could not find variant $2" else setVariant $2 diff --git a/src/packages/fff/fff/Makefile b/src/packages/fff/fff/Makefile index b2549294..3dae0384 100644 --- a/src/packages/fff/fff/Makefile +++ b/src/packages/fff/fff/Makefile @@ -1,34 +1,56 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff -PKG_RELEASE:=8 +PKG_RELEASE:=9 include $(INCLUDE_DIR)/package.mk -define Package/fff-base +define Package/fff-variant/default SECTION:=base CATEGORY:=Freifunk - TITLE:=Freifunk-Franken Base - URL:=http://www.freifunk-franken.de - DEPENDS:=+iptables \ - +ip6tables \ - +odhcp6c \ - +micrond \ - +fff-config \ - +fff-nodewatcher \ - +fff-web-ui \ - +fff-support \ - +fff-network \ - +fff-sysupgrade \ - +fff-wireless \ - +fff-timeserver \ - +fff-simple-tc + URL:=https://www.freifunk-franken.de + DEFAULT:=$(if $(filter fff-variant-$(FFF_VARIANT),$(1)),y,n) + DEPENDS:= \ + +iptables \ + +ip6tables \ + +micrond \ + +odhcp6c \ + +fff-config \ + +fff-network \ + +fff-nodewatcher \ + +fff-simple-tc \ + +fff-support \ + +fff-sysupgrade \ + +fff-timeserver \ + +fff-web-ui \ + +fff-wireless endef -define Package/fff-base/description - This is the Freifunk Franken Firmware Base package +define Package/fff-variant/default/description + This package is used to switch one of the variants on by default endef -$(eval $(call BuildPackage,fff-base)) +define Package/fff-variant-layer3 + $(Package/fff-variant/default) + TITLE:=Freifunk-Franken Layer3 Variant + DEPENDS+=+fff-layer3 + VARIANT:=layer3 +endef -include $(TOPDIR)/variant.mk +define Package/fff-variant-layer3/description + $(Package/fff-variant/default/description) +endef + +define Package/fff-variant-node + $(Package/fff-variant/default) + TITLE:=Freifunk-Franken Node Variant + DEPENDS+=+fff-node + VARIANT:=node +endef + +define Package/fff-variant-node/description + $(Package/fff-variant/default/description) +endef + +$(eval $(call BuildPackage,fff-variant-layer3)) +$(eval $(call BuildPackage,fff-variant-node)) diff --git a/src/packages/fff/fff/variant-layer3.mk b/src/packages/fff/fff/variant-layer3.mk deleted file mode 100644 index 51b99923..00000000 --- a/src/packages/fff/fff/variant-layer3.mk +++ /dev/null @@ -1,16 +0,0 @@ -define Package/fff-default - SECTION:=base - CATEGORY:=Freifunk - DEFAULT:=y - TITLE:=Freifunk-Franken Base default switcher - URL:=http://www.freifunk-franken.de - DEPENDS:=+fff-base +fff-layer3 - VARIANT:=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 deleted file mode 100644 index 8c238218..00000000 --- a/src/packages/fff/fff/variant-node.mk +++ /dev/null @@ -1,16 +0,0 @@ -define Package/fff-default - SECTION:=base - CATEGORY:=Freifunk - DEFAULT:=y - TITLE:=Freifunk-Franken Base default switcher - URL:=http://www.freifunk-franken.de - DEPENDS:=+fff-base +fff-node - VARIANT:=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))