Extensible Disk Image Generator

This forum is for discussion about general software issues.

Extensible Disk Image Generator

Postby jgmdev » Thu May 21, 2020 12:07 am

Hi to everyone! These couple of days I took some time to write a bash script that allows one to easily generate disk images for any of the platforms supported by ArchLinux Arm or even does that don't by supporting inclusion of custom packages. For now I have only added support for the Odroid N2 and Odroid C4 and the XFCE desktop environment, but it should be easy to add more platforms and environments as documented below, here is the git repo https://github.com/jgmdev/alarm-image-generator pull requests are welcome. Hope it can be useful for someone.

Introduction

The script generates images with a predefined set of configurations and software packages. It works by reading separate shell scripts that provide the necessary commands to generate the image. These scripts are divided in the following two components.

  • platform - Instructions for a specific SOC (system on a chip), eg: odroid n2, odroid c2, etc... On these scripts you can specify commands to install specific kernels, u-boot files, config files...
  • env - Instructions to install a Desktop Environment like: xfce, gnome, etc... On this scripts you can specify which software to install for a specific Desktop Environment, generate configuration files or anything else.

Also these components may depend on resources inside the 'mods' directory which contains pre-defined configuration files that are copied to the target generated image.

Requirements

The main build.sh should detect if you have a missing dependency and let you know, but besides this you will need the following:

  • ArchLinux installation running same architecture of target image. (this could change)
  • User account with sudo priviliges.

Usage

The command line options need some refining and improvements, but for now the option that generates the images is working properly. To generate a Odroid N2 image you would do:

Code: Select all
./build.sh build n2


This will set the environment by default to xfce (you can specify a different environment by using the -e flag). Then the instructions on platform/n2.sh and env/xfce.sh are executed. By default the script will install some packages, you can take a look on env/base.sh for the defaults.

Extending

Adding additional platforms and environments should be pretty simple. The script uses a hook system to call into other scripts depending on the desired platform and environment that was specified on the command line options.

Platforms

In case of adding a platform you would need to edit build.sh, add the file to download, desired image name and platform code name to the following code section:

Code: Select all
for arg in "$@"; do
    case "$arg" in
      "n2")
          NAME="ArchLinuxARM-odroid-n2-latest"
          IMAGE="ArchLinuxARM-odroid-n2"
          PLATFORM="n2"
          ;;
      "c4")
          echo "Still working on this..." 1>&2
          exit 1
          ;;
    esac
done


For example:

Code: Select all
for arg in "$@"; do
    case "$arg" in
      "n2")
          NAME="ArchLinuxARM-odroid-n2-latest"
          IMAGE="ArchLinuxARM-odroid-n2"
          PLATFORM="n2"
          ;;
      "c2")
          NAME="ArchLinuxARM-odroid-c2-latest"
          IMAGE="ArchLinuxARM-odroid-c2"
          PLATFORM="c2"
          ;;
      "c4")
          echo "Still working on this..." 1>&2
          exit 1
          ;;
    esac
done


Then you should add the installation instructions of this new platform into platform/c2.sh. On this file you have to specify 3 hook functions that get called by main build script:

  • platform_pre_chroot
  • platform_chroot_setup
  • platform_post_chroot

You can take a look in platform/n2.sh to get an idea.

Environments

Finally, adding environments should be the same process as adding a new platform. Lets say you want to add sway. You would create a new file as env/sway.sh, and add to it the following hook functions:

  • env_pre_chroot
  • env_chroot_setup
  • env_post_chroot

You can see the env/xfce.sh file for ideas. In order to use the new platform and environment to generate a new image you would call the script as follows:

Code: Select all
./build.sh build -e sway c2


Pull requests with improvements, new platforms or environments are welcome!

Inspiration for this script was taken from:
https://github.com/EasyPi/alarmpi-image
jgmdev
 
Posts: 4
Joined: Mon Jan 29, 2018 5:30 pm

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest