image build and composition scripts for Flatcar Container Linux
Go to file
Thilo Fromm a2ae11cb3d
Merge pull request #210 from flatcar-linux/t-lo/garbage_collect-fix-binpkg-url
ci-automation/garbage_collect: fix binpkg url
2022-01-10 14:44:10 +01:00
build_library ci-automation: Apply suggestions from PR review 2022-01-10 11:41:03 +01:00
changelog changelog/README.md: describe purpose of the changelog entries 2022-01-03 15:45:00 +01:00
ci-automation ci-automation/garbage_collect: fix binpkg url 2022-01-10 14:07:33 +01:00
contrib contrib: shellcheck lint 2020-09-02 08:10:50 -04:00
jenkins jenkins/kola/azure: make use of --azure-use-gallery parameter 2022-01-07 13:56:32 +01:00
lib/shflags Move cros_vm_constants to build_library 2021-08-27 14:20:54 +02:00
oem 2345.0.0 2019-12-04 14:59:11 +01:00
sdk_container version.txt + submodules: bumped to 3087 / latest 2021-12-16 18:57:27 +01:00
sdk_lib Merge pull request #205 from flatcar-linux/t-lo/fix-sdk_entry-setup_board-fallout 2022-01-07 13:26:38 +01:00
signing Use same APPID for arm64 and amd64 2020-01-22 10:50:25 +01:00
.dockerignore sdk-container: add scripts for containerised SDK 2021-11-26 17:54:43 +01:00
.gitignore sdk-container: address feedback from @krnowak review 2021-11-26 17:54:43 +01:00
.gitmodules sdk-container: add scripts for containerised SDK 2021-11-26 17:54:43 +01:00
bash_completion fix(*): remove lingering broken support for board overlays. 2013-12-08 16:02:00 -08:00
boot_nspawn fix(*): use /media/state and overlays dir 2013-07-26 08:44:47 -07:00
bootstrap_sdk *: Replace kinvolk github org with flatcar-linux 2021-12-21 17:22:48 +01:00
bootstrap_sdk_container sdk-container: add @krnowak's suggestions from code review 2021-11-26 17:54:43 +01:00
build_docker_aci *: Drop jobs parameter 2021-02-17 13:26:36 +01:00
build_image ci-automation + setup_board: publish and use binpkgs 2022-01-07 17:16:44 +01:00
build_oem_aci *: Drop jobs parameter 2021-02-17 13:26:36 +01:00
build_packages build_packages: fix default torcx output root 2022-01-05 13:28:49 +01:00
build_sdk_container_image build_sdk_container_image: force removal of running container 2022-01-06 21:28:30 +01:00
build_toolchains bootstrap_sdk, build_toolchains: Move the ROOT_OVERLAY variable 2021-02-03 17:16:02 +01:00
build_torcx_store build_torcx_store: Fix pipeline error handling 2021-09-27 20:18:22 +02:00
CHANGELOG.md changelog: Add placeholder directory to add the changelogs 2021-11-24 22:50:02 +05:30
checkout checkout: fix typo in update strategy detection 2022-01-07 15:26:17 +01:00
clean_loopback_devices Add a umount wrapper to suppress gvfsd/trashd breaking umount calls. 2012-09-05 00:00:43 -07:00
code-of-conduct.md update CoC 2018-01-04 12:20:11 -08:00
common.sh ci-automation + setup_board: publish and use binpkgs 2022-01-07 17:16:44 +01:00
CONTRIBUTING.md CONTRIBUTING: add a section about not emailing maintainers 2014-06-18 18:38:28 -07:00
core_date 2317.0.1 2019-11-07 19:40:01 +01:00
core_dev_sign_update 2345.0.0 2019-12-04 14:59:11 +01:00
core_pre_alpha 2317.0.1 2019-11-07 19:40:01 +01:00
core_roller_upload 2317.0.1 2019-11-07 19:40:01 +01:00
core_sign_update core_sign_update: add support for new signing server 2018-06-21 17:31:43 -07:00
cros_workon Add the --include-masked flag when calling the equery which command. 2013-01-30 14:25:44 -08:00
DCO chore(contributing): clean up CONTRIBUTING.md and split out DCO 2014-04-04 10:40:37 -07:00
find_overlay_dups *: add script to check for duplicate pkgs 2018-03-07 14:25:45 -08:00
get_latest_image.sh setup DEFAULT_BOARD by default 2012-08-14 10:17:31 -07:00
get_package_list setup DEFAULT_BOARD by default 2012-08-14 10:17:31 -07:00
image_inject_bootchain 2345.0.0 2019-12-04 14:59:11 +01:00
image_set_group 2317.0.1 2019-11-07 19:40:01 +01:00
image_to_vm.sh Move cros_vm_constants to build_library 2021-08-27 14:20:54 +02:00
LICENSE ROADMAP: add initial overall CoreOS roadmap document 2015-04-30 16:58:53 -07:00
NOTICE feat(*): initial commit 2014-01-19 12:25:11 -08:00
prune_images prune_images: keep newer-than-latest builds 2015-11-24 13:40:09 -08:00
README.md README.md: one more Scripts => scripts 2021-11-26 17:54:43 +01:00
rebuild_packages *: Drop jobs parameter 2021-02-17 13:26:36 +01:00
run_sdk_container run/build_sdk_container: support Podman 2022-01-06 18:05:24 +01:00
set_official *: remove restart_in_chroot_if_needed 2018-05-30 13:07:58 -07:00
set_shared_user_password.sh Added password arg to set_shared_user_password.sh 2012-07-25 10:50:08 -07:00
set_version ci-automation + setup_board: publish and use binpkgs 2022-01-07 17:16:44 +01:00
settings.env ci-automation + setup_board: publish and use binpkgs 2022-01-07 17:16:44 +01:00
setup_board sdk-container: add scripts for containerised SDK 2021-11-26 17:54:43 +01:00
tag_release 2317.0.1 2019-11-07 19:40:01 +01:00
update_chroot update_chroot: Add a way to remove hard blockers 2021-12-10 20:06:40 +01:00
update_distfiles update_distfiles: upload to both old and new buckets 2016-04-27 12:48:20 -07:00
update_ebuilds update_ebuilds: Do not generate metadata/md5-cache files 2020-07-28 15:18:16 +02:00
update_metadata update_metadata: continue if there are no updates to commit. 2014-06-20 17:30:15 -07:00

