Skip to content

Commit 09785e4

Browse files
committed
feat: multiarch
1 parent a4cac9b commit 09785e4

8 files changed

Lines changed: 171 additions & 101 deletions

File tree

‎.github/workflows/docker-image-factory.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ jobs:
6363
org.opencontainers.image.created=${{ github.run_id }}
6464
org.opencontainers.image.version=${{ steps.vars.outputs.tag }}
6565
#platforms: linux/amd64,linux/arm64,linux/arm/v7
66+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-image-factory:buildcache
67+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-image-factory:buildcache,mode=max

‎.github/workflows/docker-system.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
org.opencontainers.image.created=${{ github.run_id }}
6363
org.opencontainers.image.version=${{ steps.vars.outputs.tag }}
6464
#platforms: linux/amd64,linux/arm64,linux/arm/v7
65+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system:buildcache
66+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system:buildcache,mode=max
6567

6668
- name: Build and push Docker image - cuos-system-rpi-arm64
6769
uses: docker/build-push-action@v6
@@ -77,6 +79,8 @@ jobs:
7779
org.opencontainers.image.created=${{ github.run_id }}
7880
org.opencontainers.image.version=${{ steps.vars.outputs.tag }}
7981
platforms: linux/arm64
82+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system-rpi-arm64:buildcache
83+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system-rpi-arm64:buildcache,mode=max
8084

8185
- name: Build and push Docker image - cuos-system-lxc
8286
uses: docker/build-push-action@v6
@@ -92,3 +96,5 @@ jobs:
9296
org.opencontainers.image.created=${{ github.run_id }}
9397
org.opencontainers.image.version=${{ steps.vars.outputs.tag }}
9498
#platforms: linux/amd64,linux/arm64,linux/arm/v7
99+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system-lxc:buildcache
100+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-system-lxc:buildcache,mode=max

‎.github/workflows/docker-updater.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ jobs:
6161
org.opencontainers.image.revision=${{ github.sha }}
6262
org.opencontainers.image.created=${{ github.run_id }}
6363
org.opencontainers.image.version=${{ steps.vars.outputs.tag }}
64-
#platforms: linux/amd64,linux/arm64,linux/arm/v7
64+
platforms: linux/amd64,linux/arm64
65+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-updater:buildcache
66+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cuos-updater:buildcache,mode=max

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
old/
44
output/
55
/system*.json
6+
.docker_config.json

