Skip to content

Commit

Permalink
Merge pull request #68 from Jayy001/rewrite
Browse files Browse the repository at this point in the history
Rewrite: Added documentation and cleared up code into an OOP design
  • Loading branch information
Jayy001 authored Dec 8, 2024
2 parents 90daa85 + 4566faf commit 48806e4
Show file tree
Hide file tree
Showing 24 changed files with 3,099 additions and 2,639 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ jobs:
- name: Test codexctl
shell: bash
run: make test
- name: Make script executable
run: chmod +x ./scripts/github-make-executable.sh
- name: Build codexctl
shell: bash
run: ./github-make-executable.sh
run: ./scripts/github-make-executable.sh
env:
nuitka_cache: ${{ github.workspace }}/.nuitka
- name: Upload Compilation Report
Expand All @@ -89,9 +91,6 @@ jobs:
name: ${{ matrix.os }}-compilation-report
path: compilation-report.xml
if-no-files-found: warn
- name: Test Built version
shell: bash
run: make test-executable
- name: Move .ccache
shell: bash
run: |
Expand All @@ -103,7 +102,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: dist/codexctl.bin
path: dist/codexctl
if-no-files-found: error
- name: Upload executable
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -145,7 +144,8 @@ jobs:
libfuse-dev
cd /src
source /opt/lib/nuitka/bin/activate
./github-make-executable.sh
chmod +x ./scripts/github-make-executable.sh
./scripts/github-make-executable.sh
- name: Upload Compilation Report
uses: actions/upload-artifact@v4
if: runner.debug == '1'
Expand All @@ -157,7 +157,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: remarkable
path: dist/codexctl.bin
path: dist/codexctl
if-no-files-found: error
test_device:
name: Test for reMarkable ${{ matrix.fw_version }}
Expand All @@ -179,8 +179,8 @@ jobs:
path: artifacts
fw_version: ${{ matrix.fw_version }}
run: |
chmod +x ./codexctl.bin
./codexctl.bin download --out /tmp toltec
chmod +x ./codexctl
./codexctl download --hardware rm2 --out /tmp toltec
release:
name: Release
needs: [remote,device,test_device]
Expand Down Expand Up @@ -210,4 +210,4 @@ jobs:
tag: ${{ env.TAG }}
commit: ${{ github.sha }}
generateReleaseNotes: true
makeLatest: true
makeLatest: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ updates/
rm-docker/
nuitka-crash-report.xml
.nuitka/
compilation-report.xml
compilation-report.xml
1,348 changes: 674 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else
ifeq ($(VENV_BIN_ACTIVATE),)
VENV_BIN_ACTIVATE := .venv/bin/activate
endif
CODEXCTL_BIN := codexctl.bin
CODEXCTL_BIN := codexctl
endif

