Skip to content

Commit

Permalink
Remove python image dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
timower committed Oct 3, 2023
1 parent 2da9b2e commit 5925ba4
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 68 additions & 0 deletions get_update.sh
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions updates.json
Original file line number Diff line number Diff line change
@@ -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-"
}

0 comments on commit 5925ba4

Please sign in to comment.