Skip to content

Commit

Permalink
Implement architecture separation
Browse files Browse the repository at this point in the history
This PR improves Toltec’s support for reMarkable 2 in a few ways:

* Prevents users from installing packages that are known to be
  incompatible with their device (fixes #129).
* Automatically installs and sets up the rm2fb server when an app that
  uses the framebuffer is installed.
* Stops relying on LD_PRELOAD to load the rm2fb shim into apps that need
  it. Instead, change their dynamic dependencies to include the shim
  directly. Thanks to this change, we no longer need to set LD_PRELOAD
  globally (fixes #248) and users can launch apps that need the shim
  without prefixing them with `rm2fb-client`.

Tooling changes (more details in the updated docs/package.md):

* Added the `archs` field for declaring which device(s) a recipe is
  compatible with. Supported values are `rmall` (for device-independent
  packages), `rm1` (for reMarkable 1) and `rm2` (for reMarkable 2).
  When multiple arch values are set for a recipe, the recipe is
  generated once per entry, which allows specializing builds for
  specific devices.
* Replaced the `depends` field with an `installdepends` field used for
  declaring install-time dependencies. Previously, dependencies declared
  in the `depends` field were fulfilled both at build time and at
  install time, with no way of declaring install-time-only dependencies.
* Added a `replaces` field that sets the `Replaces` value in the
  generated package. Used for migrating users from the `rm2fb` package
  to the `display` and `rm2fb-shim` packages (see below).
* Changed [the web package listing](https://toltec-dev.org/dev/split-architectures)
  to include download links for each available architecture of each
  package.
* Packages are now stored in subdirectories named after their
  architecture. This is because opkg does not like seeing packages for
  architectures other than the ones it is configured to accept in
  opkg.conf. With this layout change, we can make opkg happy by
  only adding subdirectories for enabled architectures.

Install changes:

* The bootstrap script now adds the `rmall` architecture (and folder) on
  all installs, and the `rm1` or `rm2` architecture (and folder)
  depending on the type of the device it’s executed on. It will fail if
  the device is not of a recognized type (based on the value of
  `/sys/devices/soc0/machine`).
* Running the new bootstrap script on an existing install will upgrade
  the configuration to use the new architecture subdirectories layout.

rm2fb changes:

* The package is split into two packages, `display` (which provides the
  rm2fb server on rM2 and is an empty package on rM1) and `rm2fb-shim`
  (which provides the client shim on rM2 and a mock shim on rM1).
* The `rm2fb-server` command is removed (the most common use-case being
  that the display server is started from the systemd unit).
* The `rm2fb-client` command is renamed to `rm2fb-shim`, with the
  expectation that users will not need it anymore, unless for
  development purposes.

Apps marked as reMarkable-1-only:

* appmarkable (LinusCDE/appmarkable#2)
* rmservewacominput (because it depends on appmarkable)
* vnsee (matteodelabre/vnsee#15)
* whiteboard-hypercard (fenollp/reMarkable-tools#12)

Apps marked as reMarkable-2-only:

* rm2-suspend-fix

Apps updated to include the rM2 shim:

* calculator
* chessmarkable
* draft
* fingerterm
* keywriter
* koreader (through setting LD_PRELOAD in the existing wrapper script)
* oxide
* plato
* recrossable
* remarkable-splash
* retris
* rmkit
* xochitl (through a new wrapper script at /opt/bin/xochitl)
* zshelf

Test plan (on rM1 and rM2):

* Starting from a clean stable or testing install of Toltec, download
  the updated bootstrap script and run:

```console
$ toltec_branch=dev/split-architectures bash bootstrap
```

* This should update the `/opt/etc/opkg.conf` configuration file to
  enable the `rmall` architecture and, depending on the device you’re
  running this on, the `rm1` or the `rm2` architecture.
* It should also replace the `src/gz toltec` line with two source lines,
  `src/gz toltec-rmall` and `src/gz toltec-rm1` or `src/gz toltec-rm2`,
  pointing to subfolders of
  `https://toltec-dev.org/dev/split-architectures`.
* Run `opkg upgrade`. Most installed packages should get upgraded, and
  if you had installed any packages that use the screen, the `display`
  and `rm2fb-shim` packages should get installed. If you previously
  installed the `rm2fb` package, it should get removed automatically.
* Try installing `rm2-suspend-fix` on a reMarkable 1, or `vnsee` on a
  reMarkable 2: both operations should fail.
* Test all updated packages to make sure they can properly draw to the
  screen (both on rM1 and rM2) and that you can interact with them
  through the touchscreen and the pen, when applicable.
* In particular, make sure that apps work properly when launched from
  draft, oxide or remux (some issues remain with oxide and remux).
  • Loading branch information
matteodelabre committed Mar 11, 2021
1 parent 5c62066 commit a9e270e
Show file tree
Hide file tree
Showing 48 changed files with 1,130 additions and 581 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $(RECIPES_PUSH): %:
if ! rsync --rsync-path /opt/bin/rsync \
--archive --verbose --compress --ignore-times \
$$(for pkg in $${pkgnames[@]}; do \
echo build/repo/"$$pkg"_*.ipk; \
echo build/repo/*/"$$pkg"_*.ipk; \
done) \
root@"$(HOST)":~/.cache/toltec/; then \
echo "rysnc exited with an error." \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![Status of the stable repository](https://github.com/toltec-dev/toltec/workflows/stable/badge.svg)
![Status of the testing repository](https://github.com/toltec-dev/toltec/workflows/testing/badge.svg)
[![rm1](https://img.shields.io/badge/rM1-supported-green)](https://remarkable.com/store/remarkable)
[![rm2](https://img.shields.io/badge/rM2-experimental-yellow)](https://remarkable.com/store/remarkable-2)
[![rm2](https://img.shields.io/badge/rM2-supported-green)](https://remarkable.com/store/remarkable-2)
[![Discord](https://img.shields.io/discord/463752820026376202.svg?label=reMarkable&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/ATqQGfu)

Toltec is a community-maintained repository of free software for [the reMarkable tablet](https://remarkable.com/).
Expand All @@ -15,7 +15,7 @@ To automatically install Opkg, Entware and Toltec, run the bootstrap script in a

```sh
$ wget http://toltec-dev.org/bootstrap
$ echo "5b494f5b98c4cb5f1d9836f966075026abf48a0cd320a99c026c4b18d76c8a0b bootstrap" | sha256sum -c && bash bootstrap
$ echo "cfe46148013869c2d7c72f221d3b4e86961a1556542430431299ce0078a30043 bootstrap" | sha256sum -c && bash bootstrap
```

> **Warning:**
Expand Down
333 changes: 180 additions & 153 deletions docs/package.md

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package/appmarkable/package
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

archs=(rm1)
pkgnames=(appmarkable)
pkgdesc="Front-end for apps that do not have a graphical user interface"
url="https://github.com/LinusCDE/appmarkable"
Expand All @@ -11,15 +12,17 @@ section="devel"
maintainer="Linus K. <linus@cosmos-ink.net>"
license=MIT

image=rust:v1.1
image=rust:v1.4
source=(https://github.com/LinusCDE/appmarkable/archive/b4226e896f441af9895ed5a4ff183af7f93b11ae.zip)
sha256sums=(0422cee28668d4e7ff554c26884e45ec63feff840eec92e6b8b2e8a7905a9d3b)

build() {
rm -r .cargo/
cargo build --release --target=armv7-unknown-linux-gnueabihf
# Fall back to system-wide config
rm .cargo/config
cargo build --release --bin appmarkable
}

package() {
install -D -m 755 "$srcdir"/target/armv7-unknown-linux-gnueabihf/release/appmarkable "$pkgdir"/opt/bin/appmarkable
install -D -m 755 -t "$pkgdir"/opt/bin \
"$srcdir"/target/armv7-unknown-linux-gnueabihf/release/appmarkable
}
15 changes: 11 additions & 4 deletions package/calculator/package
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(calculator)
pkgdesc="Touch-based calculator"
url=https://github.com/reHackable/Calculator
pkgver=0.0.0-13
pkgver=0.0.0-14
timestamp=2020-08-20T12:28Z
section="math"
maintainer="Mattéo Delabre <spam@delab.re>"
license=GPL-3.0-or-later
makedepends=(build:imagemagick build:librsvg2-bin)
installdepends=(display rm2fb-shim)
makedepends=(build:imagemagick build:librsvg2-bin build:patchelf)
flags=(nostrip)

image=qt:v1.1
image=qt:v1.4
source=(
https://github.com/reHackable/Calculator/archive/7b8be5de12f1536bc04b6216abbf26f998097bf4.zip
calculator.draft
Expand All @@ -28,6 +30,11 @@ build() {
qmake Calculator.pro
make

# Inject rm2fb shim after running strip, otherwise strip removes
# too much information
"${CROSS_COMPILE}strip" --strip-all Calculator
patchelf --add-needed librm2fb_client.so Calculator

convert +set date:create +set date:modify calculator.{svg,png}
}

Expand Down
21 changes: 16 additions & 5 deletions package/chessmarkable/package
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(chessmarkable)
pkgdesc="Chess game"
url=https://github.com/LinusCDE/chessmarkable
pkgver=0.6.0-3
pkgver=0.6.0-4
timestamp=2021-01-03T05:26Z
section="games"
maintainer="Linus K. <linus@cosmos-ink.net>"
license=MIT
installdepends=(display rm2fb-shim)
makedepends=(build:patchelf)
flags=(nostrip)

image=rust:v1.2.1
image=rust:v1.4
source=(https://github.com/LinusCDE/chessmarkable/archive/0.6.0-1.zip)
sha256sums=(3ad10a46da5a42f603947ad4dce960bdac2d646c0cd29b7bb3a60b8d308dd82a)

_target="armv7-unknown-linux-gnueabihf"

build() {
# Fall back to system-wide config
rm .cargo/config

cargo build --release --bin chessmarkable

# Inject rm2fb shim
# (after running strip, otherwise strip removes too much information)
pushd target/"$_target"/release
"${CROSS_COMPILE}strip" --strip-all chessmarkable
patchelf --add-needed librm2fb_client.so chessmarkable
popd
}

package() {
install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/target/armv7-unknown-linux-gnueabihf/release/chessmarkable
install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/target/"$_target"/release/chessmarkable
install -D -m 644 "$srcdir"/oxide "$pkgdir"/opt/etc/draft/chessmarkable
install -D -m 644 "$srcdir"/icon.png "$pkgdir"/opt/etc/draft/icons/chessmarkable.png
}
107 changes: 107 additions & 0 deletions package/display/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

archs=(rm1 rm2)
pkgnames=(display rm2fb-shim)
timestamp=2021-02-21T01:41+00:00
maintainer="raisjn <of.raisjn@gmail.com>"
license=MIT
url="https://github.com/ddvk/remarkable2-framebuffer"
pkgver=1.0.0-9
section="devel"

image=qt:v1.4
source=(
https://github.com/ddvk/remarkable2-framebuffer/archive/0724acfcc87c24ae2fcb45db4cad033981f3f4a9.zip
rm2fb.service
rm2fb-shim
)
sha256sums=(
bf398905f43e189671692325444e0cac131ab9856f215adabe6b8747aaa41351
SKIP
SKIP
)

build() {
if [[ $arch = rm1 ]]; then
# Create an empty client library for rM1
pushd src/client
echo | "${CROSS_COMPILE}gcc" \
-fPIC -fvisibility=hidden -shared \
-o librm2fb_client.so.${pkgver%-*} \
-xc -
popd
else
qmake
make
fi
}

display() {
pkgdesc="Interface to the reMarkable framebuffer"
conflicts=(rm2fb)
replaces=(rm2fb)

package() {
if [[ $arch = rm2 ]]; then
libname="librm2fb_server.so.${pkgver%-*}"
install -D -m 644 -t "$pkgdir"/opt/lib "$srcdir"/src/server/"$libname"
ln -s "$libname" "$pkgdir"/opt/lib/"${libname%.*}"
ln -s "${libname%.*}" "$pkgdir"/opt/lib/"${libname%.*.*}"
ln -s "${libname%.*.*}" "$pkgdir"/opt/lib/"${libname%.*.*.*}"
install -D -m 644 -t "$pkgdir"/lib/systemd/system \
"$srcdir"/rm2fb.service
fi
}

configure() {
if [[ $arch = rm2 ]]; then
systemctl daemon-reload
systemctl enable rm2fb --now
# Restart xochitl if it's running
if systemctl --quiet is-active xochitl; then
# Reset the crash count so we don't trigger remarkable-fail
echo "0" > /tmp/crashnum
systemctl restart xochitl
fi
fi
}

preremove() {
if [[ $arch = rm2 ]]; then
if systemctl list-units --full -all | grep -Fq 'rm2fb.service'; then
systemctl disable rm2fb --now
fi
echo -n "make sure "
if ! is-enabled xochitl.service; then
echo "to re-enable xochitl with 'systemctl enable xochitl --now'"
echo -n "and "
fi
echo "to disable / uninstall any launchers like draft, oxide or remux before"
echo "rebooting your tablet to complete the uninstallation"
fi
}
}

rm2fb-shim() {
pkgdesc="Shim to make reMarkable 1 apps work on reMarkable 2"
installdepends=(display)
conflicts=(rm2fb)
replaces=(rm2fb)

package() {
libname="librm2fb_client.so.${pkgver%-*}"
install -D -m 644 -t "$pkgdir"/opt/lib "$srcdir"/src/client/"$libname"
install -d "$pkgdir"/usr/lib
ln -s /opt/lib/"$libname" "$pkgdir"/usr/lib/"$libname"

for dest in opt/lib usr/lib; do
ln -s "$libname" "$pkgdir/$dest/${libname%.*}"
ln -s "${libname%.*}" "$pkgdir/$dest/${libname%.*.*}"
ln -s "${libname%.*.*}" "$pkgdir/$dest/${libname%.*.*.*}"
done

install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/rm2fb-shim
}
}
4 changes: 4 additions & 0 deletions package/display/rm2fb-shim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT
LD_PRELOAD=/opt/lib/librm2fb_client.so exec "$@"
File renamed without changes.
4 changes: 2 additions & 2 deletions package/rm2fb/rm2fb.service → package/display/rm2fb.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: MIT

[Unit]
Description=Remarkable2 Framebuffer Server
Description=reMarkable 2 Framebuffer Server
Before=xochitl.service
After=opt.mount
StartLimitInterval=30
Expand All @@ -14,7 +14,7 @@ ExecStart=/usr/bin/remarkable-shutdown
Restart=on-failure
RestartSec=5
Environment="HOME=/home/root"
Environment="LD_PRELOAD=/opt/lib/librm2fb_server.so.1.0.0"
Environment="LD_PRELOAD=/opt/lib/librm2fb_server.so"

[Install]
WantedBy=multi-user.target xochitl.service
12 changes: 6 additions & 6 deletions package/dotnet/package
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dotnet-profile() {

dotnet-host() {
pkgdesc="Generic driver for the .NET Core Command Line Interface"
depends=(dotnet-profile)
installdepends=(dotnet-profile)

package() {
install -dm 755 "$pkgdir"/opt/{bin,usr/{lib,share/{dotnet,licenses/dotnet-host}}}
Expand All @@ -53,7 +53,7 @@ dotnet-host() {
}
dotnet-sdk() {
pkgdesc=".NET Core SDK"
depends=(
installdepends=(
dotnet-runtime
dotnet-targeting-pack
netstandard-targeting-pack
Expand All @@ -67,7 +67,7 @@ dotnet-sdk() {
}
dotnet-runtime() {
pkgdesc=".NET Core runtime"
depends=(dotnet-host icu zlib libcurl)
installdepends=(dotnet-host icu zlib libcurl)

package() {
install -dm 755 "$pkgdir"/opt/usr/share/{dotnet/shared,licenses}
Expand All @@ -77,7 +77,7 @@ dotnet-runtime() {
}
aspnet-runtime() {
pkgdesc="ASP.NET Core runtime"
depends=(dotnet-runtime)
installdepends=(dotnet-runtime)

package() {
install -dm 755 "$pkgdir"/opt/usr/share/{dotnet/shared,licenses}
Expand All @@ -87,7 +87,7 @@ aspnet-runtime() {
}
dotnet-targeting-pack() {
pkgdesc=".NET Core targeting pack"
depends=(netstandard-targeting-pack)
installdepends=(netstandard-targeting-pack)

package() {
install -dm 755 "$pkgdir"/opt/usr/share/{dotnet,dotnet/packs,licenses}
Expand All @@ -98,7 +98,7 @@ dotnet-targeting-pack() {
aspnet-targeting-pack() {
pkgdesc="ASP.NET Core targeting pack"
license=Apache
depends=(dotnet-targeting-pack)
installdepends=(dotnet-targeting-pack)

package() {
install -dm 755 "$pkgdir"/opt/usr/share/{dotnet,dotnet/packs,licenses}
Expand Down
15 changes: 11 additions & 4 deletions package/draft/package
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(draft)
pkgdesc="Launcher which wraps around the standard interface"
url=https://github.com/dixonary/draft-reMarkable
pkgver=0.2.0-18
pkgver=0.2.0-19
timestamp=2020-07-20T10:23Z
section="launchers"
maintainer="Mattéo Delabre <spam@delab.re>"
license=Apache-2.0
depends=(xochitl)
installdepends=(xochitl display rm2fb-shim)
makedepends=(build:patchelf)
flags=(nostrip)

image=qt:v1.3.2
image=qt:v1.4
source=(
https://github.com/dixonary/draft-reMarkable/archive/5bd660a2fd07eba166c6110d2b48cfc58ee67e58.zip
draft.service
Expand All @@ -25,6 +27,11 @@ sha256sums=(
build() {
qmake draft.pro
make

# Inject rm2fb shim
# (after running strip, otherwise strip removes too much information)
"${CROSS_COMPILE}strip" --strip-all draft
patchelf --add-needed librm2fb_client.so draft
}

package() {
Expand Down
14 changes: 11 additions & 3 deletions package/fingerterm/package
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(fingerterm)
pkgdesc="Terminal emulator with an on-screen touch keyboard"
url=https://github.com/dixonary/fingerterm-reMarkable
pkgver=1.3.5-12
pkgver=1.3.5-13
timestamp=2020-10-27T12:02Z
section="admin"
maintainer="Mattéo Delabre <spam@delab.re>"
license=GPL-2.0-or-later
installdepends=(display rm2fb-shim)
makedepends=(build:patchelf)
flags=(nostrip)

image=qt:v1.2.2
image=qt:v1.4
source=(
https://github.com/dixonary/fingerterm-reMarkable/archive/02c17b5b485743c698e005ca89366c32b66aa044.zip
fingerterm.png
Expand All @@ -27,6 +30,11 @@ build() {
sed -i 's,DEPLOYMENT_PATH = /usr,DEPLOYMENT_PATH = /opt,' fingerterm.pro
qmake fingerterm.pro
make

# Inject rm2fb shim
# (after running strip, otherwise strip removes too much information)
"${CROSS_COMPILE}strip" --strip-all fingerterm
patchelf --add-needed librm2fb_client.so fingerterm
}

package() {
Expand Down
Loading

0 comments on commit a9e270e

Please sign in to comment.