mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-26 17:01:06 +00:00
9540ed415b
We've been using tar directly on the base image folder, and this makes the file ordering unpredictable between filesystems, so we use find and sort so that the files are always tarred in the same order, producing the same hash in different filesystems. We also now set the mtime to the specific Unix timestamp 0, to avoid differences due to timezones. Also remove the dest folder before calculating the hash. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
60 lines
1.6 KiB
Bash
Executable File
60 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
|
|
# ARCH, ESCAPED_BRANCH_NAME, BASE_IMAGE_REPO and BASE_IMAGE_TAG should be set before calling this script.
|
|
# This script purposefully doesn't clean up the BASE_IMAGE_TAG docker image after building it.
|
|
|
|
JENKINS_PERSISTENT_WORKDIR=${1:-/var/lib/yocto}
|
|
DL_DIR="$JENKINS_PERSISTENT_WORKDIR/shared-downloads"
|
|
mkdir dest
|
|
|
|
BUILDER_REPO=registry.resinstaging.io/resin/${ARCH}-supervisor-base-builder
|
|
BUILDER_IMAGE=${BUILDER_REPO}:${ESCAPED_BRANCH_NAME}
|
|
|
|
docker pull ${BUILDER_IMAGE} || docker pull ${BUILDER_REPO}:master || true
|
|
docker build -t ${BUILDER_IMAGE} .
|
|
docker push ${BUILDER_IMAGE} || true
|
|
|
|
case "$ARCH" in
|
|
'amd64')
|
|
machine='generic-x86-64'
|
|
;;
|
|
'i386')
|
|
machine='generic-x86'
|
|
;;
|
|
'rpi')
|
|
machine='generic-armv6'
|
|
;;
|
|
'armv7hf')
|
|
machine='generic-armv7hf'
|
|
;;
|
|
'armel')
|
|
machine='generic-armv5'
|
|
;;
|
|
esac
|
|
SSTATE_DIR="$JENKINS_PERSISTENT_WORKDIR/$machine/sstate"
|
|
# Make sure shared directories are in place
|
|
mkdir -p $DL_DIR
|
|
mkdir -p $SSTATE_DIR
|
|
|
|
docker run --rm \
|
|
-e TARGET_MACHINE=$machine \
|
|
-e BUILDER_UID=$(id -u) \
|
|
-e BUILDER_GID=$(id -g) \
|
|
-v `pwd`:/source \
|
|
-v $DL_DIR:/yocto/shared-downloads \
|
|
-v $SSTATE_DIR:/yocto/shared-sstate \
|
|
-v `pwd`/dest:/dest \
|
|
${BUILDER_IMAGE}
|
|
docker rmi -f $(docker inspect -f "{{.Id}}" ${BUILDER_IMAGE}) || true
|
|
if [ -f dest/rootfs.tar.gz ]; then
|
|
docker import dest/rootfs.tar.gz ${BASE_IMAGE_TAG}
|
|
docker tag ${BASE_IMAGE_TAG} ${BASE_IMAGE_REPO}:${ESCAPED_BRANCH_NAME} || docker tag -f ${BASE_IMAGE_TAG} ${BASE_IMAGE_REPO}:${ESCAPED_BRANCH_NAME}
|
|
docker push ${BASE_IMAGE_TAG}
|
|
else
|
|
echo "rootfs is missing!"
|
|
exit 1
|
|
fi
|