Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount without extracting #56

Merged
merged 24 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 55 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ jobs:
remote:
name: Build for ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Install Apt packages
if: matrix.os == 'ubuntu-latest'
id: cache-apt
uses: awalsh128/cache-apt-pkgs-action@latest
with:
execute_install_scripts: true
packages: libfuse-dev
version: 1.0
- name: Checkout the Git repository
uses: actions/checkout@v4
- name: ccache
Expand All @@ -35,40 +47,25 @@ jobs:
nuitka_cache: ${{ github.workspace }}/.nuitka
- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install dependencies
- name: Test codexctl
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
pip install wheel
pip install -r requirements.remote.txt
pip install nuitka
run: make test
- name: Build codexctl
if: matrix.os == 'windows-latest'
shell: bash
run: |
mkdir -p dist
NUITKA_CACHE_DIR="$nuitka_cache" \
python -m nuitka \
--enable-plugin=pylint-warnings \
--onefile \
--lto=yes \
--assume-yes-for-downloads \
--remove-output \
--output-dir=dist \
codexctl.py 2>&1 \
| while read -r line; do
if [[ "$line" == 'Nuitka'*':ERROR:'* ]]; then
echo "::error file=${{ steps.args.outputs.main_file }},title=Nuitka Error::$line"
elif [[ "$line" == 'Nuitka'*':WARNING:'* ]]; then
echo "::warning file=${{ steps.args.outputs.main_file }},title=Nuitka Warning::$line"
elif [[ "$line" == 'Nuitka:INFO:'* ]]; then
echo "$line"
else
echo "::debug::$line"
fi
done
run: ./github-make-executable.sh
env:
nuitka_cache: ${{ github.workspace }}/.nuitka
VENV_BIN_ACTIVATE: .venv/Scripts/activate
- name: Build codexctl
if: matrix.os != 'windows-latest'
shell: bash
run: ./github-make-executable.sh
env:
nuitka_cache: ${{ github.workspace }}/.nuitka
- name: Move .ccache
Expand All @@ -83,15 +80,39 @@ jobs:
path: dist
if-no-files-found: error
device:
name: Build for reMarkable
name: Build for remarkable
runs-on: ubuntu-latest
steps:
- name: Checkout the codexctl repository
uses: actions/checkout@v4
- uses: Eeems-Org/remarkable-nuitka-build-action@v2
- name: Nuitka ccache
uses: actions/cache@v3
with:
main: codexctl.py
python_version: '3.9'
path: ${{ github.workspace }}/.nuitka
key: ${{ github.job }}-remarkable
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build executable
shell: bash
run: |
docker run \
--rm \
--platform=linux/arm/v7 \
-v "${src_path}":/src \
eeems/nuitka-arm-builder:bullseye-3.11 \
bash -ec "$script"
env:
src_path: ${{ github.workspace }}
script: |
echo "[info] Installing build dependencies"
apt update
apt install -y \
libfuse-dev
cd /src
source /opt/lib/nuitka/bin/activate
./github-make-executable.sh
- uses: actions/upload-artifact@v3
with:
name: remarkable
Expand All @@ -109,14 +130,13 @@ jobs:
with:
path: artifacts
name: remarkable
if-no-files-found: error
- uses: Eeems-Org/run-in-remarkable-action@v1
with:
path: artifacts
fw_version: ${{ matrix.fw_version }}
run: |
chmod +x ./codexctl.bin
./codexctl.bin --help
./codexctl.bin download --out /tmp toltec
release:
name: Release
needs: [remote,device,test_device]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ dmypy.json
updates/
rm-docker/
nuitka-crash-report.xml
.nuitka/
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.DEFAULT_GOAL := all
FW_VERSION := 2.15.1.1189
FW_DATA := wVbHkgKisg-
SHELL := /bin/bash

ifeq ($(VENV_BIN_ACTIVATE),)
VENV_BIN_ACTIVATE := .venv/bin/activate
endif

OBJ := $(shell find codexctl -type f)
OBJ += $(shell find data -type f)
OBJ += README.md

$(VENV_BIN_ACTIVATE): requirements.remote.txt requirements.txt
@echo "[info] Setting up development virtual env in .venv"
python -m venv .venv
@echo "[info] Installing dependencies"
. $(VENV_BIN_ACTIVATE); \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
-r requirements.remote.txt

.venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed: $(VENV_BIN_ACTIVATE) $(OBJ)
@echo "[info] Downloading remarkable update file"
. $(VENV_BIN_ACTIVATE); \
python -m codexctl download --out .venv ${FW_VERSION}

test: $(VENV_BIN_ACTIVATE) .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed
@echo "[info] Running test"
if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
umount -ql .venv/mnt; \
fi
mkdir -p .venv/mnt
. $(VENV_BIN_ACTIVATE); \
python -m codexctl mount --out .venv/mnt ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed"
mountpoint .venv/mnt
umount -ql .venv/mnt

clean:
@echo "[info] Cleaning"
if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
umount -ql .venv/mnt; \
fi
git clean --force -dX

executable: $(VENV_BIN_ACTIVATE)
@echo "[info] Installing Nuitka"
. $(VENV_BIN_ACTIVATE); \
python -m pip install --extra-index-url=https://wheels.eeems.codes/ wheel nuitka
@echo "[info] Building codexctl"
. $(VENV_BIN_ACTIVATE); \
NUITKA_CACHE_DIR="$(realpath .)/.nuitka" \
python -m nuitka \
--enable-plugin=pylint-warnings \
--enable-plugin=upx \
--warn-implicit-exceptions \
--onefile \
--lto=yes \
--assume-yes-for-downloads \
--remove-output \
--output-dir=dist \
codexctl.py
@echo "[info] Sanity check"
dist/codexctl.* --help

all: executable

.PHONY: \
all \
executable \
clean \
test
1 change: 0 additions & 1 deletion codexctl.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from codexctl import main

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1135: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1140: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1187: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1135: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1140: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/_bootstrap.py:1187: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/__init__.py:168: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/importlib/__init__.py:168: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1703: Will always raise exception: "TypeError(type() takes no keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1708: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1712: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1714: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1796: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1797: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\enum.py:1798: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\importlib\util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\importlib\util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for windows-latest

Nuitka Warning

Nuitka-Unusual:WARNING: C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\importlib\_bootstrap.py:1135: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1703: Will always raise exception: "TypeError(type() takes no keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1708: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1712: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1714: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1796: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1797: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1798: Will always raise exception: "UnboundLocalError(cannot access local variable 'enum_class' where it is not associated with a value)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/util.py:98: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

Check warning on line 1 in codexctl.py

View workflow job for this annotation

GitHub Actions / Build for macos-latest

Nuitka Warning

Nuitka-Unusual:WARNING: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py:1135: Will always raise exception: "TypeError(exceptions.ModuleNotFoundError does not take keyword arguments)"

if __name__ == "__main__":
main()
17 changes: 10 additions & 7 deletions codexctl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .sync import RmWebInterfaceAPI
from .updates import UpdateManager
from .server import startUpdate, scanUpdates
from .extractor import extract

REMOTE_DEPS_MET = True

Expand Down Expand Up @@ -561,24 +560,28 @@ def do_extract(args):
args.out = os.getcwd() + "/extracted"

logger.debug(f"Extracting {args.file} to {args.out}")
from remarkable_update_fuse import UpdateImage

try:
extract(args.file, args.out)
except Exception as error:
raise SystemExit(f"Error: {error}")
image = UpdateImage(args.file)
with open(args.out, "wb") as f:
f.write(image.read())


def do_mount(args):
if args.out is None:
args.out = f"/opt/remarkable/"
args.out = "/opt/remarkable/"

if not os.path.exists(args.out):
os.mkdir(args.out)

if not os.path.exists(args.filesystem):
raise SystemExit("Firmware file does not exist!")

os.system(f"mount -o loop {args.filesystem} {args.out}")
from remarkable_update_fuse import UpdateFS

server = UpdateFS()
server.parse(args=[args.filesystem, args.out], values=server, errex=1)
server.main()


def main():
Expand Down
4 changes: 4 additions & 0 deletions codexctl/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import main

if __name__ == "__main__":
main()
43 changes: 0 additions & 43 deletions codexctl/extractor.py

This file was deleted.

Loading
Loading