Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anybody want to clean up this high-level how Armbian builder works? #190

Open
lanefu opened this issue Mar 27, 2022 · 2 comments
Open

Anybody want to clean up this high-level how Armbian builder works? #190

lanefu opened this issue Mar 27, 2022 · 2 comments

Comments

@lanefu
Copy link
Member

lanefu commented Mar 27, 2022

from IRC rant a while back.. probably useful if cleaned up

build script has a decent inheritance model for configuration, albeit a few gotchas here and there, and decently subdivided to several libraries of functions....   there's some neat hooks where you can trigger individual functions  from command line if you're crafty enough

General order of operations on a vanilla execution is:

* special command line argument parser function breaks up key=value passed as arguments and sets them as their respective config variable used later
* check basic system requirements (distro, etc)
* install OS dependency packages, ex: build tools, compression tools, 
* carve out some work directories... ex cache, output, hidden tmp, userpatches
* download appropriate cross-compilation toolchains (we maintain our own collection of them for sanity purposes)
* prompt for input for what to build (if not passed via command config or config file)
** board, which flavor of kernel (legacy, stable, edge), which base OS flavor to bootstrap ( ex: debian bullseye, ubuntu focal ), what type of image.. minimal, server, or desktop... if desktop MORE questions
* commend build process
* checkout appropriate sources as defined in inherietence model for device for uboot, kernel, as well as some supplemental packages (firmware etc)
* apply patches to teh checked out code, based on the contents of our patch folders and its heirachy sytem
* apply custom patches provided by user
* compile uboot and kernel... output as deb files
* attempt to retrieve a cached prebuilt version of the respective root filesystem (ex: debian bullseye, server). if yes, mount, chroot, update, and remaining customization for a board etc, and then install kernel and uboot. if no, perform a debootstrap to create that respectiev filesystem then install other stuff
* once filesystem is complete, create actual raw disk image file via a loopback device... partition and create file ssytems as needed... rsync contents of chrooted file system prior into said image....
* perform post steps unique to system... ex: fancy u-boot dances, and assembly of secondary program loaders etc
* water mark image in /etc/armbian-release
* sign
* compress image
@igorpecovnik
Copy link
Member

igorpecovnik commented Mar 27, 2022

I remember someone did quite a big document on the forum but it was years ago. And we have https://www.youtube.com/watch?v=0K0vtUg_cgo

@inkade
Copy link

inkade commented Jun 23, 2023

While operating within the parameters of trying to remain 'high-level':

How Armbian Builder works

The Armbian Builder is a build script that facilitates the creation of custom Linux images for ARM-based devices. It provides a flexible configuration system and modular functions for building and customizing various components of the Linux image. The general order of operations within the Armbian Builder is detailed below, including the key steps in configuring, building, and customizing the Linux image for ARM-based devices.

  1. Command Line Argument Parsing: The build script includes a command line argument parser that processes key-value pairs passed as arguments and sets them as configuration variables for later use.

  2. System Requirements Check: Basic system requirements, such as the target distribution, are checked to ensure compatibility.

  3. Installation of OS Dependency Packages: The script installs necessary packages, such as build tools and compression tools, to meet the dependencies required for building the Linux image.

  4. Work Directories Setup: Several work directories are created, including cache, output, hidden tmp, and userpatches directories, which are used during the build process.

  5. Cross-Compilation Toolchains: The appropriate cross-compilation toolchains are downloaded. Armbian maintains its collection of toolchains to ensure consistency and reliability during the build process.

  6. User Input: The script prompts for user input regarding the specifics of the image to be built. This includes selecting the board, kernel flavor (legacy, stable, edge), base OS flavor (e.g., Debian Bullseye, Ubuntu Focal), and the type of image (minimal, server, desktop). Additional questions may be asked for desktop images.

  7. Build Process Commences: The build process is initiated based on the provided configurations.

  8. Source Code Checkout: The script checks the appropriate sources, such as u-boot, kernel, and supplemental packages, based on the device's inheritance model.

  9. Patch Application: Patch files from the designated patch folders and user-provided custom patches are applied to the checked-out source code.

  10. Compilation: The script compiles u-boot and the kernel, generating deb files as output.

  11. Root Filesystem Handling: If a cached prebuilt root filesystem is available, it is retrieved, mounted, and updated with customizations. Otherwise, a debootstrap process is performed to create the required filesystem. The kernel and u-boot are then installed in the filesystem.

  12. Image Creation: An actual raw disk image file is created using a loopback device. The image is partitioned, and the necessary file systems are created. The contents of the chrooted filesystem are then rsynced into the image.

  13. Post-Processing: System-specific post-processing steps are performed, such as executing u-boot configuration steps and assembling secondary program loaders.

  14. Image Finalization: The image is watermarked with relevant information in /etc/armbian-release. It is then signed and compressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants