diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13acdda..037d7bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,7 @@ jobs: uses: arduino/setup-protoc@v3 with: version: "25.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout the Git repository uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -60,6 +61,7 @@ jobs: uses: arduino/setup-protoc@v3 with: version: "25.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Checkout the Git repository uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -139,39 +141,31 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build with nuitka run: | - docker run \ - --rm \ - --platform=linux/arm/v7 \ - -v "${src_path}":/src \ - eeems/nuitka-arm-builder:bullseye-3.11 \ - bash -ec "$script" \ + set -e + ./make_for_remarkable.sh portable \ | while read -r line; do - if [[ "$line" == 'Nuitka'*':ERROR:'* ]]; then + if [[ "$line" == 'Nuitka'*':ERROR:'* ]] || [[ "$line" == "ERROR:"* ]]; then echo "::error file=${{ steps.args.outputs.main_file }},title=Nuitka Error::$line" - elif [[ "$line" == 'Nuitka'*':WARNING:'* ]]; then + elif [[ "$line" == 'Nuitka'*':WARNING:'* ]] || [[ "$line" == "WARNING:"* ]]; then echo "::warning file=${{ steps.args.outputs.main_file }},title=Nuitka Warning::$line" - elif [[ "$line" == 'Nuitka:INFO:'* ]]; then + elif [[ "$line" == 'Nuitka:INFO:'* ]] || [[ "$line" == "INFO:"* ]]; then echo "$line" else echo "::debug::$line" fi done - env: - src_path: ${{ github.workspace }} - script: | - apt update - apt install -y \ - protobuf-compiler \ - libfuse-dev - cp -a /opt/lib/nuitka .venv - source /opt/lib/nuitka/bin/activate - pip install --upgrade pip - make -C /src executable + working-directory: ${{ github.workspace }} - uses: actions/upload-artifact@v4 with: name: rmufuse-remarkable path: dist if-no-files-found: error + - name: Sanity check + uses: Eeems-Org/run-in-remarkable-action@v1 + with: + fw_version: 2.15.1 + run: ./rmufuse-portable --help + path: dist build-wheel: name: Build wheel with python ${{ matrix.python }} needs: [test] @@ -192,6 +186,7 @@ jobs: uses: arduino/setup-protoc@v3 with: version: "25.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install build tool run: pip install build - name: Building package @@ -217,6 +212,7 @@ jobs: uses: arduino/setup-protoc@v3 with: version: "25.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install build tool run: pip install build - name: Building package @@ -283,6 +279,10 @@ jobs: name="rmufuse-${{ matrix.artifact }}" mv rmufuse "$name" gh release upload "$TAG" "$name" --clobber + elif [ -f rmufuse-portable ]; then + name="rmufuse-${{ matrix.artifact }}" + mv rmufuse-portable "$name" + gh release upload "$TAG" "$name" --clobber else find . -type f | xargs -rI {} gh release upload "$TAG" {} --clobber fi diff --git a/.gitignore b/.gitignore index 228ca04..aacf6dd 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,4 @@ cython_debug/ #.idea/ *.orig .nuitka/ +nuitka-crash-report.xml diff --git a/Makefile b/Makefile index f9c38fa..15df403 100644 --- a/Makefile +++ b/Makefile @@ -82,10 +82,12 @@ 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); \ - python -m pip install --extra-index-url=https://wheels.eeems.codes/ nuitka; \ + python -m pip install \ + --extra-index-url=https://wheels.eeems.codes/ \ + wheel \ + nuitka; \ NUITKA_CACHE_DIR="$(realpath .)/.nuitka" \ python -m nuitka \ --enable-plugin=pylint-warnings \ @@ -97,11 +99,35 @@ dist/rmufuse: dist $(VENV_BIN_ACTIVATE) $(OBJ) --noinclude-unittest-mode=allow \ --assume-yes-for-downloads \ --python-flag=-m \ - --remove-output \ --output-dir=dist \ + --remove-output \ --output-filename=rmufuse \ remarkable_update_fuse +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" \ + python -m nuitka \ + --enable-plugin=pylint-warnings \ + --enable-plugin=upx \ + --warn-implicit-exceptions \ + --onefile \ + --lto=yes \ + --assume-yes-for-downloads \ + --python-flag=-m \ + --output-dir=dist \ + --remove-output \ + --output-filename=rmufuse-portable \ + '--include-data-files=$(shell pkgconf --variable=libdir fuse)/libfuse.so=libfuse.so.2' \ + '--include-data-files=$(shell pkgconf --variable=libdir libssl)/libssl.so=libssl.so.1' \ + '--include-data-files=$(shell pkgconf --variable=libdir libcrypto)/libcrypto.so=libcrypto.so.3' \ + remarkable_update_fuse + patchelf --print-needed dist/rmufuse-portable + $(VENV_BIN_ACTIVATE): requirements.txt @echo "Setting up development virtual env in .venv" python -m venv .venv @@ -141,9 +167,11 @@ test: $(VENV_BIN_ACTIVATE) .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed $(O . $(VENV_BIN_ACTIVATE); \ python test.py -executable: $(VENV_BIN_ACTIVATE) dist/rmufuse +executable: dist/rmufuse dist/rmufuse --help +portable: dist/rmufuse-portable + all: release lint: $(VENV_BIN_ACTIVATE) @@ -168,6 +196,7 @@ format-fix: $(VENV_BIN_ACTIVATE) clean \ dev \ executable \ + portable \ install \ release \ sdist \ diff --git a/README.md b/README.md index 09712a7..bedea5e 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,10 @@ 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 ``` + +### Building for the reMarkable (Or really any linux/arm/v7 device) + +The same as above, but use `./make_for_remarkable.sh` instead of `make`. This requires docker to be installed. diff --git a/make_for_remarkable.sh b/make_for_remarkable.sh new file mode 100755 index 0000000..535b067 --- /dev/null +++ b/make_for_remarkable.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e +qemu_arm_flags=$(grep flags: /proc/sys/fs/binfmt_misc/qemu-arm | cut -d' ' -f2) +if ! echo "$qemu_arm_flags" | grep -q F; then + echo "INFO: Enabling linux/arm/v7 docker builds with qmeu" + docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7 +fi +script=" +apt update +apt install -y \\ + protobuf-compiler \\ + libfuse-dev \\ + pkgconf +cp -a /opt/lib/nuitka /src/.venv +source /src/.venv/bin/activate +pip install --upgrade pip build +make -C /src \"\$@\" +" +docker run \ + --rm \ + --platform=linux/arm/v7 \ + -v "$(pwd)":/src \ + eeems/nuitka-arm-builder:bullseye-3.11 \ + bash -ec "$script" -- "$@"