From 5925ba4e26d2d3b9292ecdbd7f20bbeed2a0537a Mon Sep 17 00:00:00 2001 From: Timothy Werquin Date: Tue, 3 Oct 2023 23:59:55 +0200 Subject: [PATCH] Remove python image dependency --- Dockerfile | 23 +++++++++++------ get_update.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ updates.json | 27 ++++++++++++++++++++ 3 files changed, 110 insertions(+), 8 deletions(-) create mode 100755 get_update.sh create mode 100644 updates.json diff --git a/Dockerfile b/Dockerfile index a7ccb9c..2bf0140 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,24 +29,31 @@ RUN make O=imx7 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j $(nproc) && \ rm -rf imx7 # Step 2: rootfs -FROM python:3 as rootfs +FROM linuxkit/guestfs:f85d370f7a3b0749063213c2dd451020e3a631ab AS rootfs WORKDIR /opt +ARG TARGETARCH # Install dependencies +ADD https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-${TARGETARCH} \ + /usr/local/bin/jq + RUN apt-get update && \ - apt-get install -y qemu-utils libguestfs-tools && \ - git clone -b 1695743393 https://github.com/Jayy001/codexctl.git /opt/codexctl && \ - pip3 install -r /opt/codexctl/requirements.txt && \ - pip3 install protobuf && \ + apt-get install -y --no-install-recommends \ + git \ + python3 \ + python3-protobuf && \ + chmod +x /usr/local/bin/jq && \ git clone https://github.com/ddvk/stuff.git /opt/stuff ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python +ADD get_update.sh /opt +ADD updates.json /opt + ARG fw_version=3.5.2.1807 -RUN python /opt/codexctl/codexctl.py download $fw_version && \ - mv updates/*.signed /opt/fw.signed && \ - python /opt/stuff/extractor/extractor.py /opt/fw.signed /opt/rootfs.ext4 +RUN /opt/get_update.sh download $fw_version && \ + python3 /opt/stuff/extractor/extractor.py /opt/fw.signed /opt/rootfs.ext4 # Make the rootfs image ADD make_rootfs.sh /opt diff --git a/get_update.sh b/get_update.sh new file mode 100755 index 0000000..18e3492 --- /dev/null +++ b/get_update.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +set -eu + +action="$1" +fw_version="${2:-3}" + +get_url() { + fw_info=$(jq "[to_entries.[] | select(.key | startswith(\"$1\"))] | max_by(.key)" updates.json) + + if [ "$fw_info" = "null" ] + then + echo "Unknown version $1" + exit 1 + fi + + fw_hash=$(echo "$fw_info" | jq --raw-output '.value') + fw_ver=$(echo "$fw_info" | jq --raw-output '.key') + fw_major=$(echo "$fw_ver" | cut -d '.' -f 1) + + + fw_url="" + if [ "$fw_major" = "3" ] + then + fw_url="https://updates-download.cloud.remarkable.engineering/build/reMarkable%20Device/reMarkable2" + else + fw_url="https://updates-download.cloud.remarkable.engineering/build/reMarkable%20Device%20Beta/RM110" + fi + + fw_url="$fw_url/$fw_ver/${fw_ver}_reMarkable2-$fw_hash.signed" +} + +download_fw() { + get_url "$1" + + echo "Downloading $fw_ver from:" + echo " $fw_url" + curl -f -o fw.signed "$fw_url" +} + + +check_fw() { + get_url "$1" + echo "Checking $fw_ver at $fw_url" + curl -f -I "$fw_url" +} + +check_all() { + all_fw=$(jq --raw-output 'keys[]' updates.json) + for f in $all_fw + do + check_fw "$f" + done +} + +case $action in + download) + download_fw "$fw_version" + ;; + check) + check_fw "$fw_version" + ;; + check-all) + check_all + ;; + *) + ;; +esac diff --git a/updates.json b/updates.json new file mode 100644 index 0000000..0b0603d --- /dev/null +++ b/updates.json @@ -0,0 +1,27 @@ +{ + "3.6.1.1894": "T2dkdktE1H", + "3.6.0.1865": "7wgexMSZP5-", + "3.5.2.1807": "3bZjC0Xn5C-", + "3.5.1.1798": "9CfoVp8qCU-", + "3.4.1.1790": "rYfHxYmwC8-", + "3.4.0.1784": "fD3GCOcU9m-", + "3.3.2.1666": "ihUirIf133-", + "3.2.3.1595": "fTtpld3Mvn-", + "3.2.2.1581": "dwyp884gLP-", + "3.0.4.1305": "tdwbuIzhYP-", + "2.15.1.1189": "wVbHkgKisg-", + "2.15.0.1067": "lyC7KAjjSB-", + "2.14.3.977": "joPqAABTAW-", + "2.14.3.958": "B7yhC887i1-", + "2.14.3.1047": "RGLmy8Jb39-", + "2.14.3.1005": "4HCZ7J2Bse-", + "2.14.1.866": "JLWa2mnXu1-", + "2.14.0.861": "TfpToxrexR-", + "2.13.0.758": "2N5B5nvpZ4-", + "2.12.3.606": "XOSYryyJXI-", + "2.12.2.573": "XnE1EL7ojK-", + "2.12.1.527": "8OkCxOJFn9-", + "2.11.0.442": "tJDDwsDM4V-", + "2.10.3.379": "n16KxgSfCk-", + "2.10.2.356": "JLB6Ax3hnJ-" +}