Files
operating-system/buildroot-external/package/hassio/create-data-partition.sh
Stefan Agner 762f098c14 Use skopeo and DIND to download container images (#1561)
* Use skopeo to download container images

Separate container download from image build. This will allow to share
the downloaded images between multiple builds.

We won't store the Supervisor container with the version tag, just with
the latest tag. This allows to simplify the procedure a bit. It seems
there is no downside to this approach.

* Use official Docker in Docker images to build data partition

Instead of building our own Debian based image let's use the official
Docker in Docker image. This avoids building an image for the hassio
data partition and speeds up build as well.

This calls mount commands using sudo to mount the data partition as part
of the buildroot build now. This is not much different from before as
mount has been called as root inside the container, essentially equates
to the same "isolation" level.

* Use image digest as part of the file name

The landing page has no version information in the tag. To avoid
potentially source caching issues, use the digest as part of the file
name.
2021-10-04 10:06:26 +02:00

33 lines
875 B
Bash
Executable File

#!/usr/bin/env bash
set -e
build_dir=$1
dst_dir=$2
data_img="${dst_dir}/data.ext4"
# Make image
rm -f "${data_img}"
truncate --size="1280M" "${data_img}"
mkfs.ext4 -L "hassos-data" -E lazy_itable_init=0,lazy_journal_init=0 "${data_img}"
# Mount / init file structs
mkdir -p "${build_dir}/data/"
sudo mount -o loop,discard "${data_img}" "${build_dir}/data/"
# Use official Docker in Docker images
# Ideally we use the same version as Buildroot is using in case the
# overlayfs2 storage format changes
container=$(docker run --privileged -e DOCKER_TLS_CERTDIR="" \
-v "${build_dir}/data/":/data \
-v "${build_dir}/data/docker/":/var/lib/docker \
-v "${build_dir}":/build \
-d docker:20.10-dind --storage-driver overlay2)
docker exec "${container}" sh /build/dind-import-containers.sh
docker stop "${container}"
# Unmount data image
sudo umount "${build_dir}/data/"