From a91dddfbafdbe45237508f3016f14e73ab6d5189 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Fri, 2 May 2025 00:35:41 +0900 Subject: [PATCH 01/15] 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 02/15] 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 03/15] 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 04/15] 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 05/15] 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 06/15] 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, From 65b068f8ec42e005ea100521550b65209553d784 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 12:04:45 +0900 Subject: [PATCH 07/15] feat: rMPPM support too --- docs/recipe-format.md | 1 + tests/recipe_parsers/test_installdepends.py | 23 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/recipe-format.md b/docs/recipe-format.md index 5a52161..64911a5 100644 --- a/docs/recipe-format.md +++ b/docs/recipe-format.md @@ -44,6 +44,7 @@ Name | Meaning `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. +`rmppm` | Packages requiring reMarkable Paper Pro Move-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. diff --git a/tests/recipe_parsers/test_installdepends.py b/tests/recipe_parsers/test_installdepends.py index 07d9999..1ad4e7c 100644 --- a/tests/recipe_parsers/test_installdepends.py +++ b/tests/recipe_parsers/test_installdepends.py @@ -51,6 +51,8 @@ def test_installdepends(self) -> None: installdepends_rm2os3=(rm2-suspend-fix) installdepends_rmpp=(rmpp-make-root-rw) installdepends_rmppos3=(rmpp-make-root-rw) +installdepends_rmppm=(rmpp-make-root-rw) +installdepends_rmppmos3=(rmpp-make-root-rw) image=base:v2.1 source=("https://example.org/toltec/${pkgnames[0]}/release-${pkgver%-*}.zip") @@ -83,6 +85,7 @@ def test_installdepends(self) -> None: ] rm2_depends = [Dependency(DependencyKind.HOST, "rm2-suspend-fix")] rmpp_depends = [Dependency(DependencyKind.HOST, "rmpp-make-root-rw")] + rmppm_depends = [Dependency(DependencyKind.HOST, "rmpp-make-root-rw")] recipes = parse_recipe(rec_path) @@ -100,6 +103,8 @@ def test_installdepends(self) -> None: "rm2os3", "rmpp", "rmppos3", + "rmppm", + "rmppmos3", ], ) recipe = recipes["rmall"] @@ -200,3 +205,21 @@ def test_installdepends(self) -> None: package.installdepends, set(basic_depends + rmpp_depends), ) + + recipe = recipes["rmppm"] + 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 + rmppm_depends), + ) + + recipe = recipes["rmppmos3"] + 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 + rmppm_depends), + ) From fcb453a2975cb864848fc28fc59c567471601878 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 12:56:28 +0900 Subject: [PATCH 08/15] fix: setting build env --- toltec/builder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/toltec/builder.py b/toltec/builder.py index e8607ba..34d5570 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -348,12 +348,12 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) ) - if recipe.arch.startswith('rmpp'): - pre_script.extend( - ( - "source /opt/x-tools/switch-aarch64.sh" - ) + if recipe.arch.startswith('rmpp'): + pre_script.extend( + ( + "source /opt/x-tools/switch-aarch64.sh" ) + ) logs = bash.run_script_in_container( self.docker, From 278de33a9fb88077f9620f33782cf01c0363aae2 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 13:38:33 +0900 Subject: [PATCH 09/15] feat: arch test case --- tests/fixtures/hello/package | 3 ++- tests/recipe_parsers/test_installdepends.py | 2 +- toltec/builder.py | 2 +- toltec/hooks/strip.py | 26 +++++++++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/fixtures/hello/package b/tests/fixtures/hello/package index ca2b948..d4b02a1 100644 --- a/tests/fixtures/hello/package +++ b/tests/fixtures/hello/package @@ -11,8 +11,9 @@ license=MIT pkgver=0.0.1-1 section="utils" flags=() +archs=(rm1 rmpp) -image=base:v2.1 +image=base:v4.0 source=(hello.c) sha256sums=(SKIP) diff --git a/tests/recipe_parsers/test_installdepends.py b/tests/recipe_parsers/test_installdepends.py index 1ad4e7c..4f01a4a 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 rmpp rmppos3) +archs=(rmall rmallos2 rmallos3 rm1 rm1os2 rm1os3 rm2 rm2os2 rm2os3 rmpp rmppos3 rmppm rmppmos3) pkgnames=(toltec-base) pkgdesc="Metapackage defining the base set of packages in a Toltec install" url=https://toltec-dev.org/ diff --git a/toltec/builder.py b/toltec/builder.py index 34d5570..9ace56a 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -349,7 +349,7 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) if recipe.arch.startswith('rmpp'): - pre_script.extend( + pre_script.append( ( "source /opt/x-tools/switch-aarch64.sh" ) diff --git a/toltec/hooks/strip.py b/toltec/hooks/strip.py index f8d1127..311deee 100644 --- a/toltec/hooks/strip.py +++ b/toltec/hooks/strip.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) MOUNT_SRC = "/src" -TOOLCHAIN = "toolchain:v3.1" +TOOLCHAIN = "toolchain:v4.0" def walk_elfs(src_dir: str, for_each: Callable) -> None: @@ -73,6 +73,7 @@ def post_build( # pylint: disable=too-many-locals,too-many-branches # Search for binary objects that can be stripped strip_arm: List[str] = [] + strip_aarch64: List[str] = [] strip_x86: List[str] = [] def filter_elfs(info: ELFFile, file_path: str) -> None: @@ -81,12 +82,14 @@ def filter_elfs(info: ELFFile, file_path: str) -> None: return if info.get_machine_arch() == "ARM": strip_arm.append(file_path) + elif info.get_machine_arch() == "AArch64": + strip_aarch64.append(file_path) elif info.get_machine_arch() in ("x86", "x64"): strip_x86.append(file_path) walk_elfs(src_dir, filter_elfs) - if not strip_arm and not strip_x86: + if not strip_arm and not strip_aarch64 and not strip_x86: logger.debug("Skipping, no binaries found") return @@ -139,6 +142,25 @@ def docker_file_path(file_path: str) -> str: os.path.relpath(file_path, src_dir), ) + if strip_aarch64: + script.extend( + ( + 'source /opt/x-tools/switch-aarch64.sh', + '"${CROSS_COMPILE}strip" --strip-all -- ' + + " ".join( + docker_file_path(file_path) for file_path in strip_aarch64 + ) + ) + ) + + logger.debug("AArch64 binaries to be stripped:") + + for file_path in strip_aarch64: + logger.debug( + " - %s", + os.path.relpath(file_path, src_dir), + ) + run_in_container(builder, src_dir, logger, script) # Restore original mtimes From 9aef260b60d4e3860b51f6c5c0747a46fc065275 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 13:38:53 +0900 Subject: [PATCH 10/15] feat: arch test case actually --- tests/test_arch.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/test_arch.py diff --git a/tests/test_arch.py b/tests/test_arch.py new file mode 100644 index 0000000..f2a1130 --- /dev/null +++ b/tests/test_arch.py @@ -0,0 +1,45 @@ +# Copyright (c) 2023 The Toltec Contributors +# SPDX-License-Identifier: MIT + +import unittest +import subprocess + +from os import path +from tempfile import TemporaryDirectory +from elftools.elf.elffile import ELFFile + + +class TestBuild(unittest.TestCase): + def setUp(self) -> None: + self.dir = path.dirname(path.realpath(__file__)) + self.fixtures_dir = path.join(self.dir, "fixtures") + + def test_arch(self) -> None: + with TemporaryDirectory() as tmp_dir: + rec_dir = path.join(self.fixtures_dir, "hello") + work_dir = path.join(tmp_dir, "build") + dist_dir = path.join(tmp_dir, "dist") + + result = subprocess.run( + [ + "python3", + "-m", + "toltec", + "--work-dir", + work_dir, + "--dist-dir", + dist_dir, + "--", + rec_dir, + ], + capture_output=True, + check=False, + ) + self.assertEqual( + result.returncode, 0, result.stderr.decode("utf-8") + ) + self.assertEqual(result.stdout.decode("utf-8"), "") + with open(path.join(tmp_dir, "build", "rm1", "src", "hello"), 'rb') as f: + self.assertEqual(ELFFile(f).get_machine_arch(), "ARM") + with open(path.join(tmp_dir, "build", "rmpp", "src", "hello"), 'rb') as f: + self.assertEqual(ELFFile(f).get_machine_arch(), "AArch64") From b44d0247669926791787d9d78069f296cacc68ce Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 13:52:27 +0900 Subject: [PATCH 11/15] fix: run formatter to please linter --- tests/test_arch.py | 8 ++++++-- toltec/builder.py | 18 ++++++++++-------- toltec/hooks/strip.py | 7 ++++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tests/test_arch.py b/tests/test_arch.py index f2a1130..70076d3 100644 --- a/tests/test_arch.py +++ b/tests/test_arch.py @@ -39,7 +39,11 @@ def test_arch(self) -> None: result.returncode, 0, result.stderr.decode("utf-8") ) self.assertEqual(result.stdout.decode("utf-8"), "") - with open(path.join(tmp_dir, "build", "rm1", "src", "hello"), 'rb') as f: + with open( + path.join(tmp_dir, "build", "rm1", "src", "hello"), "rb" + ) as f: self.assertEqual(ELFFile(f).get_machine_arch(), "ARM") - with open(path.join(tmp_dir, "build", "rmpp", "src", "hello"), 'rb') as f: + with open( + path.join(tmp_dir, "build", "rmpp", "src", "hello"), "rb" + ) as f: self.assertEqual(ELFFile(f).get_machine_arch(), "AArch64") diff --git a/toltec/builder.py b/toltec/builder.py index 9ace56a..994b687 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -316,8 +316,14 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) if host_deps: - 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" + 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( ( @@ -348,12 +354,8 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: ) ) - if recipe.arch.startswith('rmpp'): - pre_script.append( - ( - "source /opt/x-tools/switch-aarch64.sh" - ) - ) + if recipe.arch.startswith("rmpp"): + pre_script.append(("source /opt/x-tools/switch-aarch64.sh")) logs = bash.run_script_in_container( self.docker, diff --git a/toltec/hooks/strip.py b/toltec/hooks/strip.py index 311deee..265d08e 100644 --- a/toltec/hooks/strip.py +++ b/toltec/hooks/strip.py @@ -145,11 +145,12 @@ def docker_file_path(file_path: str) -> str: if strip_aarch64: script.extend( ( - 'source /opt/x-tools/switch-aarch64.sh', + "source /opt/x-tools/switch-aarch64.sh", '"${CROSS_COMPILE}strip" --strip-all -- ' + " ".join( - docker_file_path(file_path) for file_path in strip_aarch64 - ) + docker_file_path(file_path) + for file_path in strip_aarch64 + ), ) ) From 71b2902ef44c27936e910ff263aab28e8c0be5f1 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 13:56:27 +0900 Subject: [PATCH 12/15] fix: run formatter to please linter, part 2 --- toltec/builder.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/toltec/builder.py b/toltec/builder.py index 994b687..306c5ad 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -324,13 +324,23 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: opkg_exec = ( "opkg-aarch64" if recipe.arch.startswith("rmpp") else "opkg" ) + opkg_arch = ( + "aarch64-3.10" + if recipe.arch.startswith("rmpp") + else "armv7-3.2" + ) + opkg_src = ( + "aarch64-k3.10" + if recipe.arch.startswith("rmpp") + else "armv7sf-k3.2" + ) pre_script.extend( ( 'echo -n "dest root /', "arch all 100", - 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'}", + f"arch {opkg_arch} 160", + f"src/gz entware https://bin.entware.net/{opkg_src}", "arch rmall 200", "src/gz toltec-rmall file:///repo/rmall", f'" > "{opkg_conf_path}"', From 8f3c8f92192289a831cee48c5ea8c9977dadbc1c Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 13:57:56 +0900 Subject: [PATCH 13/15] fix: run formatter to please linter, part 3 --- toltec/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toltec/builder.py b/toltec/builder.py index 306c5ad..0eec90b 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -274,7 +274,7 @@ def _prepare(recipe: Recipe, src_dir: str) -> None: ) bash.pipe_logs(logger, logs, "prepare()") - def _build(self, recipe: Recipe, src_dir: str) -> None: + def _build(self, recipe: Recipe, src_dir: str) -> None: #pylint: disable=too-many-locals """Build artifacts for a recipe.""" if not recipe.build: logger.debug("Skipping build (nothing to do)") From 476791619e77998044a19822571342c5c8f1747e Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 14:35:09 +0900 Subject: [PATCH 14/15] fix: now black strikes again! --- toltec/builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toltec/builder.py b/toltec/builder.py index 0eec90b..aef1e50 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -274,7 +274,8 @@ def _prepare(recipe: Recipe, src_dir: str) -> None: ) bash.pipe_logs(logger, logs, "prepare()") - def _build(self, recipe: Recipe, src_dir: str) -> None: #pylint: disable=too-many-locals + # pylint: disable=too-many-locals + def _build(self, recipe: Recipe, src_dir: str) -> None: """Build artifacts for a recipe.""" if not recipe.build: logger.debug("Skipping build (nothing to do)") From 833679e1ccc733776270f010a52d7954a184e643 Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Tue, 28 Oct 2025 15:28:35 +0900 Subject: [PATCH 15/15] fix: remove unneeded manual arch switch guide --- docs/recipe-format.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/recipe-format.md b/docs/recipe-format.md index 64911a5..daeb0de 100644 --- a/docs/recipe-format.md +++ b/docs/recipe-format.md @@ -232,8 +232,6 @@ 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`. -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