Skip to content

Commit

Permalink
Merge pull request freifunk-gluon#3054 from blocktrron/flexible-featu…
Browse files Browse the repository at this point in the history
…re-packages

build: implement flexible site-selection system
  • Loading branch information
blocktrron authored Dec 26, 2023
2 parents 683defd + 43aff41 commit db0e7bd
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 177 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ ifneq ($(GLUON_BRANCH),)
GLUON_AUTOUPDATER_ENABLED ?= 1
endif

ifneq ($(GLUON_FEATURES)$(GLUON_FEATURES_standard)$(GLUON_FEATURES_tiny),)
$(error *** Warning: GLUON_FEATURES has been obsolete, please use the image-customization.lua file instead.)
endif

ifneq ($(GLUON_SITE_PACKAGES)$(GLUON_SITE_PACKAGES_standard)$(GLUON_SITE_PACKAGES_tiny),)
$(error *** Warning: GLUON_SITE_PACKAGES has been obsolete, please use the image-customization.lua file instead.)
endif

GLUON_AUTOUPDATER_ENABLED ?= 0

# initialize (possibly already user set) directory variables
Expand Down
16 changes: 16 additions & 0 deletions contrib/ci/minimal-site/image-customization.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
features {
'autoupdater',
'ebtables-filter-multicast',
'ebtables-filter-ra-dhcp',
'ebtables-limit-arp',
'mesh-batman-adv-15',
'mesh-vpn-fastd',
'respondd',
'status-page',
'web-advanced',
'web-wizard',
}

if not device_class('tiny') then
features {'wireless-encryption-wpa3'}
end
20 changes: 20 additions & 0 deletions contrib/ci/olsr-site/image-customization.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
features {
'autoupdater',
'ebtables-filter-multicast',
'ebtables-filter-ra-dhcp',
'ebtables-limit-arp',
'mesh-olsrd',
'mesh-vpn-fastd',
'respondd',
'status-page',
'web-advanced',
'web-wizard',
}

packages {
'iwinfo',
}

if not device_class('tiny') then
features {'wireless-encryption-wpa3'}
end
28 changes: 0 additions & 28 deletions contrib/ci/olsr-site/site.mk
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
## gluon site.mk makefile example

## GLUON_FEATURES
# Specify Gluon features/packages to enable;
# Gluon will automatically enable a set of packages
# depending on the combination of features listed

GLUON_FEATURES := \
autoupdater \
ebtables-filter-multicast \
ebtables-filter-ra-dhcp \
ebtables-limit-arp \
mesh-olsrd \
mesh-vpn-fastd \
respondd \
status-page \
web-advanced \
web-wizard

GLUON_FEATURES_standard := \
wireless-encryption-wpa3

## GLUON_SITE_PACKAGES
# Specify additional Gluon/OpenWrt packages to include here;
# A minus sign may be prepended to remove a packages from the
# selection that would be enabled by default or due to the
# chosen feature flags

GLUON_SITE_PACKAGES := iwinfo

## DEFAULT_GLUON_RELEASE
# version string to use for images
# gluon relies on
Expand Down
5 changes: 3 additions & 2 deletions docs/dev/packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ Feature flags

Feature flags provide a convenient way to define package selections without
making it necessary to list each package explicitly. The list of features to
enable for a Gluon build is set by the *GLUON_FEATURES* variable in *site.mk*.
enable for a Gluon build is determined by the evaluated image-customization.lua file
in the root-directory of the Site repository.

The main feature flag definition file is ``package/features``, but each package
feed can provide additional definitions in a file called ``features`` at the root
Expand Down Expand Up @@ -207,7 +208,7 @@ Example::
This will

* disable the inclusion of the (non-existent) packages *gluon-web-wizard* and *gluon-no-radvd* when their
corresponding feature flags appear in *GLUON_FEATURES*
corresponding feature flags are evaluated as selected in the image-customization.lua file
* enable four additional config mode packages when the *web-wizard* feature is enabled
* enable *gluon-config-mode-mesh-vpn* when both *web-wizard* and one
of *mesh-vpn-fastd* and *mesh-vpn-tunneldigger* are enabled
Expand Down
2 changes: 1 addition & 1 deletion docs/features/multidomain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Via config mode
^^^^^^^^^^^^^^^

To allow switching the domain via config mode, add ``config-mode-domain-select``
to GLUON_FEATURES in site.mk.
to the enabled features in the image-customization.lua file.

|image0|

Expand Down
2 changes: 1 addition & 1 deletion docs/features/private-wlan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please note that you should not enable Wired Mesh on the uplink port at the same

The private WLAN is encrypted using WPA2 by default. On devices with enough flash and a supported radio,
WPA3 or WPA2/WPA3 mixed-mode can be used instead of WPA2. For this to work, the ``wireless-encryption-wpa3``
feature has to be added to ``GLUON_FEATURES``.
feature has to be enabled as a feature.

