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 <freifunk@adrianschmutzler.de>
Tested-by: Robert Langhammer <rlanghammer@web.de>
Reviewed-by: Robert Langhammer <rlanghammer@web.de>
This commit is contained in:
Adrian Schmutzler 2021-01-30 20:17:08 +01:00
parent 31866435a1
commit 1946aaca87
4 changed files with 49 additions and 58 deletions

View File

@ -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 <name of variant>"
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

View File

@ -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))

View File

@ -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))

View File

@ -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))