‎system/Dockerfile.rpi-arm64‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ ENTRYPOINT ["sh", "-c", "rm -f /.dockerenv; trap 'echo Received SIGTERM; exit 0'
88
COPY seccomp-default.json /etc/docker/
99
COPY raspberrypi-archive.gpg /etc/apt/keyrings/
1010

11+
RUN echo "rpi-arm64" >"/etc/cuos-arch" \
12+
&& mkdir -p /boot/firmware && \
13+
cat <<'EOF' > "/boot/firmware/config.txt"
14+
dtparam=audio=on
15+
camera_auto_detect=1
16+
display_auto_detect=1
17+
auto_initramfs=1
18+
dtoverlay=vc4-kms-v3d
19+
max_framebuffers=2
20+
disable_fw_kms_setup=1
21+
arm_64bit=1
22+
disable_overscan=1
23+
arm_boost=1
24+
25+
[cm4]
26+
otg_mode=1
27+
28+
[cm5]
29+
dtoverlay=dwc2,dr_mode=host
30+
31+
[all]
32+
EOF
33+
1134
RUN apt-get update && apt-get install --no-install-recommends -y \
1235
ca-certificates curl lsb-release apt-transport-https \
1336
busybox-static parted dosfstools e2fsprogs \

‎system/cuos/do-rollback.sh‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,37 @@ set -x
55
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
66

77
if [[ ! -f "/system_next.json" ]]; then
8-
echo "Rollback not possible. No previous system."
9-
exit 1
8+
echo "Rollback not possible. No previous system."
9+
exit 1
1010
fi
1111

1212
VIRT_TYPE="$(systemd-detect-virt)"
1313
if [[ "${VIRT_TYPE}" = "lxc" ]]; then
14-
"${SCRIPT_DIR}/do-rollback-lxc.sh" "$@"
15-
exit "$?"
14+
"${SCRIPT_DIR}/do-rollback-lxc.sh" "$@"
15+
exit "$?"
1616
fi
1717

1818
# shellcheck source=/dev/null
1919
source "${SCRIPT_DIR}/utils.sh"
2020

21+
OS_ARCH="$(cat /etc/cuos-arch 2>/dev/null || arch)"
22+
2123
TARGET_BOOT_PARTITION="${TARGET_BOOT_PARTITION:-"LABEL=boot"}"
2224
TARGET_BOOT="${TARGET_BOOT:-"/mnt/boot"}"
2325
GRUB_CFG_PATH="${TARGET_BOOT}/grub/grub.cfg"
2426

2527
mkdir -p "${TARGET_BOOT}"
2628
mount -t vfat "${TARGET_BOOT_PARTITION}" "${TARGET_BOOT}" || {
27-
echo "Failed to mount /boot. Is the boot partition available?"
28-
exit 1
29+
echo "Failed to mount /boot. Is the boot partition available?"
30+
exit 1
2931
}
3032

3133
CURRENT_PARTITION="$(cat "/etc/partition_mode" 2>/dev/null || echo "A")"
3234
PARTITION="A"
3335
PARTITION_ID=0
3436
if [[ "${CURRENT_PARTITION}" == "A" ]]; then
35-
PARTITION="B"
36-
PARTITION_ID=1
37+
PARTITION="B"
38+
PARTITION_ID=1
3739
fi
3840

3941
REASON="$1"
@@ -44,29 +46,38 @@ state '.state' 'rollback'
4446
state jq '.last_update_date = (now | todate)'
4547
state '.update_state' "rollback to partition ${PARTITION} (${REASON})"
4648

47-
PARTITION_NAME="$(grep "menuentry " "${TARGET_BOOT}/${PARTITION}_grub.cfg" | head -n 1 | cut -d "'" -f 2)"
48-
if [[ -z "${PARTITION_NAME}" ]]; then
49-
PARTITION_NAME="${PARTITION_ID}"
50-
fi
49+
if [[ "${OS_ARCH}" == "rpi"* ]]; then
50+
51+
if [[ -f "${TARGET_BOOT}"/cmdline-previous.txt ]]; then
52+
mv "${TARGET_BOOT}"/cmdline.txt "${TARGET_BOOT}"/cmdline-tmp.txt
53+
mv "${TARGET_BOOT}"/cmdline-previous.txt "${TARGET_BOOT}"/cmdline.txt
54+
mv "${TARGET_BOOT}"/cmdline-tmp.txt "${TARGET_BOOT}"/cmdline-previous.txt
55+
fi
5156

52-
{
53-
cat <<EOF
57+
else
58+
PARTITION_NAME="$(grep "menuentry " "${TARGET_BOOT}/${PARTITION}_grub.cfg" | head -n 1 | cut -d "'" -f 2)"
59+
if [[ -z "${PARTITION_NAME}" ]]; then
60+
PARTITION_NAME="${PARTITION_ID}"
61+
fi
62+
63+
{
64+
cat <<EOF
5465
set timeout=1
5566
load_video
5667
set gfxpayload=keep
5768
EOF
58-
cat "${TARGET_BOOT}"/{A,B}_grub.cfg 2>/dev/null
59-
60-
echo "set default=\"${PARTITION_NAME}\""
61-
} > "$GRUB_CFG_PATH"
69+
cat "${TARGET_BOOT}"/{A,B}_grub.cfg 2>/dev/null
6270

71+
echo "set default=\"${PARTITION_NAME}\""
72+
} > "$GRUB_CFG_PATH"
73+
fi
6374

6475
sync
6576

6677
umount "${TARGET_BOOT}" || umount -l "${TARGET_BOOT}" || {
6778
echo "Warning: Failed to unmount ${TARGET_BOOT}. Is it busy?"
6879
}
69-
echo "GRUB configuration updated for partition ${PARTITION_NAME}."
80+
echo "Boot configuration updated for partition ${PARTITION_NAME}."
7081

7182
echo "Rebooting ..."
7283
reboot

‎system/cuos/do-update.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ UPDATE_IMAGE="$(image_url "updater")" || \
2121
action_on_failure "cuos:updater:image_not_defined" "Updater image not defined"
2222
UPDATE_IMAGE_DIGEST="$(jq -r '.updater_image_digest // empty' "${CONFIG_PATH}")"
2323

24-
OS_IMAGE="$(image_url "os")" || \
24+
OS_ARCH="$(cat "/etc/cuos-arch" 2>/dev/null || arch)"
25+
26+
OS_IMAGE="$(image_url "${OS_ARCH}" || image_url "os")" || \
2527
action_on_failure "cuos:updater:os_image_not_defined" "OS image not defined"
26-
OS_DIGEST="$(jq -r '.os_image_digest // empty' "${CONFIG_PATH}")"
28+
OS_DIGEST="$(jq -r --arg arch "${OS_ARCH}" '.[$arch+"_image_digest"] // .os_image_digest // empty' "${CONFIG_PATH}")"
2729

2830
IMAGE_VERSION_STRING="${OS_IMAGE}@${OS_DIGEST}"
2931

@@ -65,6 +67,7 @@ docker run --rm \
6567
-v "/usr/local/share/ca-certificates/custom:/usr/local/share/ca-certificates/custom:ro" \
6668
-v "/etc/image:/etc/image:ro" \
6769
-e "TARGET_DEVICE=${ROOT_DISK}" \
70+
-e "OS_ARCH=${OS_ARCH}" \
6871
--name dockerboot-updater-container \
6972
"${UPDATE_IMAGE}" \
7073
"${PARTITION}" "${OS_IMAGE}" "${OS_DIGEST}"

0 commit comments

Comments
 (0)