conference logo

Playlist "openSUSE Conference 2022"

Sourcery: a multi-architecture root file system that is mostly source

rminnich

Sourcery is a program that builds root file systems consisting mostly of Go
source code: of the 90,000 files in a typical sourcery root, there are
only 12 or so programs. Other programs are compiled on demand to a
ramfs-backed file system. Compilation takes a fraction of a second
for most programs, and never more than 2 seconds. Once the program is
compiled to a statically-linked, tmpfs-based binary, invocation is
instantaneous.

Because these images are mostly source, they can also be
multi-architecture. Binaries present on boot have a path formed from
the target os and architecture, e.g. /$OS_$ARCH/bin/init for
init. Dynamically compiled binaries are placed in the tmpfs-backed
/bin, since these binaries vanish on boot, the path can be simpler.

The file system includes the full Go toolchain as well as all
source code. Constructing the root file system, including the git
clone steps and Go toolchain build, takes under 4 minutes; each
additional architecture takes another 90 seconds (to ensure
reproducible builds, the Go toolchain builds itself 3 times).

Sourcery root file systems are designed for VFAT, a standard for
firmware for x86, ARM, and RISC-V. A typical USB stick for sourcery
would include a syslinux bootstrap for x86, required for those
platforms; a kernel Image file for ARM; and a kernel file for RISC-V: the
firmware for ARM and RISC-V is able to find boot kernels
without using an on-stick bootstrap.

Sourcery may be found at github.com:u-root/sourcery.

Sourcery is a program that builds root file systems consisting mostly of Go
source code: of the 90,000 files in a typical sourcery root, there are
only 12 or so programs. Other programs are compiled on demand to a
ramfs-backed file system. Compilation takes a fraction of a second
for most programs, and never more than 2 seconds. Once the program is
compiled to a statically-linked, tmpfs-based binary, invocation is
instantaneous.

Because these images are mostly source, they can also be
multi-architecture. Binaries present on boot have a path formed from
the target os and architecture, e.g. /$OS_$ARCH/bin/init for
init. Dynamically compiled binaries are placed in the tmpfs-backed
/bin, since these binaries vanish on boot, the path can be simpler.

The file system includes the full Go toolchain as well as all
source code. Constructing the root file system, including the git
clone steps and Go toolchain build, takes under 4 minutes; each
additional architecture takes another 90 seconds (to ensure
reproducible builds, the Go toolchain builds itself 3 times).

Sourcery root file systems are designed for VFAT, a standard for
firmware for x86, ARM, and RISC-V. A typical USB stick for sourcery
would include a syslinux bootstrap for x86, required for those
platforms; a kernel Image file for ARM; and a kernel file for RISC-V: the
firmware for ARM and RISC-V is able to find boot kernels
without using an on-stick bootstrap.

Sourcery may be found at github.com:u-root/sourcery.