Building Calculinux¶
This guide covers building the Calculinux distribution from source.
Prerequisites¶
System Requirements¶
- Host OS: Linux (Ubuntu 22.04 LTS or similar recommended)
- Disk Space: Minimum 50GB free space (100GB+ recommended)
- Memory: 8GB RAM minimum (16GB+ recommended for parallel builds)
- CPU: Multi-core processor (builds can take 2-6 hours depending on hardware)
Required Software¶
Install the required packages on your build host:
# Ubuntu/Debian
sudo apt install gawk wget git diffstat unzip texinfo \
gcc build-essential chrpath socat cpio python3 \
python3-pip python3-pexpect xz-utils debianutils \
iputils-ping python3-git python3-jinja2 libegl1-mesa \
libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev \
zstd liblz4-tool
Build System Overview¶
Calculinux uses the Yocto Project build system with:
- Build Tool: KAS for simplified configuration
- Base: Yocto Scarthgap (4.2)
- Distribution: Calculinux (based on Poky)
- Layers: Multiple meta-layers for hardware support and software packages
Quick Start¶
1. Clone the Repository¶
mkdir calculinux-build && cd calculinux-build
git clone https://github.com/Calculinux/meta-calculinux.git
cd meta-calculinux
2. Build with KAS¶
The simplest way to build is using the KAS container:
This command will:
- Download all required Yocto layers
- Configure the build for Luckfox Lyra
- Build the complete distribution image
- Generate IPK packages
3. Locate Build Output¶
After the build completes (2-6 hours), find your images in:
Key outputs:
calculinux-image-luckfox-lyra.rootfs.wic.gz- Full disk image for initial installationcalculinux-bundle-luckfox-lyra.raucb- RAUC update bundle for updating existing installations
Build Types and Package Feed Configuration¶
Calculinux images are automatically configured with the appropriate package feed based on how they are built. Feeds are pre-configured in the image and typically do not require manual intervention. This section is primarily informational to help you understand the feed structure.
Understanding Feed Configuration¶
Package feeds are organized by:
- DISTRO_CODENAME - The Yocto/Poky codename (e.g.,
walnascarfor Scarthgap 4.2) - FEED_SUBFOLDER - Either
continuous(development) orrelease(stable tags)
The feed URL structure is:
CI Build Configuration (Automated)¶
When building via GitHub Actions CI, the build system automatically generates build/conf/auto.conf to configure the package feeds:
| Build Trigger | DISTRO_CODENAME | FEED_SUBFOLDER | Resulting Feed URL |
|---|---|---|---|
main branch push |
walnascar |
continuous |
https://opkg.calculinux.org/ipk/walnascar/continuous/ |
develop branch push |
develop |
continuous |
https://opkg.calculinux.org/ipk/develop/continuous/ |
Tagged release (e.g., v1.0.0) |
walnascar |
release |
https://opkg.calculinux.org/ipk/walnascar/release/ |
Pre-release tag (e.g., v1.0.0-rc1) |
walnascar |
release |
https://opkg.calculinux.org/ipk/walnascar/release/ |
Example auto.conf generated by CI:
# For main branch:
DISTRO_CODENAME = "walnascar"
CALCULINUX_FEED_SUBFOLDER = "continuous"
# For develop branch:
DISTRO_CODENAME = "develop"
CALCULINUX_FEED_SUBFOLDER = "continuous"
# For tagged release (v1.0.0):
DISTRO_CODENAME = "walnascar"
CALCULINUX_FEED_SUBFOLDER = "release"
Manual Build Configuration¶
When you build manually (without CI), auto.conf is not created, so the configuration comes from the distribution defaults in meta-calculinux-distro/conf/distro/calculinux-distro.conf:
# Default values from calculinux-distro.conf:
DISTRO_CODENAME = "walnascar" # Inherited from poky.conf
CALCULINUX_FEED_SUBFOLDER ??= "continuous" # Defaults to continuous
Manual Build Behavior:
| What You Do | DISTRO_CODENAME | FEED_SUBFOLDER | Feed URL |
|---|---|---|---|
kas-container build kas-luckfox-lyra-bundle.yaml |
walnascar (from Poky) |
continuous (default) |
ipk/walnascar/continuous/ |
Add CALCULINUX_FEED_SUBFOLDER = "release" to build/conf/local.conf |
walnascar (from Poky) |
release (override) |
ipk/walnascar/release/ |
Add DISTRO_CODENAME = "develop" to build/conf/local.conf |
develop (override) |
continuous (default) |
ipk/develop/continuous/ |
Feed Configuration Variables¶
These variables control which package feed your image will use:
DISTRO_CODENAME: Distribution codename- Inherited from
poky.conf(currentlywalnascarfor Scarthgap 4.2) - CI overrides this to
developfor develop branch builds -
Can be manually overridden in
build/conf/local.conforbuild/conf/auto.conf -
CALCULINUX_FEED_SUBFOLDER: Feed subdirectory - Defaults to
continuousif not specified - CI sets to
releasefor tagged builds - Can be manually overridden in
build/conf/local.conf
When to Change Feed Configuration¶
You typically don't need to change feed configuration unless:
- Testing a different feed: You want to test your local build with a different package repository
- Custom deployment: You're creating a custom image variant with specific package sources
- Development workflow: You're developing packages and want to use a test feed
To change the feed configuration for manual builds, create or edit build/conf/local.conf:
# Example: Use the release feed instead of continuous
CALCULINUX_FEED_SUBFOLDER = "release"
# Example: Use the develop feed
DISTRO_CODENAME = "develop"
CALCULINUX_FEED_SUBFOLDER = "continuous"
Verifying Feed Configuration¶
To check which feed your image will use:
# Inside kas-container shell:
./kas-container shell kas-luckfox-lyra-bundle.yaml
# Query the feed configuration:
bitbake -e calculinux-image | grep -E "^(DISTRO_CODENAME|CALCULINUX_FEED_SUBFOLDER|PACKAGE_FEED_BASE_PATHS)="
Example output:
DISTRO_CODENAME="walnascar"
CALCULINUX_FEED_SUBFOLDER="continuous"
PACKAGE_FEED_BASE_PATHS="ipk/walnascar/continuous"
How Feed Configuration Works¶
The feed configuration is baked into the image during build:
- Build Time: Yocto reads
DISTRO_CODENAMEandCALCULINUX_FEED_SUBFOLDERvariables - Image Creation: Feed URL is written to
/etc/opkg/opkg.confin the image - Runtime:
opkguses the configured feed URL to install/update packages
Users can still manually change feeds after installation by editing /etc/opkg/opkg.conf, but this is only needed for advanced use cases (see Package Management for details).
Configuring Your Build¶
Setting Distribution Codename¶
To manually set the distribution codename, edit conf/local.conf:
# For stable builds
DISTRO_CODENAME = "walnascar"
# For development builds
DISTRO_CODENAME = "develop"
Setting Feed Subfolder¶
To configure the package feed subfolder, edit conf/local.conf:
# For continuous/rolling releases
CALCULINUX_FEED_SUBFOLDER = "continuous"
# For stable releases
CALCULINUX_FEED_SUBFOLDER = "release"
Complete Build Configuration Example¶
For a development build:
For a release build:
Build Targets¶
Calculinux provides several build targets:
Main Image¶
The primary Calculinux image with desktop environment and applications.
Minimal Image¶
A minimal base system without desktop environment.
SDK¶
Generates a cross-compilation SDK for application development.
Build Options¶
Clean Build¶
To perform a clean build:
# Clean everything
bitbake -c cleanall calculinux-image
# Clean specific package
bitbake -c cleanall <package-name>
Parallel Builds¶
Configure parallel builds in conf/local.conf:
# Number of parallel BitBake tasks
BB_NUMBER_THREADS ?= "8"
# Number of parallel make tasks
PARALLEL_MAKE ?= "-j 8"
Adjust numbers based on your CPU cores and available RAM.
Disk Space Management¶
Monitor disk usage:
# Check build directory size
du -sh build/tmp
# Clean shared state cache
rm -rf build/sstate-cache/*
# Clean downloads (only if needed)
rm -rf build/downloads/*
Build Output¶
After a successful build, find images in:
Key files:
calculinux-image-*.wic.gz- Flashable SD card imagecalculinux-image-*.tar.gz- Root filesystem archivecalculinux-image-*.manifest- List of installed packages
Flashing the Image¶
To SD Card (Linux)¶
# Decompress the image
gunzip calculinux-image-*.wic.gz
# Flash to SD card (replace /dev/sdX with your card)
sudo dd if=calculinux-image-*.wic of=/dev/sdX bs=4M status=progress
sudo sync
To SD Card (Cross-platform)¶
Use Etcher or Raspberry Pi Imager with the .wic.gz file.
CI/CD Integration¶
Calculinux uses GitHub Actions for automated builds. The CI system automatically:
- Detects the branch or tag being built
- Sets appropriate
DISTRO_CODENAMEandCALCULINUX_FEED_SUBFOLDER - Builds the image
- Publishes packages to the correct feed location
- Uploads build artifacts
CI Configuration Files¶
The build behavior is controlled by:
.github/workflows/build.yml- Main CI workflowconf/auto.conf- Auto-generated build configurationconf/calculinux.conf- Distribution configuration
Package Feed Publishing¶
After building, packages can be published to the opkg feed:
# Upload to continuous feed (development)
rsync -avz tmp/deploy/ipk/ \
user@opkg.calculinux.org:/var/www/opkg/ipk/walnascar/continuous/
# Upload to release feed (stable)
rsync -avz tmp/deploy/ipk/ \
user@opkg.calculinux.org:/var/www/opkg/ipk/walnascar/release/
The CI system handles this automatically for official builds.
Troubleshooting¶
Build Failures¶
If a build fails:
- Check the error message in the build log
- Clean the failing package:
bitbake -c cleanall <package> - Retry the build
- Check Common Issues
Disk Space Issues¶
If you run out of disk space:
# Remove old build artifacts
bitbake -c clean calculinux-image
# Clear shared state cache
rm -rf build/sstate-cache/*
Network Issues¶
If downloads fail:
# Use mirrors
# Add to conf/local.conf:
PREMIRRORS_prepend = "\
git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
ftp://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
http://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
https://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n"
Next Steps¶
- Customizing Images - Learn how to customize your build
- Adding Packages - Add your own packages
- Kernel Development - Customize the kernel
- Release Process - Create official releases
See Also¶
- Yocto Project Documentation
- BitBake User Manual
- Package Management Guide - Using opkg feeds