Flatcar Container Linux SDK scripts

Welcome to the scripts repo, your starting place for most things here in the Flatcar Container Linux SDK. To get started you can find our documentation on the Flatcar docs website.

The SDK can be used to

  • Patch or update applications or libraries included in the Flatcar OS image
  • Add or remove applications and / or libraries
  • Modify the kernel configuration and add or remove kernel modules included with Flatcar
  • Build OS images for a variety of targets (qemu, bare metal, AWS, Azure, VMWare, etc.)
  • And lastly, the SDK can be used to upgrade SDK packages and to build new SDKs

Using the scripts repository: submodules and tags

The repository is meant to be the entry point for Flatcar builds and development. For building packages, there are 2 additional repositories, coreos-overlay and portage-stable, which contain all packages' ebuild (build configuration) files. These repositories are included in scripts via git submodules and are used by the SDK container wrapper scripts detailed on further below. The submodules reside in:

scripts
   +--sdk_container
          +---------src
                     +--third_party
                             +------coreos-overlay
                             +------portage-stable

When working with the scripts repo always make sure to initialise and to update these submodules; otherwise builds will break because build configuration is missing:

$ git clone --recurse-submodules https://github.com/flatcar-linux/scripts.git

The scripts repository makes ample use of tags to mark releases. Sometimes, local and origin tags can diverge (e.g. when re-tagging something locally to test a build). Also, git pull and git fetch do not automatically pull new tags, so long-standing local sourcetrees may lack newer versions. To fetch and update all tags and to remove tags locally which have been deleted upstream, do

$ git pull --all --tags --prune --prune-tags

If upstream retagged (of if a tag was changed locally) the corresponding upstream tag will not be pulled so the local tag remains. In order to override local tags with upstream, run

$ git pull --all --tags --prune --prune-tags --force

Using the SDK container

We provide a containerised SDK via https://github.com/orgs/flatcar-linux/packages. The container comes in 3 flavours:

  • Full SDK initialised with both architectures supported by Flatcar (amd64 and arm64). This is the largest container, it's about 8GB in size (~3 GB compressed).
  • AMD64 SDK initialised for building AMD64 OS images. About 6GB in size (2GB compressed).
  • ARM64 SDK initialised for building ARM64 OS images on AMD64 hosts. Also about 6GB in size. While work on a native ARM64 native SDK is ongoing, it's unfortunately not ready yet. If you want to help, patches are welcome!

The container can be run in one of two ways - "standalone", or integrated with the scripts repo:

  • Standalone mode will use no host volumes and will allow you to play with the SDK in a sandboxed throw-away environment. In standalone mode, you interface with Docker directly to use the SDK container.
  • Integrated mode will closely integrate with the scripts repo directory and bind-mount it as well as the portage-stable and coreos-overlay gitmodules into the container. Integrated mode uses wrapper scripts to interact with the SDK container. This is the recommended way for developing patches for Flatcar.

Standalone mode

