Plan for Introducing Automation into Zynthian Builds
Introduction
This document outlines a rough plan for introducing CI/CD automation into the building and testing of Zynthian software and Zynthian OS images based on the approach taken in the Librem 5 phone. This plan was discussed at a Zynth Club meeting on 2026-08-21 during which it was advised that writing the plan down would be helpful to the project.
Why
Advantages of this effort include but are not limited to:
- Reduced workload for software maintainers and reduced likelihood of introducing bugs due to the elimination of manual steps.
- Reduced OS image size and disk requirements due to the removal of compiler toolchain and build dependencies.
- Reduced number of bugs that make it into the hands of users due to automated testing.
- Reduced workload for reviewers of code contributions due to the obviation of manual testing.
- Quicker migration between versions of the underlying distribution due to the ease of identifying regressions.
- Improved robustness of all software.
- Improved robustness and speed of software upgrades.
- Elimination of technical debt.
- Lower barrier of entry for new contributors due to the automation of software building, testing and integration.
How
The first steps of the rough plan are:
- Package all of the software which is currently compiled during the process of preparing an OS image.
- Build and test the resulting packages in CI, integrating the reporting of build and test results into merge requests.
- Transition the OS image building script to install packages using apt rather than compiling.
These steps will only eliminate compilation from the image building script. After compilation is eliminated, there are still very non-trivial tasks required:
- Fully automatic image construction with no requirement for manual steps, in particular eliminating any need to execute the image on target hardware as part of the build process.
- Integration testing of built images in VMs/containers.
- Integration testing on actual hardware, for example using LAVA and a farm of test devices.
Complications
Currently the Zynthian codebase has problems which complicate the automation of software builds.
Assumption that the build host is the runtime host
There is an assumption throughout the Zynthian software and build systems that the software will be compiled on the same host on which it runs. So far, this seems most acute within the zyncoder package. For just one example, the zyncoder build script sets build flags based on the execution of lsmod on the build host:
The use of CI to build binary packages obviously invalidates this assumption and so the introduction of CI builds will necessitate extensive changes to how at least zyncoder and no doubt other packages operate so that all functionality is compiled in and behaviour adapts
based on runtime checks.
Compile-time software configuration
There are a number of preprocessor macros that are used to configure Zynthian software at compile time. For example:
There are also a number of environment variables in the image build script which describe the hardware the build is intended for. For example:
All of this compile-time configuration will need to be removed and replaced with runtime configuration based on static configuration files, runtime detection and user input. Any hardware-specific static configuration files will be put in hardware-specific packages, for example zynthian-hwconfig-zynthianV5.
Who
I, rah, am working to implement this plan. I hope others will help the effort, especially once CI jobs start to take form and demonstrate the advantages of this approach.
I will try to find some suitable introductory materials for creating Debian packages but I expect the bulk of the work will be in (1) modifying the existing software as described above, (2) implementing CI jobs and (3) implementing unit- and integration-tests.