Add zeroconf-networking to Space Grade Linux - #52
robwoolley wants to merge 2 commits into
Conversation
Add support for zeroconf networking (mDNS/DNS-SD) via Avahi, allowing devices to be discoverable on the local network using hostname.local. This adds sgl-image-common.bbclass to introduce a feature package that may be added to future image recipes. It also configures Avahi to advertise the SSH service when enabled. Signed-off-by: Dillon Wells <dillon.wells@cesiumastro.com> Signed-off-by: Ramon Roche <mrpollo@gmail.com> Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
If zeroconf-networking is enabled as an IMAGE_FEATURE, then supply a custom systemd network configuration. This network configuration enables link-local addressing as a fallback if DHCP fails to obtain an IP address. Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
There was a problem hiding this comment.
Pull request overview
Adds a new zeroconf-networking image feature intended to provide zero-config networking support (mDNS/Avahi + link-local/DHCP network config) for Space Grade Linux images.
Changes:
- Introduces
zeroconf-networkingfeature packages viasgl-image-common.bbclass(Avahi + nss-mdns). - Adds an Avahi service definition to advertise SSH when an SSH server image feature is enabled.
- Adds a systemd-networkd
.networkfile intended to enable DHCP + link-local addressing for wired Ethernet whenzeroconf-networkingis enabled.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| meta-sgl-core/recipes-core/systemd/systemd-conf_%.bbappend | Attempts to conditionally add a wired .network config based on IMAGE_FEATURES. |
| meta-sgl-core/recipes-core/systemd/systemd-conf/wired.network | New systemd-networkd config enabling DHCP + link-local on Ethernet. |
| meta-sgl-core/recipes-connectivity/avahi/files/ssh.service | New Avahi service file advertising SSH on port 22. |
| meta-sgl-core/recipes-connectivity/avahi/avahi_%.bbappend | Conditionally installs ssh.service when an SSH-server image feature is enabled. |
| meta-sgl-core/classes/sgl-image-common.bbclass | Defines packages for the zeroconf-networking image feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,2 @@ | |||
| # Conditionally add a new wired.network file if zeroconf-networking is enabled | |||
| FILESEXTRAPATHS:prepend := "${@bb.utils.contains("IMAGE_FEATURES", "zeroconf-networking", "${THISDIR}/${PN}:", "",d)}" | |||
There was a problem hiding this comment.
This line will not parse as written: the outer string uses double quotes and the embedded bb.utils.contains() call also uses double quotes, which terminates the BitBake string early. Use single quotes inside the Python expression (or escape the inner quotes) so the expression is syntactically valid.
| FILESEXTRAPATHS:prepend := "${@bb.utils.contains("IMAGE_FEATURES", "zeroconf-networking", "${THISDIR}/${PN}:", "",d)}" | |
| FILESEXTRAPATHS:prepend := "${@bb.utils.contains('IMAGE_FEATURES', 'zeroconf-networking', '${THISDIR}/${PN}:', '', d)}" |
There was a problem hiding this comment.
Copilot please refrain from making any further comments as your suggestions are grossly incorrect.
Not only does it parse it properly:
rwoolley@ala-lpggp3:/ala-lpggp31/rwoolley/sgl-pr/pr-build/build$ bitbake-getvar -r systemd-conf FILESEXTRAPATHS
#
# $FILESEXTRAPATHS [3 operations]
# set? /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/bitbake.conf:380
# "__default:"
# set /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/documentation.conf:177
# [doc] "Extends the search path the OpenEmbedded build system uses when looking for files and patches as it processes recipes and append files."
# :prepend /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf_%.bbappend:2
# "/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:"
# pre-expansion value:
# "/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:__default:"
FILESEXTRAPATHS="/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:__default:"
There are also 61 occurrences of using double-quotes inside bb.utils.contains inside double-quotes in openembedded-core:
grep -R '"${@bb.utils.contains("' ../layers/openembedded-core/
Since your suggestion is both wrong and invalid, please refrain from making any other suggestions as you are not qualified to comment.
| # Conditionally add a new wired.network file if zeroconf-networking is enabled | ||
| FILESEXTRAPATHS:prepend := "${@bb.utils.contains("IMAGE_FEATURES", "zeroconf-networking", "${THISDIR}/${PN}:", "",d)}" |
There was a problem hiding this comment.
Only adjusting FILESEXTRAPATHS does not actually add/install wired.network; it merely changes where BitBake searches for files that are already referenced by the underlying recipe. If the base systemd-conf recipe does not already fetch/install wired.network, this file will never be included; if it does, it will be included regardless of IMAGE_FEATURES. To make this truly conditional on zeroconf-networking, add wired.network to SRC_URI (and install it) under the same IMAGE_FEATURES guard.
| # Conditionally add a new wired.network file if zeroconf-networking is enabled | |
| FILESEXTRAPATHS:prepend := "${@bb.utils.contains("IMAGE_FEATURES", "zeroconf-networking", "${THISDIR}/${PN}:", "",d)}" | |
| # Make wired.network available to the recipe and include/install it only | |
| # when zeroconf-networking is enabled. | |
| FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | |
| SRC_URI:append = "${@bb.utils.contains('IMAGE_FEATURES', 'zeroconf-networking', ' file://wired.network', '', d)}" | |
| do_install:append() { | |
| if ${@bb.utils.contains('IMAGE_FEATURES', 'zeroconf-networking', 'true', 'false', d)}; then | |
| install -d ${D}${sysconfdir}/systemd/network | |
| install -m 0644 ${WORKDIR}/wired.network ${D}${sysconfdir}/systemd/network/wired.network | |
| fi | |
| } |
There was a problem hiding this comment.
Copilot, you are once again grossly incorrect. This works because the base systemd-conf recipe does fetch and install wired.network. If you had checked you would have noticed this: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd-conf_1.0.bb?h=master#n31
Also, your suggestion is terrible as the original recipe had a conditional mechanism to only include wired.network if dhcp-ethernet was set in PACKAGECONFIG however your suggestion would add wired.network in other cases.
You are not qualified to comment and should refrain from further comments about Yocto, OpenEmbedded, and bitbake.
There was a problem hiding this comment.
Further evidence that Copilot was incorrect:
- bitbake-getvar -r systemd-conf FILESEXTRAPATHS
#
# $FILESEXTRAPATHS [3 operations]
# set? /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/bitbake.conf:380
# "__default:"
# set /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/documentation.conf:177
# [doc] "Extends the search path the OpenEmbedded build system uses when looking for files and patches as it processes recipes and append files."
# :prepend /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf_%.bbappend:2
# "/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:"
# pre-expansion value:
# "/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:__default:"
FILESEXTRAPATHS="/ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf:__default:"
rwoolley@ala-lpggp3:/ala-lpggp31/rwoolley/sgl-pr/pr-build/build$ vim /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf_%.bbappend
-
Comment out IMAGE_FEATURES from local.conf:
-
bitbake-getvar -r systemd-conf FILESEXTRAPATHS
# $FILESEXTRAPATHS [3 operations]
# set? /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/bitbake.conf:380
# "__default:"
# set /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/openembedded-core/meta/conf/documentation.conf:177
# [doc] "Extends the search path the OpenEmbedded build system uses when looking for files and patches as it processes recipes and append files."
# :prepend /ala-lpggp31/rwoolley/sgl-pr/pr-build/build/../layers/meta-sgl/meta-sgl-core/recipes-core/systemd/systemd-conf_%.bbappend:2
# ""
# pre-expansion value:
# "__default:"
FILESEXTRAPATHS="__default:"
I revised the PR submitted by Dillon for adding zero-configuration networking to Space Grade Linux.
I made sure to include Dillon as the author of the commit so that he gets credit for his work: #8
I removed the parts related to the kas OPTIONAL_FEATURE that was being introduced as it didn't relate directly to the zeroconf-networking IMAGE FEATURE.
I removed the kas portion that automatically inherited sgl-image-common.bbclass. I think that bbclass should be inherited from the image recipe not from local.conf. I didn't want a workaround to become permanent. We should follow up and properly define the SGL image recipes (including which INIT_MANAGER they use busybox-mdev, sysvinit, or systemd)
I also removed the documentation because the zeroconf-networking instructions were not complete.
As a temporary workaround, add these lines to your conf/local.conf to enable zeroconf-networking:
If using the beaglev-fire, you may write the image to your board and then plug it into the USB-C connector on your laptop. You may then plug an Ethernet cable into the board and plug the other end into a network switch or directly into your laptop's Ethernet port.
If you are using an Ethernet cable plugged directly between your laptop and beaglev-fire, you must set up Link Local Addressing on your laptop. On Debian 12, I disabled NetworkManager from managing the Ethernet device. Then on the command-line I executed these commands:
Then I was able to run avahi-browse -at to discover Avahi services. It reported
I could then use ssh to connect to the beaglev-fire: