Skip to content

Commit

Permalink
Merge pull request #77 from Magnitus-/master
Browse files Browse the repository at this point in the history
More Composability
  • Loading branch information
DieterReuter committed Mar 31, 2018
2 parents 51a118d + a3f9aa1 commit fec4bf9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 34 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
FROM hypriot/image-builder:latest

ENV HYPRIOT_OS_VERSION=v1.2.6 \
RAW_IMAGE_VERSION=v0.2.2

#Note that the checksums and build timestamps only apply when fetching missing
#artifacts remotely is enabled to validate downloaded remote artifacts
ENV FETCH_MISSING_ARTIFACTS=true \
ROOT_FS_ARTIFACT=rootfs-arm64-debian-$HYPRIOT_OS_VERSION.tar.gz \
KERNEL_ARTIFACT=4.9.80-hypriotos-v8.tar.gz \
BOOTLOADER_ARTIFACT=rpi-bootloader.tar.gz \
RAW_IMAGE_ARTIFACT=rpi-raw.img.zip \
DOCKER_ENGINE_VERSION="18.03.0~ce" \
DOCKER_COMPOSE_VERSION="1.20.1" \
DOCKER_MACHINE_VERSION="0.13.0" \
KERNEL_VERSION="4.9.80" \
ROOTFS_TAR_CHECKSUM="737c914f5d457772072cba8a647b31b564bcb2e896870e087f5ed6ccbcc9a1e9" \
RAW_IMAGE_CHECKSUM="2fbeb13b7b0f2308dbd0d82780b54c33003ad43d145ff08498b25fb8bbe1c2c6" \
BOOTLOADER_BUILD="20180320-071222" \
KERNEL_BUILD="20180319-130037"

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
binfmt-support \
Expand Down
58 changes: 40 additions & 18 deletions builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ if [ ! -f /.dockerenv ]; then
exit 1
fi

# get versions for software that needs to be installed
# shellcheck disable=SC1091
source /workspace/versions.config

### setting up some important variables to control the build process

# place to store our created sd-image file
Expand All @@ -18,7 +14,7 @@ BUILD_RESULT_PATH="/workspace"
# place to build our sd-image
BUILD_PATH="/build"

ROOTFS_TAR="rootfs-arm64-debian-${HYPRIOT_OS_VERSION}.tar.gz"
ROOTFS_TAR=${ROOT_FS_ARTIFACT}
ROOTFS_TAR_PATH="${BUILD_RESULT_PATH}/${ROOTFS_TAR}"

# Show TRAVSI_TAG in travis builds
Expand All @@ -35,26 +31,44 @@ mkdir ${BUILD_PATH}

# download our base root file system
if [ ! -f "${ROOTFS_TAR_PATH}" ]; then
wget -q -O "${ROOTFS_TAR_PATH}" "https://github.com/hypriot/os-rootfs/releases/download/${HYPRIOT_OS_VERSION}/${ROOTFS_TAR}"
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
wget -q -O "${ROOTFS_TAR_PATH}" "https://github.com/hypriot/os-rootfs/releases/download/${HYPRIOT_OS_VERSION}/${ROOTFS_TAR}"
else
echo "Missing artifact ${ROOT_FS_ARTIFACT}"
exit 255
fi
fi

# verify checksum of our root filesystem
echo "${ROOTFS_TAR_CHECKSUM} ${ROOTFS_TAR_PATH}" | sha256sum -c -
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
# verify checksum of our root filesystem
echo "${ROOTFS_TAR_CHECKSUM} ${ROOTFS_TAR_PATH}" | sha256sum -c -
fi

# extract root file system
tar xf "${ROOTFS_TAR_PATH}" -C "${BUILD_PATH}"

# extract/add additional files
FILENAME=/workspace/rpi-bootloader.tar.gz
FILENAME=/workspace/$BOOTLOADER_ARTIFACT
if [ ! -f "$FILENAME" ]; then
fetch --repo="https://github.com/DieterReuter/rpi-bootloader" --tag="v$BOOTLOADER_BUILD" --release-asset="rpi-bootloader.tar.gz.sha256" /workspace
fetch --repo="https://github.com/DieterReuter/rpi-bootloader" --tag="v$BOOTLOADER_BUILD" --release-asset="rpi-bootloader.tar.gz" /workspace
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
fetch --repo="https://github.com/DieterReuter/rpi-bootloader" --tag="v$BOOTLOADER_BUILD" --release-asset="rpi-bootloader.tar.gz.sha256" /workspace
fetch --repo="https://github.com/DieterReuter/rpi-bootloader" --tag="v$BOOTLOADER_BUILD" --release-asset="rpi-bootloader.tar.gz" /workspace
else
echo "Missing artifact ${BOOTLOADER_ARTIFACT}"
exit 255
fi
fi
tar -xf "$FILENAME" -C "${BUILD_PATH}"
FILENAME=/workspace/$KERNEL_VERSION-hypriotos-v8.tar.gz

FILENAME=/workspace/$KERNEL_ARTIFACT
if [ ! -f "$FILENAME" ]; then
fetch --repo="https://github.com/DieterReuter/rpi64-kernel" --tag="v$KERNEL_BUILD" --release-asset="$KERNEL_VERSION-hypriotos-v8.tar.gz.sha256" /workspace
fetch --repo="https://github.com/DieterReuter/rpi64-kernel" --tag="v$KERNEL_BUILD" --release-asset="$KERNEL_VERSION-hypriotos-v8.tar.gz" /workspace
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
fetch --repo="https://github.com/DieterReuter/rpi64-kernel" --tag="v$KERNEL_BUILD" --release-asset="$KERNEL_VERSION-hypriotos-v8.tar.gz.sha256" /workspace
fetch --repo="https://github.com/DieterReuter/rpi64-kernel" --tag="v$KERNEL_BUILD" --release-asset="$KERNEL_VERSION-hypriotos-v8.tar.gz" /workspace
else
echo "Missing artifact ${KERNEL_ARTIFACT}"
exit 255
fi
fi
tar -xf "$FILENAME" -C "${BUILD_PATH}"

Expand Down Expand Up @@ -97,13 +111,21 @@ tar -czf /image_with_kernel_root.tar.gz -C ${BUILD_PATH} .
du -sh ${BUILD_PATH}
ls -alh /image_with_kernel_*.tar.gz

RAW_IMAGE=${RAW_IMAGE_ARTIFACT%.*}
# download the ready-made raw image for the RPi
if [ ! -f "${BUILD_RESULT_PATH}/${RAW_IMAGE}.zip" ]; then
wget -q -O "${BUILD_RESULT_PATH}/${RAW_IMAGE}.zip" "https://github.com/hypriot/image-builder-raw/releases/download/${RAW_IMAGE_VERSION}/${RAW_IMAGE}.zip"
if [ ! -f "${BUILD_RESULT_PATH}/${RAW_IMAGE_ARTIFACT}" ]; then
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
wget -q -O "${BUILD_RESULT_PATH}/${RAW_IMAGE_ARTIFACT}" "https://github.com/hypriot/image-builder-raw/releases/download/${RAW_IMAGE_VERSION}/${RAW_IMAGE}.zip"
else
echo "Missing artifact ${RAW_IMAGE_ARTIFACT}"
exit 255
fi
fi

# verify checksum of the ready-made raw image
echo "${RAW_IMAGE_CHECKSUM} ${BUILD_RESULT_PATH}/${RAW_IMAGE}.zip" | sha256sum -c -
if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
# verify checksum of the ready-made raw image
echo "${RAW_IMAGE_CHECKSUM} ${BUILD_RESULT_PATH}/${RAW_IMAGE_ARTIFACT}" | sha256sum -c -
fi

unzip -p "${BUILD_RESULT_PATH}/${RAW_IMAGE}" > "/${HYPRIOT_IMAGE_NAME}"

Expand Down
8 changes: 8 additions & 0 deletions builder/chroot-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ chmod +x usr/local/bin/rpi-serial-console
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

if [ "$FETCH_MISSING_ARTIFACTS" == "true" ]; then
# set device label and version number
cat <<EOF >> /etc/os-release
HYPRIOT_BOOTLOADER_BUILD="${BOOTLOADER_BUILD}"
Expand All @@ -273,4 +274,11 @@ HYPRIOT_KERNEL_VERSION="${KERNEL_VERSION}"
HYPRIOT_DEVICE="$HYPRIOT_DEVICE"
HYPRIOT_IMAGE_VERSION="$HYPRIOT_IMAGE_VERSION"
EOF
else
cat <<EOF >> /etc/os-release
HYPRIOT_KERNEL_VERSION="${KERNEL_VERSION}"
HYPRIOT_DEVICE="$HYPRIOT_DEVICE"
HYPRIOT_IMAGE_VERSION="$HYPRIOT_IMAGE_VERSION"
EOF
fi
cp /etc/os-release /boot/os-release
16 changes: 0 additions & 16 deletions versions.config

This file was deleted.

0 comments on commit fec4bf9

Please sign in to comment.