Simplify firmware variant selection

Instead of tampering with the 'DEFAULT' property of meta packages on
every build in a non-portable way, use the build system as intended and
select packages using an approriate build config ('.config').

This is achived by adding the approriate variant package to the build
config before expanding it using defconfig.

By that, the fff-variant-* packages and FFF_VARIANT environment variable
can be removed. Base packages required in both variants are now included
via fff-base (formerly fff-variant/default).

Besides cleaning up the build process, this change also fixes a recent
issue with build dependencies, as they are evaluated on a per-package
basis instead of per-variant. Due to that, dependencies of all
variants are compiled, regardless of the selected variant. Combined with
a recent build issue of mosquitto (see [1]), the node variant could not
be built from a clean state.

[1] https://github.com/eclipse/mosquitto/issues/2432

Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Fabian Bläse 2022-03-26 16:01:31 +01:00
parent 7a5bef0d7d
commit f89503660d
3 changed files with 37 additions and 69 deletions

View File

@ -126,20 +126,9 @@ prepare() {
patch_target
# apply variant to ensure the included file "variant.mk"
# exists in builddir.
apply_variant
update_feeds
}
apply_variant() {
# set the variant for this build
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
}
update_feeds() {
## generate own feeds.conf
#this local variable should be globally configure variable used in get_source and here
@ -174,8 +163,6 @@ update_feeds() {
}
prebuild() {
apply_variant
#create filesdir for our config
/bin/rm -rf "$builddir"/files
mkdir "$builddir"/files
@ -193,6 +180,9 @@ prebuild() {
version="$variant-$version"
fi
# select variant packages
echo "CONFIG_PACKAGE_fff-${variant}=y" >> "$builddir"/.config
{
echo "FIRMWARE_VERSION=\"$version\""
echo "VARIANT=\"$variant\""

View File

@ -0,0 +1,34 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-base
PKG_RELEASE:=$(COMMITCOUNT)
include $(INCLUDE_DIR)/package.mk
define Package/fff-base
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken base dependencies
URL:=https://www.freifunk-franken.de
DEFAULT:=y
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-variant/description
This package includes base packages used in the Freifunk-Franken firmware
endef
$(eval $(call BuildPackage,fff-base))

View File

@ -1,56 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff
PKG_RELEASE:=$(COMMITCOUNT)
include $(INCLUDE_DIR)/package.mk
define Package/fff-variant/default
SECTION:=base
CATEGORY:=Freifunk
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-variant/default/description
This package is used to switch one of the variants on by default
endef
define Package/fff-variant-layer3
$(Package/fff-variant/default)
TITLE:=Freifunk-Franken Layer3 Variant
DEPENDS+=+fff-layer3
VARIANT:=layer3
endef
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))