Skip to content

Commit 2ad110e

Browse files
committed
Use codexctl to download rootfs, add 3.20
1 parent 9a1740a commit 2ad110e

3 files changed

Lines changed: 62 additions & 24 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ jobs:
1818
packages: write
1919
strategy:
2020
matrix:
21-
fw_version: ['2.15.1', '3.3.2', '3.5.2', '3.8.3', '3.11.2']
21+
os:
22+
- version: '2.15.1.1189'
23+
target: qemu-toltec
24+
- version: '3.3.2.1666'
25+
target: qemu-toltec
26+
- version: '3.8.2.1965'
27+
target: qemu-toltec
28+
- version: '3.20.0.92'
29+
target: qemu-base
30+
2231
steps:
2332
- name: Set up Docker Buildx
2433
uses: docker/setup-buildx-action@v3
@@ -37,17 +46,17 @@ jobs:
3746
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3847
flavor: |
3948
latest=auto
40-
suffix=-${{ matrix.fw_version }},onlatest=true
49+
suffix=-${{matrix.os.target}}-${{ matrix.os.version }},onlatest=true
4150
4251
- name: Build
4352
uses: docker/build-push-action@v5
4453
with:
4554
push: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}
4655
tags: ${{ steps.meta.outputs.tags }}
47-
target: qemu-toltec
56+
target: ${{ matrix.os.target }}
4857
cache-from: type=gha
4958
cache-to: type=gha,mode=max
5059
build-args: |
51-
fw_version=${{ matrix.fw_version }}
60+
fw_version=${{ matrix.os.version }}
5261
5362

Dockerfile

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,27 @@ FROM linuxkit/guestfs:f85d370f7a3b0749063213c2dd451020e3a631ab AS rootfs
3939
WORKDIR /opt
4040
ARG TARGETARCH
4141

42-
# Install dependencies
43-
ADD https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-${TARGETARCH} \
44-
/usr/local/bin/jq
42+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4543

44+
# Install dependencies
4645
RUN apt-get update && \
4746
apt-get install -y --no-install-recommends \
4847
git \
49-
python3 \
50-
python3-protobuf && \
51-
chmod +x /usr/local/bin/jq && \
52-
git clone https://github.com/ddvk/stuff.git /opt/stuff
53-
54-
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
55-
56-
ADD get_update.sh /opt
57-
ADD updates.json /opt
48+
build-essential \
49+
pkg-config \
50+
fuse \
51+
libfuse-dev \
52+
libz-dev && \
53+
uv venv --python 3.13
5854

5955
ARG fw_version
60-
RUN /opt/get_update.sh download $fw_version && \
61-
python3 /opt/stuff/extractor/extractor.py /opt/fw.signed /opt/rootfs.ext4
56+
RUN uv pip install https://github.com/Jayy001/codexctl.git && \
57+
.venv/bin/codexctl download $fw_version --hardware rm2 --out /tmp/firmware && \
58+
.venv/bin/codexctl extract --out /opt/rootfs.ext4 /tmp/firmware/*
6259

6360
# Make the rootfs image
6461
ADD make_rootfs.sh /opt
65-
RUN ./make_rootfs.sh /opt/rootfs.ext4
62+
RUN ./make_rootfs.sh /opt/rootfs.ext4 $fw_version
6663

6764
# Step3: Qemu!
6865
FROM debian:bookworm AS qemu-debug
@@ -92,7 +89,7 @@ RUN run_vm -serial null -daemonize && \
9289
VOLUME /opt/root
9390

9491
# SSH access
95-
EXPOSE 22/tcp
92+
EXPOSE 2222/tcp
9693
# Qemu monitor TCP port
9794
EXPOSE 5555/tcp
9895
# For rm2fb

make_rootfs.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
set -eux
44

55
ROOTFS=$1
6+
FW_VERSION=${2:-""}
7+
8+
# Extract major.minor version for comparison
9+
get_version_parts() {
10+
echo "$1" | cut -d '.' -f 1,2
11+
}
12+
13+
# Check if firmware version is >= 3.12
14+
should_skip_dhcpcd() {
15+
if [ -z "$FW_VERSION" ]; then
16+
return 1 # Don't skip if no version provided
17+
fi
18+
19+
version_parts=$(get_version_parts "$FW_VERSION")
20+
major=$(echo "$version_parts" | cut -d '.' -f 1)
21+
minor=$(echo "$version_parts" | cut -d '.' -f 2)
22+
23+
if [ "$major" -gt 3 ] || ([ "$major" -eq 3 ] && [ "$minor" -ge 12 ]); then
24+
return 0 # Skip dhcpcd modification
25+
else
26+
return 1 # Don't skip
27+
fi
28+
}
629

730
qemu-img create -f qcow2 rootfs.qcow2 8G
831

@@ -26,14 +49,23 @@ download /etc/fstab /tmp/fstab
2649
! sed -i 's/mmcblk2/mmcblk1/' /tmp/fstab
2750
upload /tmp/fstab /etc/fstab
2851
29-
download /lib/systemd/system/dhcpcd.service /tmp/dhcpcd.service
30-
! sed -i 's/wlan/eth/' /tmp/dhcpcd.service
31-
upload /tmp/dhcpcd.service /lib/systemd/system/dhcpcd.service
32-
3352
mount /dev/sda4 /home
3453
cp-a /etc/skel /home/root
3554
3655
ln-s /dev/null /etc/systemd/system/remarkable-fail.service
3756
3857
GFS
3958

59+
# Handle dhcpcd.service modification for firmware versions < 3.12
60+
if ! should_skip_dhcpcd; then
61+
echo "Modifying dhcpcd.service for firmware version $FW_VERSION"
62+
guestfish --rw --add rootfs.qcow2 <<DHCPCD_GFS
63+
run
64+
mount /dev/sda2 /
65+
download /lib/systemd/system/dhcpcd.service /tmp/dhcpcd.service
66+
! sed -i 's/wlan/eth/' /tmp/dhcpcd.service
67+
upload /tmp/dhcpcd.service /lib/systemd/system/dhcpcd.service
68+
DHCPCD_GFS
69+
else
70+
echo "Skipping dhcpcd.service modification for firmware version $FW_VERSION (>= 3.12)"
71+
fi

0 commit comments

Comments
 (0)