It is recommended to enable IEEE 802.11w management frame protection for WPA2/WPA3 networks, however this
can lead to connectivity problems for older clients. In this case, management frame protection can be
Expand Down
2 changes: 1 addition & 1 deletion docs/features/vpn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Protocol handlers
^^^^^^^^^^^^^^^^^

There are currently three protocol handlers which can be selected
via ``GLUON_FEATURES`` in ``site.mk``:
as a feature:

mesh-vpn-fastd
""""""""""""""
Expand Down
20 changes: 20 additions & 0 deletions docs/multidomain-site-example/image-customization.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
features {
'autoupdater',
'ebtables-filter-multicast',
'ebtables-filter-ra-dhcp',
'ebtables-limit-arp',
'mesh-batman-adv-15',
'mesh-vpn-fastd',
'respondd',
'status-page',
'web-advanced',
'web-wizard',
}

packages {
'iwinfo',
}

if not device_class('tiny') then
features {'wireless-encryption-wpa3'}
end
28 changes: 0 additions & 28 deletions docs/multidomain-site-example/site.mk
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
## gluon site.mk makefile example

## GLUON_FEATURES
# Specify Gluon features/packages to enable;
# Gluon will automatically enable a set of packages
# depending on the combination of features listed

GLUON_FEATURES := \
autoupdater \
ebtables-filter-multicast \
ebtables-filter-ra-dhcp \
ebtables-limit-arp \
mesh-batman-adv-15 \
mesh-vpn-fastd \
respondd \
status-page \
web-advanced \
web-wizard

GLUON_FEATURES_standard := \
wireless-encryption-wpa3

## GLUON_MULTIDOMAIN
# Build gluon with multidomain support.

GLUON_MULTIDOMAIN=1

## GLUON_SITE_PACKAGES
# Specify additional Gluon/OpenWrt packages to include here;
# A minus sign may be prepended to remove a packages from the
# selection that would be enabled by default or due to the
# chosen feature flags

GLUON_SITE_PACKAGES := iwinfo

## DEFAULT_GLUON_RELEASE
# version string to use for images
# gluon relies on
Expand Down
5 changes: 3 additions & 2 deletions docs/package/gluon-ebtables-limit-arp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ This package is installed by default if the selected routing
feature is *mesh-batman-adv-15*.
It can be unselected via::

GLUON_SITE_PACKAGES := \
-gluon-ebtables-limit-arp
packages {
'-gluon-ebtables-limit-arp',
}
20 changes: 20 additions & 0 deletions docs/site-example/image-customization.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
packages {'iwinfo'}

features {
'autoupdater',
'ebtables-filter-multicast',
'ebtables-filter-ra-dhcp',
'ebtables-limit-arp',
'mesh-batman-adv-15',
'mesh-vpn-fastd',
'respondd',
'status-page',
'web-advanced',
'web-wizard'
}

if not device_class('tiny') then
features {
'wireless-encryption-wpa3'
}
end
28 changes: 0 additions & 28 deletions docs/site-example/site.mk
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
## gluon site.mk makefile example

## GLUON_FEATURES
# Specify Gluon features/packages to enable;
# Gluon will automatically enable a set of packages
# depending on the combination of features listed

GLUON_FEATURES := \
autoupdater \
ebtables-filter-multicast \
ebtables-filter-ra-dhcp \
ebtables-limit-arp \
mesh-batman-adv-15 \
mesh-vpn-fastd \
respondd \
status-page \
web-advanced \
web-wizard

GLUON_FEATURES_standard := \
wireless-encryption-wpa3

## GLUON_SITE_PACKAGES
# Specify additional Gluon/OpenWrt packages to include here;
# A minus sign may be prepended to remove a packages from the
# selection that would be enabled by default or due to the
# chosen feature flags

GLUON_SITE_PACKAGES := iwinfo

## DEFAULT_GLUON_RELEASE
# version string to use for images
# gluon relies on
Expand Down
97 changes: 57 additions & 40 deletions docs/user/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ wifi24 \: optional
For an OWE secured network, the ``owe_ssid`` string has to be set. It sets the
SSID for the opportunistically encrypted wireless network, to which compatible
clients can connect to.
For OWE to work, the ``wireless-encryption-wpa3`` has to be enabled (usually by
adding it to ``GLUON_FEATURES_standard``) in your ``site.mk``.
For OWE to work, the ``wireless-encryption-wpa3`` has to be enabled as a feature
in your site.
To utilize the OWE transition mode, ``owe_transition_mode`` has to be set to true.
When ``owe_transition_mode`` is enabled, the OWE secured SSID will be hidden.
Compatible devices will automatically connect to the OWE secured SSID when selecting
Expand Down Expand Up @@ -611,33 +611,6 @@ GLUON_DEPRECATED
and ``upgrade`` for existing configurations (where upgrades for existing
deployments of low-flash devices are required). Defaults to ``0``.

GLUON_FEATURES
Defines a list of features to include. Depending on the device, the feature list
defined from this value is combined with the feature list for either the standard
or the tiny device-class. The resulting feature list is used to generate the default
package set.

GLUON_FEATURES_standard
Defines a list of additional features to include or exclude for devices of
the standard device-class.

GLUON_FEATURES_tiny
Defines a list of additional features to include or exclude for devices of
the tiny device-class.

GLUON_SITE_PACKAGES
Defines a list of packages which should be installed in addition to the
default package set. It is also possible to remove packages from the
default set by prepending a minus sign to the package name.

GLUON_SITE_PACKAGES_standard
Defines a list of additional packages to include or exclude for devices of
the standard device-class.

GLUON_SITE_PACKAGES_tiny
Defines a list of additional packages to include or exclude for devices of
the tiny device-class.

GLUON_RELEASE
The current release version Gluon should use.

Expand Down Expand Up @@ -674,8 +647,8 @@ leading to entangled package names like *gluon-mesh-vpn-fastd-respondd* or
*gluon-status-page-mesh-batman-adv-i18n-de*.

For this reason, we have introduced *feature flags*, which can be specified
in the *GLUON_FEATURES* variable. These flags allow to specify a set of features
on a higher level than individual package names.
using the image-customization.lua file. These flags allow to specify
a set of features on a higher level than individual package names.

Most Gluon packages can simply be specified as feature flags by removing the ``gluon-``
prefix: The feature flag corresponding to the package *gluon-mesh-batman-adv-15* is
Expand All @@ -697,29 +670,73 @@ flags using a flexible ruleset defined in the Gluon repo or site package feeds.
To some extent, it will even allow us to further modularize existing Gluon packages,
without necessitating changes to existing site configurations.

It is still possible to override such automatic rules using *GLUON_SITE_PACKAGES*
(e.g., ``-gluon-status-page-mesh-batman-adv`` to remove the automatically added
package *gluon-status-page-mesh-batman-adv*).
It is still possible to override such automatic rules by removing them using
*packages* in the image-customization.lua file
(e.g., ``features { '-gluon-status-page-mesh-batman-adv' }`` to remove
the automatically added package *gluon-status-page-mesh-batman-adv*).

For convenience, there are two feature flags that do not directly correspond to a Gluon
package:

* web-wizard

Includes the *gluon-config-mode-...* base packages (hostname, geolocation and contact info),
as well as the *gluon-config-mode-autoupdater* (when *autoupdater* is in *GLUON_FEATURES*),
and *gluon-config-mode-mesh-vpn* (when *mesh-vpn-fastd* or *mesh-vpn-tunneldigger* are in
*GLUON_FEATURES*)
as well as the *gluon-config-mode-autoupdater* (when *autoupdater* is an enabled feature),
and *gluon-config-mode-mesh-vpn* (when *mesh-vpn-fastd* or *mesh-vpn-tunneldigger* are
enabled features)

* web-advanced

Includes the *gluon-web-...* base packages (admin, network, WiFi config),
as well as the *gluon-web-autoupdater* (when *autoupdater* is in *GLUON_FEATURES*)
as well as the *gluon-web-autoupdater* (when *autoupdater* is an enabled feature),

We recommend to use *GLUON_SITE_PACKAGES* for non-Gluon OpenWrt packages only and
completely rely on *GLUON_FEATURES* for Gluon packages, as it is shown in the
We recommend to include packages for non-Gluon OpenWrt packages only and
completely rely on features for Gluon packages, as it is shown in the
example *site.mk*.

.. _site-image-customization:

Image customization
^^^^^^^^^^^^^^^^^^^

Gluon allows configuration of the build-parameters for the images. A Lua domain-specific-language
has been implemented to facilitate this configuration. This file is interpreted for every device
independently. The file is located in the site-repository root as ``image-config``.

A simple example for a device-specific image configuration can be found in the site-example.

The following functions are available:

device(device_name_list)
Returns true in case the current device is in the list of devices specified in ``device_name_list``.
``device_name_list`` is a table of strings.

target(openwrt_target, openwrt_subtarget)
Returns true in case the current device is of the specified OpenWrt target and subtarget.
The parameter ```openwrt_subtarget``` is optional. If it is not specified, only the target is matched.

device_class(dev_class)
Returns true in case the current device is of the specified device class.

features(feature_table)
Includes the specified list of features in the image. ``feature_table`` is a table of strings.
These strings can be prefixed with a dash to exclude features included earlier in the file.

packages(package_table)
Includes the specified list of packages in the image. ``package_table`` is a table of strings.
These strings can be prefixed with a dash to exclude packages included earlier in the file.

broken(broken_state)
Overrides the broken state specified by Gluon. Can be used to mark a device as broken or
remove the pre-defined broken state.

disable()
Disables image generation.

disable_factory()
Disables factory image generation. Sysupgrade images are still generated and stored in the image
output directory.

.. _site-config-mode-texts:

Config mode texts
Expand Down
Loading

0 comments on commit db0e7bd

Please sign in to comment.