In standalone mode, the SDK is just another Docker container. Interaction with the container happens via use of docker directly. Use for experimenting and for throw-away work only, otherwise please use integrated mode (see below).

  • Check the list of available versions and pick a version to use. The SDK Major versions correspond to Flatcar Major release versions. List of images: https://github.com/orgs/flatcar-linux/packages/container/package/flatcar-sdk-all For the purpose of this example we'll use version 3033.0.0.
  • Fetch the container image: docker pull ghcr.io/flatcar-linux/flatcar-sdk-all:3033.0.0
  • Start the image in interactive (tty) mode: docker run -ti ghcr.io/flatcar-linux/flatcar-sdk-all:3033.0.0 You are now inside the SDK container (the hostname will likely differ): sdk@f236fda982a4 ~/trunk/src/scripts $
  • Initialise the SDK in self-contained mode. This needs to be done once per container and will check out the scripts, coreos-overlay, and portage-stable repositories into the container. sdk@f236fda982a4 ../sdk_init_selfcontained.sh

You can now work with the SDK container.

Privileged mode when building images

In order to build OS images (via ./build_image and ./image_to_vm) the SDK tooling requires privileged access to /dev. This is necessary because the SDK currently employs loop devices to create and to partition OS images.

To start a container in privileged mode with /dev available use:

  • docker run -ti --privileged -v /dev:/dev ghcr.io/flatcar-linux/flatcar-sdk-all:3033.0.0

Integrated mode

This is the preferred mode of working with the SDK. Interaction with the container happens via wrapper scripts from the scripts repository. Both the host's scripts repo as well as its submodules (portage-stable and coreos-overlay) are made available in the container, allowing for work on these repos directly. The wrapper scripts will re-use existing containers instead of creating new ones to preserve your work in the container, enabling consistency.

To clone the scripts repo and pick a version:

  • Clone the scripts repo: git clone https://github.com/flatcar-linux/scripts.git
  • Optionally, check out a release tag to base your work on
    • list releases (e.g. all Alpha releases): git tag -l alpha-*
    • check out the release version, e.g. 3033.0.0: git checkout 3033.0.0
  • Make sure to initialise and fetch git submodules - Flatcar's ebuilds are in 2 separate repositories, connected to scripts via submodules.
    • git submodule init; git submodule update

To use the SDK container:

  • Fetch image and start the SDK container: ./run_sdk_container -t This will fetch the container image of the "scripts" repo's release version you checked out. The -t command line flag will allocate a TTY, which is preferred for interactive use. The command will put you into the SDK container: sdk@sdk-container ~/trunk/src/scripts $
  • Alternatively, you can run individual commands in the SDK container using ./run_sdk_container <command> (e.g. ./run_sdk_container ./build_packages).

Subsequent calls to ./run_sdk_container will re-use the container (as long as the local release version check-out the scripts repo does not change). Check out docker container ls --all and you'll see something like

CONTAINER ID   IMAGE                                            COMMAND                  CREATED       STATUS                         PORTS     NAMES
19ea3b6d00ad   ghcr.io/flatcar-linux/flatcar-sdk-all:3033.0.0   "/bin/sh -c /home/sd…"   4 hours ago   Exited (0) About an hour ago             flatcar-sdk-all-3033.0.0_os-3033.0.0

Re-use of containers happens on a per-name basis. The above example's container name flatcar-sdk-all-3033.0.0_os-3033.0.0 is generated automatically. Using docker container rm the container can be discarded - a subsequent call to ./run_sdk_container will create a new one. Custom containers can be created by use of the -n <name> command line option; these will be re-used in subsequent calls to ./run_sdk_container when using the same <name>.

The local sourcetree can also be used with an entirely custom SDK container image. Users must ensure that the image is either fetch-able or present locally. The custom image can be specified using -C <custom-image>. This option is useful e.g. for building the local sourcetree with different SDK versions.

Check out ./run_sdk_container -h for more information on command line options.

Building a new SDK container

Building an SDK container is done using ./build_sdk_container_image <tarball>. The tarball input is the result of an SDK bootstrap (see below). Version information for both OS as well as for the SDK will be extracted from the tarball name. The version file will be updated accordingly before the SDK container is built. During the build, toolchain packages will be built and installed into the SDK container image. Both supported boards (amd64-usr and arm64-usr) will be initialised in the container image.

Bootstrapping a new SDK tarball using the SDK container

The script ./bootstrap_sdk_container bootstraps a new SDK tarball using an existing SDK container and seed tarball. Specifying the seed version as well as the designated new SDK version is required for this script.

Automation stubs for continuous integration

Script stubs for various build stages can be found in the ci-automation folder. These are helpful for gluing Flatcar Container Linux builds to a continuous integration system.