Leverage Armbian Build Framework for custom image generation
In this topic we'll explore how to leverage the Armbian Build Framework to create a custom Armbian image. We'll introduce you to the steps needed to set up the build environment, add extensions, and generate a tailored image for your device. We've created a comprehensive implementation in this repository that you can use as a reference and fork to extend with your own logic. We'll delve deeper into our recommended customizations for each board in the respective docs underneath this topic.
Before we continue if you like armbian please consider supporting the project
Setting Up the Build Environment
start by cloning the build framework
git clone https://github.com/armbian/build
cd build
Install the necessary dependencies. The build framework will guide you through the installation, or you can pre-install them with:
sudo apt-get install git curl zip unzip rsync bc
you can now run the framework using ./compile.sh
Configure Extensions
Armbian has support for various extensions, we'll show guide you through how you might add some of these.
Extension Structure
Extensions use function naming pattern: <hook_name>__<implementation_name>()
function run_after_build__custom_action() {
echo "Running custom post-build action"
}
Creating Extensions
Single-file Extension
# userpatches/extensions/my-extension.sh
function prepare_host__install_deps() {
apt-get install -y custom-package
}
function run_after_build__deploy() {
echo "Build completed, deploying..."
}
Directory-based Extension
Create the directory
mkdir -p userpatches/extensions/my-complex-ext
afterwards add a shell file with an extension function
# userpatches/extensions/my-complex-ext/my-complex-ext.sh
function post_customize_image__configure() {
cp "${EXTENSION_DIR}/config.template" "${SDCARD}/etc/myconfig"
}
Enabling Extensions
./compile.sh ENABLE_EXTENSIONS=my-extension,cloud-init
Or in configuration:
enable_extension "my-extension"
Cloud-init Extension Implementation
Add the official cloud init extension to your build.
mkdir -p userpatches/extensions
cp -r extensions/cloud-init userpatches/extensions/cloud-init
Since you'll want to be modifying the user-data
file, you can copy your own version into the image. We show an example automation of this in our repository.