From 79a66caa6db82bea16a49d3682c8d2d8f42ee2db Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Wed, 20 Nov 2024 23:38:09 -0500 Subject: [PATCH 1/5] feat(arch): Add ARM64 image build --- .woodpecker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 844e7e7..a87fcf3 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,7 +4,7 @@ steps: settings: dry-run: true repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64/v8 registry: git.merp.digital when: - event: push @@ -15,7 +15,7 @@ steps: image: woodpeckerci/plugin-docker-buildx settings: repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64/v8 registry: git.merp.digital tags: develop username: ${CI_REPO_OWNER} @@ -29,7 +29,7 @@ steps: image: woodpeckerci/plugin-docker-buildx settings: repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64/v8 registry: git.merp.digital tags: ["latest", "${CI_COMMIT_TAG}"] username: ${CI_REPO_OWNER} From 5e72c24b582cdb4696bd1aa5c8964057ce3a3737 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Wed, 20 Nov 2024 23:42:04 -0500 Subject: [PATCH 2/5] ci: Add manual event --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index a87fcf3..098d3d2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,7 +7,7 @@ steps: platforms: linux/amd64,linux/arm64/v8 registry: git.merp.digital when: - - event: push + - event: [push, manual] branch: exclude: [develop, master] From 56c1c804e692e616692b0bb56c4368dcc3c9edfc Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Wed, 20 Nov 2024 23:47:21 -0500 Subject: [PATCH 3/5] revert: Base image doesn't do ARM :( --- .woodpecker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 098d3d2..452a8ba 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,7 +4,7 @@ steps: settings: dry-run: true repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64,linux/arm64/v8 + platforms: linux/amd64 registry: git.merp.digital when: - event: [push, manual] @@ -15,7 +15,7 @@ steps: image: woodpeckerci/plugin-docker-buildx settings: repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64,linux/arm64/v8 + platforms: linux/amd64 registry: git.merp.digital tags: develop username: ${CI_REPO_OWNER} @@ -29,7 +29,7 @@ steps: image: woodpeckerci/plugin-docker-buildx settings: repo: git.merp.digital/${CI_REPO_OWNER}/${CI_REPO_NAME} - platforms: linux/amd64,linux/arm64/v8 + platforms: linux/amd64 registry: git.merp.digital tags: ["latest", "${CI_COMMIT_TAG}"] username: ${CI_REPO_OWNER} From cd2cf79ccf089f6ae55df88df5199430ba75cbba Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Thu, 21 Nov 2024 01:41:39 -0500 Subject: [PATCH 4/5] feat(linker): Add cargo linker to dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4224d24..d8fd3d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,5 @@ RUN git clone https://github.com/OnionIoT/source.git COPY openwrt-build-config source/.config ENV FORCE_UNSAFE_CONFIGURE=1 -RUN cd source && make -j12 \ No newline at end of file +ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-musl-gcc +RUN cd source && make -j12 From f63168fe0a7fd2d5e698b4791e8158eb34264643 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Thu, 21 Nov 2024 02:25:56 -0500 Subject: [PATCH 5/5] docs: Update README for new release --- README.md | 58 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index b5cefe3..f2ecdbd 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,43 @@ # onion2s-build -Docker image for cross to build rust packages for the Onion Omega 2S(+) +Docker image for cross to build Rust packages for the Onion Omega 2S(+) ## Prerequisites You will need to have the rustup version of cargo installed, for more information look at the official Rust documentation. You need Docker (or Podman) up and running, and you need to install cross with: ```sh -cargo install cross --git https://github.com/cross-rs/cross +cargo install cross ``` -## Configuration -To compile for the Onion Omega 2S(+) you need to add the following configuration: - -Cargo.toml: -```toml -[workspace.metadata.cross.target.mipsel-unknown-linux-musl] -image = "git.merp.digital/zenermerps/onion2s-build:latest" -build-std = ["std"] -``` - -.cargo/config: -```toml -[target.mipsel-unknown-linux-musl] -linker = "/source/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-musl-gcc" -``` -_Note_: cargo will complain that this location is deprecated, however (at least on macOS) moving the file to the suggested location results in an error about `Cargo.toml` not being found (while a `cargo.toml` exists). I assume this is due to some discrepancy between macOS's case-insensitive vs Linux's case-sensistive file system. - -## Build -You then can use `cross` as replacement for `cargo`, you need to specify the target with: `--target mipsel-unknown-linux-musl`, this is all you need to compile for the Onion Omega 2S(+). - -For example: +You will also need to install the nightly toolchain of Rust for your platform: ```sh -cross build --release --target mipsel-unknown-linux-musl -``` \ No newline at end of file +rustup install nightly +``` + +On the first run of cross, cross will also install a nightly toolchain that is able to run in the Docker image (amd64). + +### A note on ARM Macs +When trying to run cross on an ARM based Mac, docker will try to download the image for the ARM arch. Since cross doesn't provide ARM base images, this will fail. However, utilizing Rosetta, it is possible to run AMD64 images. To use those, pull the image manually using docker: + +```sh +docker pull --platform linux/amd64 git.merp.digital/zenermerps/onion2s-build:latest +``` + +This ensures docker will find an image with the correct name and tag, and doesn't try to download the non-existing ARM version. + +## Configuration +To compile for the Onion Omega 2S(+) you need to add the following configuration to your `Cargo.toml`: + +```toml +[package.metadata.cross.target.mipsel-unknown-linux-musl] +image = "git.merp.digital/zenermerps/onion2s-build:latest" +build-std = true +``` + +## Build +You then can use `cross +nightly` as replacement for `cargo`. You need to specify the correct target with: `--target mipsel-unknown-linux-musl`, this is all you need to compile for the Onion Omega 2S(+). + +For example: +```sh +cross +nightly build --release --target mipsel-unknown-linux-musl +```