From a91dddfbafdbe45237508f3016f14e73ab6d5189 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Fri, 2 May 2025 00:35:41 +0900 Subject: [PATCH 1/6] feat: rMPP support --- docs/recipe-format.md | 4 ++++ pyproject.toml | 3 ++- toltec/builder.py | 12 +++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/recipe-format.md b/docs/recipe-format.md index 3f75a0f..eef5a47 100644 --- a/docs/recipe-format.md +++ b/docs/recipe-format.md @@ -43,8 +43,10 @@ Name | Meaning `rmall` | Packages which work on all reMarkable devices without modification. `rm1` | Packages requiring reMarkable 1-specific resources or compilation flags. `rm2` | Packages requiring reMarkable 2-specific resources or compilation flags. +`rmpp` | Packages requiring reMarkable Paper Pro-specific resources or compilation flags. For example, use `archs=(rm1)` for a package that only works on reMarkable 1, or `archs=(rm1 rm2)` for a package that works both on reMarkable 1 and reMarkable 2 but needs different dependencies or compilation flags for each of those. +DO NOT USE `rmall` for packages with any binaries, since aarch32 binaries will not work on aarch64 devices and vice versa. In the following sections, you can add a suffix to any field to specify that its value only applies to a given architecture. For string fields, the arch-specific value will replace the unsuffixed value; for array fields, it will be appended to the unsuffixed value. @@ -230,6 +232,8 @@ Should match the upstream name as closely as possible. The `build()` function runs in the context of a Docker container with the chosen `image`. This function has access to all the metadata variables declared above, plus the `$arch` variable which contains the name of the architecture the recipe is currently being built for. The working directory is `$srcdir`, which is populated with all the sources declared in `sources`. +Do note that if you are going to build aarch64 binaries, you must switch to suitable environment variables by sourcing `/opt/x-tools/switch-aarch64.sh`. +If you need to go back to aarch32, you can source `/opt/x-tools/switch-arm.sh`. ### Package Section diff --git a/pyproject.toml b/pyproject.toml index b9dd286..91deede 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,10 @@ [project] name = "toltecmk" -version = "0.3.4" +version = "0.4.0" authors = [ { name="Mattéo Delabre", email="git.matteo@delab.re" }, { name="Eeems", email="eeems@eeems.email" }, + { name="Noa Himesaka", email="himesaka@noa.codes" }, ] description = "Build system used for the Toltec community repository" requires-python = ">=3.11" diff --git a/toltec/builder.py b/toltec/builder.py index bfd53ea..8d7faec 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -316,13 +316,15 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) if host_deps: - opkg_conf_path = "$SYSROOT/etc/opkg/opkg.conf" + opkg_conf_path = "$SYSROOT_AARCH64/etc/opkg/opkg.conf" if recipe.arch == "rmpp" else "$SYSROOT/etc/opkg/opkg.conf" + opkg_exec = "opkg-aarch64" if recipe.arch == "rmpp" else "opkg" + pre_script.extend( ( 'echo -n "dest root /', "arch all 100", - "arch armv7-3.2 160", - "src/gz entware https://bin.entware.net/armv7sf-k3.2", + f"arch {'aarch64-3.10' if recipe.arch == 'rmpp' else 'armv7-3.2'} 160", + f"src/gz entware https://bin.entware.net/{'aarch64-k3.10' if recipe.arch == 'rmpp' else 'armv7sf-k3.2'}", "arch rmall 200", "src/gz toltec-rmall file:///repo/rmall", f'" > "{opkg_conf_path}"', @@ -340,8 +342,8 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: pre_script.extend( ( - "opkg update --verbosity=0", - "opkg install --verbosity=0 --no-install-recommends" + f"{opkg_exec} update --verbosity=0", + f"{opkg_exec} install --verbosity=0 --no-install-recommends" " -- " + " ".join(host_deps), ) ) From 204adfef5a814388bb47da6b57718c207e743aca Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Fri, 2 May 2025 14:36:50 +0900 Subject: [PATCH 2/6] fix/builder.py: fix arch detection --- toltec/builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toltec/builder.py b/toltec/builder.py index 8d7faec..9a880f2 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -316,15 +316,15 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) if host_deps: - opkg_conf_path = "$SYSROOT_AARCH64/etc/opkg/opkg.conf" if recipe.arch == "rmpp" else "$SYSROOT/etc/opkg/opkg.conf" - opkg_exec = "opkg-aarch64" if recipe.arch == "rmpp" else "opkg" + opkg_conf_path = "$SYSROOT_AARCH64/etc/opkg/opkg.conf" if recipe.arch == 'rmpp' else "$SYSROOT/etc/opkg/opkg.conf" + opkg_exec = "opkg-aarch64" if "rmpp" in recipe.arch else "opkg" pre_script.extend( ( 'echo -n "dest root /', "arch all 100", - f"arch {'aarch64-3.10' if recipe.arch == 'rmpp' else 'armv7-3.2'} 160", - f"src/gz entware https://bin.entware.net/{'aarch64-k3.10' if recipe.arch == 'rmpp' else 'armv7sf-k3.2'}", + f"arch {'aarch64-3.10' if "rmpp" in recipe.arch else 'armv7-3.2'} 160", + f"src/gz entware https://bin.entware.net/{'aarch64-k3.10' if 'rmpp' in recipe.arch else 'armv7sf-k3.2'}", "arch rmall 200", "src/gz toltec-rmall file:///repo/rmall", f'" > "{opkg_conf_path}"', From c45973f23688fe311747a77e89607f01c2cda256 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sat, 3 May 2025 00:02:56 +0900 Subject: [PATCH 3/6] feat/test: test for rMPP things too --- tests/recipe_parsers/test_installdepends.py | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/recipe_parsers/test_installdepends.py b/tests/recipe_parsers/test_installdepends.py index 0d28db4..07d9999 100644 --- a/tests/recipe_parsers/test_installdepends.py +++ b/tests/recipe_parsers/test_installdepends.py @@ -35,7 +35,7 @@ def test_installdepends(self) -> None: with open(path.join(rec_path, "package"), "w") as rec_def_file: rec_def_file.write( """ -archs=(rmall rmallos2 rmallos3 rm1 rm1os2 rm1os3 rm2 rm2os2 rm2os3) +archs=(rmall rmallos2 rmallos3 rm1 rm1os2 rm1os3 rm2 rm2os2 rm2os3 rmpp rmppos3) pkgnames=(toltec-base) pkgdesc="Metapackage defining the base set of packages in a Toltec install" url=https://toltec-dev.org/ @@ -49,6 +49,8 @@ def test_installdepends(self) -> None: installdepends_rm1os3=(open-remarkable-shutdown) installdepends_rm2os2=(rm2-suspend-fix) installdepends_rm2os3=(rm2-suspend-fix) +installdepends_rmpp=(rmpp-make-root-rw) +installdepends_rmppos3=(rmpp-make-root-rw) image=base:v2.1 source=("https://example.org/toltec/${pkgnames[0]}/release-${pkgver%-*}.zip") @@ -80,6 +82,7 @@ def test_installdepends(self) -> None: Dependency(DependencyKind.HOST, "open-remarkable-shutdown") ] rm2_depends = [Dependency(DependencyKind.HOST, "rm2-suspend-fix")] + rmpp_depends = [Dependency(DependencyKind.HOST, "rmpp-make-root-rw")] recipes = parse_recipe(rec_path) @@ -95,6 +98,8 @@ def test_installdepends(self) -> None: "rm2", "rm2os2", "rm2os3", + "rmpp", + "rmppos3", ], ) recipe = recipes["rmall"] @@ -177,3 +182,21 @@ def test_installdepends(self) -> None: package.installdepends, set(basic_depends + rm2_depends), ) + + recipe = recipes["rmpp"] + self.assertIs(type(recipe), Recipe) + package = recipe.packages["toltec-base"] + self.assertEqual(list(recipe.packages.keys()), ["toltec-base"]) + self.assertEqual( + package.installdepends, + set(basic_depends + rmpp_depends), + ) + + recipe = recipes["rmppos3"] + self.assertIs(type(recipe), Recipe) + package = recipe.packages["toltec-base"] + self.assertEqual(list(recipe.packages.keys()), ["toltec-base"]) + self.assertEqual( + package.installdepends, + set(basic_depends + rmpp_depends), + ) From fbc748343e77f91b2ea01784a4dd6be7fb989b63 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sat, 3 May 2025 00:32:54 +0900 Subject: [PATCH 4/6] fix/builder: use startwith per Eeems' suggestion --- toltec/builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toltec/builder.py b/toltec/builder.py index 9a880f2..0b2b825 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -316,15 +316,15 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) if host_deps: - opkg_conf_path = "$SYSROOT_AARCH64/etc/opkg/opkg.conf" if recipe.arch == 'rmpp' else "$SYSROOT/etc/opkg/opkg.conf" - opkg_exec = "opkg-aarch64" if "rmpp" in recipe.arch else "opkg" + opkg_conf_path = "$SYSROOT_AARCH64/etc/opkg/opkg.conf" if recipe.arch.startswith('rmpp') else "$SYSROOT/etc/opkg/opkg.conf" + opkg_exec = "opkg-aarch64" if recipe.arch.startswith('rmpp') else "opkg" pre_script.extend( ( 'echo -n "dest root /', "arch all 100", - f"arch {'aarch64-3.10' if "rmpp" in recipe.arch else 'armv7-3.2'} 160", - f"src/gz entware https://bin.entware.net/{'aarch64-k3.10' if 'rmpp' in recipe.arch else 'armv7sf-k3.2'}", + f"arch {'aarch64-3.10' if recipe.arch.startswith('rmpp') else 'armv7-3.2'} 160", + f"src/gz entware https://bin.entware.net/{'aarch64-k3.10' if recipe.arch.startswith('rmpp') else 'armv7sf-k3.2'}", "arch rmall 200", "src/gz toltec-rmall file:///repo/rmall", f'" > "{opkg_conf_path}"', From 85b04f80a7dd22d301afd86a4bfc4d5f9c536a5c Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sat, 3 May 2025 00:54:20 +0900 Subject: [PATCH 5/6] fix/docs: per suggestions --- docs/recipe-format.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/recipe-format.md b/docs/recipe-format.md index eef5a47..5a52161 100644 --- a/docs/recipe-format.md +++ b/docs/recipe-format.md @@ -40,13 +40,12 @@ The following values are accepted: Name | Meaning --------|------------------------------------------------------------------------- -`rmall` | Packages which work on all reMarkable devices without modification. +`rmall` | Packages which work on all reMarkable devices without modification. These packages must be cpu architecture independent, which generally means that they do not contain binaries, only scripts and configuration files. `rm1` | Packages requiring reMarkable 1-specific resources or compilation flags. `rm2` | Packages requiring reMarkable 2-specific resources or compilation flags. `rmpp` | Packages requiring reMarkable Paper Pro-specific resources or compilation flags. For example, use `archs=(rm1)` for a package that only works on reMarkable 1, or `archs=(rm1 rm2)` for a package that works both on reMarkable 1 and reMarkable 2 but needs different dependencies or compilation flags for each of those. -DO NOT USE `rmall` for packages with any binaries, since aarch32 binaries will not work on aarch64 devices and vice versa. In the following sections, you can add a suffix to any field to specify that its value only applies to a given architecture. For string fields, the arch-specific value will replace the unsuffixed value; for array fields, it will be appended to the unsuffixed value. @@ -232,8 +231,8 @@ Should match the upstream name as closely as possible. The `build()` function runs in the context of a Docker container with the chosen `image`. This function has access to all the metadata variables declared above, plus the `$arch` variable which contains the name of the architecture the recipe is currently being built for. The working directory is `$srcdir`, which is populated with all the sources declared in `sources`. -Do note that if you are going to build aarch64 binaries, you must switch to suitable environment variables by sourcing `/opt/x-tools/switch-aarch64.sh`. -If you need to go back to aarch32, you can source `/opt/x-tools/switch-arm.sh`. +If you are going to build aarch64 binaries, you must switch to suitable environment variables by sourcing `/opt/x-tools/switch-aarch64.sh`. +If you need to go back to ARMv7, you can source `/opt/x-tools/switch-arm.sh`. ### Package Section From 21dc8d4a391579bca50373b63afce35f642afb51 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sat, 3 May 2025 01:31:32 +0900 Subject: [PATCH 6/6] feat/builder: auto switch aarch64 envvars --- toltec/builder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toltec/builder.py b/toltec/builder.py index 0b2b825..e8607ba 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -348,6 +348,13 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) ) + if recipe.arch.startswith('rmpp'): + pre_script.extend( + ( + "source /opt/x-tools/switch-aarch64.sh" + ) + ) + logs = bash.run_script_in_container( self.docker, image=self.IMAGE_PREFIX + recipe.image,