-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-rpi-armv7
executable file
·16 lines (13 loc) · 1.02 KB
/
build-rpi-armv7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
set -euo pipefail
AARCH_URL="${AARCH_URL:-http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz}"
archive="$(basename ${AARCH_URL})"
md5="$(< "${archive}".md5)"
if [[ ! -f "${archive}" ]] || [[ "$(md5sum "${archive}")" != "${md5}" ]]; then
wget -O "${archive}" "${AARCH_URL}"
[[ "$(md5sum "${archive}")" == "${md5}" ]] || { echo "Bad checksum for ${archive}" 1>&2; exit 1; }
fi
# extract date from gzip header
date="$(date --date=@"$(dd status=none bs=4 skip=1 count=1 < ArchLinuxARM-rpi-armv7-latest.tar.gz | od -t u4 -An | grep -Eo '[0-9]*')" -I)"
podman import --arch arm/v7 --os linux "${archive}" localhost/archlinuxarm/rpi-armv7-import:"${date}" -c LABEL=org.opencontainers.image.base.name="${AARCH_URL}" -c LABEL=org.opencontainers.image.base.date="${date}" -c LABEL=org.opencontainers.image.base.digest="$(cut -f 1 -d ' ' <<< "${md5}")"
podman build --cap-add=CAP_SYS_CHROOT -t localhost/archlinuxarm/rpi-armv7 docker-context-rpi-armv7 --build-arg BASE_IMAGE=localhost/archlinuxarm/rpi-armv7-import:"${date}"