Skip to content

Commit

Permalink
Fixed tests, v2?
Browse files Browse the repository at this point in the history
v3

v3

Final

Please please

added cargo

finally fixed

finally fixed

Moved scripts

done
  • Loading branch information
Jayy001 committed Dec 8, 2024
1 parent de008da commit 2339864
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*

# Allow files and directories
!/builds/scripts
!/scripts

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- '*.py'
- data/**
- codexctl/**
- builds/scripts/**
- builds/github-make-executable.sh
- scripts/**
- github-make-executable.sh
- Makefile
- .github/workflows/main.yml
push:
Expand All @@ -22,8 +22,8 @@ on:
- '*.py'
- data/**
- codexctl/**
- builds/scripts/**
- builds/github-make-executable.sh
- scripts/**
- github-make-executable.sh
- Makefile
- .github/workflows/main.yml
workflow_dispatch:
Expand Down Expand Up @@ -74,9 +74,12 @@ jobs:
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Test codexctl
shell: bash
run: make test
- name: Build codexctl
shell: bash
run: ./builds/github-make-executable.sh
run: ./scripts/github-make-executable.sh
env:
nuitka_cache: ${{ github.workspace }}/.nuitka
- name: Upload Compilation Report
Expand All @@ -97,7 +100,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 @@ -136,10 +139,10 @@ jobs:
echo "[info] Installing build dependencies"
apt update
apt install -y \
libfuse-dev
libfuse-dev rustc cargo
cd /src
source /opt/lib/nuitka/bin/activate
./builds/github-make-executable.sh
./scripts/github-make-executable.sh
- name: Upload Compilation Report
uses: actions/upload-artifact@v4
if: runner.debug == '1'
Expand All @@ -151,7 +154,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 @@ -173,8 +176,8 @@ jobs:
path: artifacts
fw_version: ${{ matrix.fw_version }}
run: |
chmod +x ./codexctl.bin
./codexctl.bin download --hardware rm2 --out /tmp toltec
chmod +x ./codexctl
./codexctl download --hardware rm2 --out /tmp toltec
release:
name: Release
needs: [remote,device,test_device]
Expand Down
File renamed without changes.
32 changes: 17 additions & 15 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 @@ -25,45 +25,46 @@ OBJ += README.md

$(VENV_BIN_ACTIVATE): requirements.remote.txt requirements.txt
@echo "[info] Setting up development virtual env in .venv"
python3 -m venv --system-site-packages .venv
python -m venv --system-site-packages .venv
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python3 -m pip install wheel
python -m pip install wheel
@echo "[info] Installing dependencies"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python3 -m pip install \
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"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python3 -m codexctl download --hardware rm2 --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); \
python3 tests/test.py; \
if [[ "linux" == "$$(python3 -c 'import sys;print(sys.platform)')" ]]; then \
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; \
fi; \
mkdir -p .venv/mnt; \
python3 -m codexctl mount --out .venv/mnt ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed"; \
python -m codexctl mount --out .venv/mnt ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed"; \
mountpoint .venv/mnt; \
umount -ql .venv/mnt; \
fi; \
python3 -m codexctl extract --out ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.img" ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed"; \
python -m codexctl extract --out ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.img" ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed"; \
echo "${IMG_SHA} .venv/${FW_VERSION}_reMarkable2-${FW_DATA}.img" | sha256sum --check; \
rm -f ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.img"; \
set -o pipefail; \
if ! diff --color <(python3 -m codexctl ls ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed" / | tr -d "\n\r") <(echo -n ${LS_DATA}) | cat -te; then \
if ! diff --color <(python -m codexctl ls ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed" / | tr -d "\n\r") <(echo -n ${LS_DATA}) | cat -te; then \
echo "codexctl ls failed test"; \
exit 1; \
fi; \
if ! diff --color <(python3 -m codexctl cat ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed" /etc/version | tr -d "\n\r") <(echo -n ${CAT_DATA}) | cat -te; then \
if ! diff --color <(python -m codexctl cat ".venv/${FW_VERSION}_reMarkable2-${FW_DATA}.signed" /etc/version | tr -d "\n\r") <(echo -n ${CAT_DATA}) | cat -te; then \
echo "codexctl cat failed test"; \
exit 1; \
fi
Expand Down Expand Up @@ -95,20 +96,21 @@ executable: $(VENV_BIN_ACTIVATE)
@echo "[info] Installing Nuitka"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
python3 -m pip install \
python -m pip install \
--extra-index-url=https://wheels.eeems.codes/ \
nuitka==2.4.8
@echo "[info] Building codexctl"
@set -e; \
. $(VENV_BIN_ACTIVATE); \
NUITKA_CACHE_DIR="$(realpath .)/.nuitka" \
python3 -m nuitka \
python -m nuitka \
--assume-yes-for-downloads \
--remove-output \
--output-dir=dist \
--report=compilation-report.xml \
--output-filename=codexctl \
main.py
mv dist/main.bin dist/codexctl.bin
mv dist/codexctl.exe dist/codexctl.exe

if [ -d dist/codexctl.build ]; then \
rm -r dist/codexctl.build; \
fi
Expand Down
107 changes: 49 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,74 @@
# Codexctl
A utility program that helps to manage the remarkable device version utilizing [ddvks update server](https://github.com/ddvk/remarkable-update)

### Installation & Use
## Caveat for downgrading to a version below 3.11

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.
If youre remarkable device is above 3.11 and you want to downgrade to a version below 3.11, codexctl is not able to do this (at the moment). Please refer to #71 for manual instructions.

## Running from source
## Installation

Codexctl can be run from source on both the reMarkable, as well as on a remote device.
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.

### Running on reMarkable
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.

```
git clone https://github.com/Jayy001/codexctl.git
cd codexctl
pip install -r requirements.txt
python codexctl.py --help
```

### Running on a remote device

This requires python 3.11 or newer.

```
git clone https://github.com/Jayy001/codexctl.git
cd codexctl
pip install wheel
pip install -r requirements.remote.txt
python codexctl.py --help
```

## Building executables from source

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

```
make executable
```

## Usage

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 thge 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
```
- Downloading rmpp version 3.15.4.2 to a folder named `out` and then installing it
```
codexctl download 3.0.4.1305 -hw rm1 -o out
codexctl install ./out/remarkable-ct-prototype-image-3.15.4.2-ferrari-public.swu
```
- Backing up all documents to the cwd
```
codexctl backup
```
- 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
```



Loading

0 comments on commit 2339864

Please sign in to comment.