Skip to content

Commit

Permalink
Merge branch 'main' into sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems authored Sep 8, 2024
2 parents b06847a + 3e152cd commit 2182c0b
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 753 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ on:
permissions: read-all
jobs:
test:
name: Test
name: Test with python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python:
- '3.11'
- '3.12'
steps:
- name: Install Apt packages
id: cache-apt
Expand All @@ -29,7 +34,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Cache test files
uses: actions/cache@v4
Expand Down Expand Up @@ -76,15 +81,19 @@ jobs:
path: dist
if-no-files-found: error
build-executable-alpine:
name: Build binary for alpine
name: Build binary for alpine ${{ matrix.alpine }}
needs: [test]
runs-on: ubuntu-latest
strategy:
matrix:
alpine:
- v3.19
steps:
- name: Checkout the Git repository
uses: actions/checkout@v4
- uses: jirutka/setup-alpine@v1
with:
branch: v3.18
branch: ${{ matrix.alpine }}
packages: >
build-base
python3
Expand All @@ -100,10 +109,11 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuitka
key: ${{ github.job }}-ccache-alpine-v3.18
key: ${{ github.job }}-ccache-alpine-${{ matrix.alpine }}
- name: Build with nuitka
shell: alpine.sh {0}
run: make executable
run: |
make executable
- uses: actions/upload-artifact@v4
with:
name: rmufuse-alpine
Expand Down Expand Up @@ -264,7 +274,7 @@ jobs:
name: ${{ matrix.artifact }}
path: dist
- name: Upload to release
run:
run: |
if [ -f rmufuse ]; then
name="rmufuse-${{ matrix.artifact }}"
mv rmufuse "$name"
Expand Down
71 changes: 43 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
.DEFAULT_GOAL := all
VERSION := $(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
PACKAGE := $(shell grep -m 1 name pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
CODEXCTL := https://github.com/Jayy001/codexctl/releases/download/1703028363/ubuntu-latest.zip
CODEXCTL_HASH := 5c3aa5f264f4ae95de6e259eb8d5da8f0d9c2d7eb3710adb0cf53bcb72dcb79a
CODEXCTL := https://github.com/Jayy001/codexctl/releases/download/1719419372/ubuntu-latest.zip
CODEXCTL_HASH := 210f68f8a2136120b706c29852f9b7ce306d6e30d2f6124eb23eb25e858685e5
FW_VERSION := 2.15.1.1189
FW_DATA := wVbHkgKisg-

PROTO_SOURCE := $(shell find protobuf -type f -name '*.proto')
PROTO_OBJ := $(addprefix $(PACKAGE),$(PROTO_SOURCE:%.proto=%_pb2.py))

OBJ := $(shell find ${PACKAGE} -type f)
OBJ += requirements.txt
OBJ += pyproject.toml
OBJ += README.md
OBJ += $(PROTO_OBJ)

define PLATFORM_SCRIPT
from sysconfig import get_platform
Expand Down Expand Up @@ -45,6 +41,10 @@ endef
export ABI_SCRIPT
ABI := $(shell python -c "$$ABI_SCRIPT")

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

clean:
if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
umount -ql .venv/mnt; \
Expand Down Expand Up @@ -82,35 +82,36 @@ dist/${PACKAGE}-${VERSION}.tar.gz: dist $(OBJ)
dist/${PACKAGE}-${VERSION}-${ABI}-${ABI}-${PLATFORM}.whl: dist $(OBJ)
python -m build --wheel


dist/rmufuse: dist .venv/bin/activate $(OBJ)
. .venv/bin/activate; \
dist/rmufuse: dist $(VENV_BIN_ACTIVATE) $(OBJ)
. $(VENV_BIN_ACTIVATE); \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
wheel \
nuitka; \
NUITKA_CACHE_DIR="$(realpath .)/.nuitka" \
nuitka3 \
python -m nuitka \
--enable-plugin=pylint-warnings \
--enable-plugin=upx \
--warn-implicit-exceptions \
--onefile \
--lto=yes \
--include-package=google \
--noinclude-unittest-mode=allow \
--assume-yes-for-downloads \
--python-flag=-m \
--output-dir=dist \
--remove-output \
--output-filename=rmufuse \
remarkable_update_fuse

dist/rmufuse-portable: dist .venv/bin/activate $(OBJ)
. .venv/bin/activate; \
dist/rmufuse-portable: dist $(VENV_BIN_ACTIVATE) $(OBJ)
$(VENV_BIN_ACTIVATE); \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
wheel \
nuitka; \
NUITKA_CACHE_DIR="$(realpath .)/.nuitka" \
nuitka3 \
python -m nuitka \
--enable-plugin=pylint-warnings \
--enable-plugin=upx \
--warn-implicit-exceptions \
Expand All @@ -127,14 +128,15 @@ dist/rmufuse-portable: dist .venv/bin/activate $(OBJ)
remarkable_update_fuse
patchelf --print-needed dist/rmufuse-portable

.venv/bin/activate: requirements.txt
$(VENV_BIN_ACTIVATE): requirements.txt
@echo "Setting up development virtual env in .venv"
python -m venv .venv
. .venv/bin/activate; \
. $(VENV_BIN_ACTIVATE); \
python -m pip install wheel ruff; \
python -m pip install --extra-index-url=https://wheels.eeems.codes/ -r requirements.txt


.venv/codexctl.zip: .venv/bin/activate
.venv/codexctl.zip: $(VENV_BIN_ACTIVATE)
curl -L "${CODEXCTL}" -o .venv/codexctl.zip

.venv/bin/codexctl.bin: .venv/codexctl.zip
Expand All @@ -149,27 +151,20 @@ dist/rmufuse-portable: dist .venv/bin/activate $(OBJ)
.venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed: .venv/bin/codexctl.bin
.venv/bin/codexctl.bin download --out .venv ${FW_VERSION}


$(PROTO_OBJ): $(PROTO_SOURCE)
protoc \
--python_out=$(PACKAGE) \
--proto_path=protobuf \
$(PROTO_SOURCE)

dev: .venv/bin/activate .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed $(OBJ)
dev: $(VENV_BIN_ACTIVATE) .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed $(OBJ)
if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
umount -ql .venv/mnt; \
fi
mkdir -p .venv/mnt
. .venv/bin/activate; \
. $(VENV_BIN_ACTIVATE); \
python -m remarkable_update_fuse \
-d \
-f \
.venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed \
.venv/mnt

test: .venv/bin/activate .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed $(OBJ)
. .venv/bin/activate; \
test: $(VENV_BIN_ACTIVATE) .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed $(OBJ)
. $(VENV_BIN_ACTIVATE); \
python test.py

executable: dist/rmufuse
Expand All @@ -179,6 +174,22 @@ portable: dist/rmufuse-portable

all: release

lint: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
python -m ruff check

lint-fix: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
python -m ruff check

format: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
python -m ruff format --diff

format-fix: $(VENV_BIN_ACTIVATE)
. $(VENV_BIN_ACTIVATE); \
python -m ruff format

.PHONY: \
all \
build \
Expand All @@ -190,4 +201,8 @@ all: release
release \
sdist \
wheel \
test
test \
lint \
lint-fix \
format \
format-fix
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,10 @@ rmufuse path/to/update_file.signed /mnt/signed
- Will report checksum errors for Directory inode, even though they are fine
- Will report checksum errors for extent headers, even though they are fine

## Programatic Usage

```python
from ext4 import Volume
from remarkable_update_fuse import UpdateImage

image = UpdateImage("path/to/update/file.signed")

# Extract raw ext4 image
with open("image.ext4", "wb") as f:
f.write(image.read())

# Extract specific file
volume = Volume(image)
inode = volume.inode_at("/etc/version")
with open("version", "wb") as f:
f.write(inode.open().read())
```

## Building
Dependencies:
- curl
- protoc
- python
- python-build
- python-pip
Expand All @@ -50,6 +32,7 @@ make # Build wheel and sdist packages in dist/
make wheel # Build wheel package in dist/
make sdist # Build sdist package in dist/
make dev # Test mounting 2.15.1.1189 to .venv/mnt
make test # Run automated tests
make install # Build wheel and install it with pipx or pip install --user
make executable # Build a standalone executable
make portable # Build a standalone executable with some extra dependencies embedded
Expand Down
Loading

0 comments on commit 2182c0b

Please sign in to comment.