OBJ := $(wildcard codexctl/**)
Expand All @@ -33,20 +33,20 @@ $(VENV_BIN_ACTIVATE): requirements.remote.txt requirements.txt
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
--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"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python -m codexctl download --out .venv ${FW_VERSION}
python -m codexctl download --hardware rm2 --out .venv ${FW_VERSION}

test: $(VENV_BIN_ACTIVATE) .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed
@echo "[info] Running test"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python test.py; \
python tests/test.py; \
if [[ "linux" == "$$(python -c 'import sys;print(sys.platform)')" ]]; then \
if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
umount -ql .venv/mnt; \
Expand Down Expand Up @@ -97,7 +97,7 @@ executable: $(VENV_BIN_ACTIVATE)
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
--extra-index-url=https://wheels.eeems.codes/ \
nuitka==2.4.8
@echo "[info] Building codexctl"
@set -e; \
Expand All @@ -108,7 +108,9 @@ executable: $(VENV_BIN_ACTIVATE)
--remove-output \
--output-dir=dist \
--report=compilation-report.xml \
codexctl.py
--output-filename=codexctl \
main.py

if [ -d dist/codexctl.build ]; then \
rm -r dist/codexctl.build; \
fi
Expand All @@ -122,4 +124,4 @@ all: executable
executable \
clean \
test \
test-executable
test-executable
96 changes: 41 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,74 @@
# Codexctl
A utility program that helps to manage the remarkable device version utilizing [ddvks update server](https://github.com/ddvk/remarkable-update)

## Caveat for downgrading to a version below 3.11

## PLEASE READ BEFORE USING
If your remarkable device is at version >= 3.11, codexctl will not be able to automatically install updates on it due to a major overhaul in the update engine. You can still use the other functions like downloading the image files and then manually extracting it, using `dd` to write to the other partition and then using the `restore` command. More information can be found in https://github.com/Jayy001/codexctl/issues/71#issuecomment-2099115757.
---
If your reMarkable device is above 3.11 and you want to downgrade to a version below 3.11, codexctl cannot do this currently. Please refer to #71 for manual instructions.

## Installation & Use
## Installation

You can find pre-compiled binaries on the [releases](https://github.com/Jayy001/codexctl/releases/) page. This includes a build for the reMarkable itself, as well as well as builds for linux, macOS, and Windows. It currently only has support for **command line interfaces** but a graphical interface is soon to come.
You can find pre-compiled binaries on the [releases](https://github.com/Jayy001/codexctl/releases/) page. This includes a build for the reMarkable itself, as well as well as builds for linux, macOS, and Windows. Alternatively, you can install directly from pypi with `pip install codexctl`. Codexctl currently only has support for a **command line interfaces** but a graphical interface is soon to come.

### Usage
Finally, if you want to build it yourself, you can run `make executable` which requires python 3.11 or newer, python-venv and pip. Linux also requires libfuse-dev.

The script is designed to have as little interactivity as possible, meaning arguments are directly taken from the command to run the script.
## General useage

```
❯ codexctl --help
usage: Codexctl app [-h] [--debug] [--rm1] [--auth AUTH] [--verbose] {install,download,backup,extract,mount,status,restore,list} ...
usage: Codexctl [-h] [--verbose] [--address ADDRESS] [--password PASSWORD]
{install,download,backup,cat,ls,extract,mount,upload,status,restore,list} ...
positional arguments:
{install,download,backup,extract,mount,status,restore,list}
{install,download,backup,cat,ls,extract,mount,upload,status,restore,list}
install Install the specified version (will download if not available on the device)
download Download the specified version firmware file
backup Download remote files to local directory
extract Extract the specified version update file
cat Cat the contents of a file inside a firmware image
ls List files inside a firmware image
extract Extract the specified version firmware file
mount Mount the specified version firmware filesystem
upload Upload folder/files to device (pdf only)
status Get the current version of the device and other information
restore Restores to previous version installed on device
list List all versions available for use
list List all available versions
options:
-h, --help show this help message and exit
--debug Print debug info
--rm1 Use rm1
--auth AUTH Specify password or SSH key for SSH
--verbose Enable verbose logging
--verbose, -v Enable verbose logging
--address ADDRESS, -a ADDRESS
Specify the address of the device
--password PASSWORD, -p PASSWORD
Specify password or path to SSH key for remote access
```

### Examples
## Examples
- Installing the latest for device (will automatically figure out the version)
```
codexctl install latest # Downloads and installs latest version
codexctl download toltec # Downloads latest version that has full support for toltec
codexctl download 3.0.4.1305 --rm1 # Downloads 3.0.4.1305 firmware file for remarkable 1
codexctl status # Prints current & previous version (can only be used when running on device itself)
codexctl list # Lists all available versions
codexctl restore # Restores previous version
codexctl --verbose # Enables logging
codexctl --backup # Exports all files to local directory
codexctl --backup -l root -r FM --no-recursion --no-overwrite # Exports all files from FM directory to root folder on localhost
codexctl extract 3.8.0.1944_reMarkable2-7eGpAv7sYB.signed # Extracts contents to filesystem named "extracted"
codexctl mount extracted /opt/remarkable # Mounts extracted filesystem to /opt/remarkable
codexctl ls 3.8.0.1944_reMarkable2-7eGpAv7sYB.signed / # Lists the root directory of the update image
codexctl cat 3.8.0.1944_reMarkable2-7eGpAv7sYB.signed /etc/version # Outputs the contents of /etc/version from the update image
codexctl install latest
```

## Running from source

Codexctl can be run from source on both the reMarkable, as well as on a remote device.

### Running on reMarkable

- Downloading rmpp version 3.15.4.2 to a folder named `out` and then installing it
```
git clone https://github.com/Jayy001/codexctl.git
cd codexctl
pip install -r requirements.txt
python codexctl.py --help
codexctl download 3.0.4.1305 -hw rmpp -o out
codexctl install ./out/remarkable-ct-prototype-image-3.15.4.2-ferrari-public.swu
```

### Running on a remote device

This requires python 3.11 or newer.

- Backing up all documents to the cwd
```
codexctl backup
```
git clone https://github.com/Jayy001/codexctl.git
cd codexctl
pip install wheel
pip install -r requirements.remote.txt
python codexctl.py --help
- Backing up only documents in a folder named "FM" to cwd, without overwriting any current files
```
codexctl backup -l root -r FM --no-recursion --no-overwrite
```
- Getting the version of the device and then switching to previous version (restore only for rm1/rm2)
```
codexctl status
codexctl restore
```
- Download 3.8.0.1944 for rm2, then cat the /etc/version file from it
```
codexctl download 3.8.0.1944 --hardware rm2
codexctl cat 3.8.0.1944_reMarkable2-7eGpAv7sYB.signed /etc/version
```

## Building executables from source

This requires python 3.11 or newer, python-venv, pip. Linux also requires libfuse-dev.

```
make executable
```
Loading

0 comments on commit 48806e4

Please sign in to comment.