From acb956a28d78b5bcb1bc9cc05f79d0e819cf4d32 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 26 Jun 2023 22:48:05 -0400 Subject: [PATCH 01/15] cross custom build command --- tfclient/Cargo.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tfclient/Cargo.toml b/tfclient/Cargo.toml index 41c66ad..43b12fc 100644 --- a/tfclient/Cargo.toml +++ b/tfclient/Cargo.toml @@ -47,4 +47,12 @@ maintainer = "c0repwn3r " copyright = "e3team " license-file = "LICENSE.txt" maintainer-scripts = "debian/" -systemd-units = { enable = false, unit-name = "tfclient@" } \ No newline at end of file +systemd-units = { enable = false, unit-name = "tfclient@" } + +# Cross config +[target.aarch64-unknown-linux-musl] +pre-build = [ + "wget https://go.dev/dl/go1.20.5.linux-arm64.tar.gz -O /go.tar.gz", + "tar -C /usr/local -xzf /go.tar.gz", + "echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile" +] From b7ad25b5eca03344c97d988156fdc294953032dc Mon Sep 17 00:00:00 2001 From: core Date: Mon, 26 Jun 2023 23:17:49 -0400 Subject: [PATCH 02/15] fix cross compilation with cross --- Cargo.lock | 2 +- Cross.toml | 18 ++++++++++++++++++ nebula-ffi/Cargo.toml | 4 ++-- nebula-ffi/build.rs | 17 +++++++++++++++-- tfclient/Cargo.toml | 7 ------- 5 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 Cross.toml diff --git a/Cargo.lock b/Cargo.lock index e6b777f..6aa746c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2073,7 +2073,7 @@ dependencies = [ [[package]] name = "nebula-ffi" -version = "0.1.1" +version = "0.1.2" dependencies = [ "bindgen", "gobuild", diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..d613b0e --- /dev/null +++ b/Cross.toml @@ -0,0 +1,18 @@ +# Cross config +[target.aarch64-unknown-linux-musl] +pre-build = [ + "apt-get update && apt-get install --assume-yes wget && wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /go.tar.gz && tar -C /usr/local -xzf /go.tar.gz && echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile && touch /go-installed", +] + +[target.aarch64-unknown-linux-musl.env] +volumes = [] +passthrough = ["GOPATH=/tmp/gopath", "GOCACHE=/tmp/gocache"] + +[target.x86_64-unknown-linux-musl] +pre-build = [ + "apt-get update && apt-get install --assume-yes wget && wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /go.tar.gz && tar -C /usr/local -xzf /go.tar.gz && echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile && touch /go-installed", +] + +[target.x86_64-unknown-linux-musl] +volumes = [] +passthrough = ["GOPATH=/tmp/gopath", "GOCACHE=/tmp/gocache"] diff --git a/nebula-ffi/Cargo.toml b/nebula-ffi/Cargo.toml index 739288f..118e73a 100644 --- a/nebula-ffi/Cargo.toml +++ b/nebula-ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nebula-ffi" -version = "0.1.1" +version = "0.1.3" edition = "2021" description = "A Rust wrapper crate for communicating with Nebula via a CGO FFI." license = "GPL-3.0-or-later" @@ -13,4 +13,4 @@ repository = "https://git.e3t.cc/~core/trifid" [build-dependencies] gobuild = "0.1.0-alpha.2" -bindgen = "0.66.1" \ No newline at end of file +bindgen = "0.66.1" diff --git a/nebula-ffi/build.rs b/nebula-ffi/build.rs index fce0147..d3300a4 100644 --- a/nebula-ffi/build.rs +++ b/nebula-ffi/build.rs @@ -1,9 +1,20 @@ use std::env; use std::path::PathBuf; use bindgen::CargoCallbacks; +use std::path::Path; fn main() { - gobuild::Build::new().file("main.go").compile("nebulaffi"); + // Find compiler: if /usr/local/go/bin/go exists, use that + // otherwise, rely on PATH + let compiler; + if Path::new("/usr/local/go/bin/go").exists() { + println!("Using /usr/local/go/bin/go"); + compiler = "/usr/local/go/bin/go"; + } else { + compiler = "go"; + } + + gobuild::Build::new().compiler(compiler).file("main.go").compile("nebulaffi"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); @@ -13,6 +24,8 @@ fn main() { println!("cargo:rerun-if-changed=go.sum"); println!("cargo:rerun-if-changed=main.go"); + println!("Bindgen start"); + let bindings = bindgen::Builder::default() .header(out_path.join("libnebulaffi.h").display().to_string()) .parse_callbacks(Box::new(CargoCallbacks)) @@ -23,4 +36,4 @@ fn main() { bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); -} \ No newline at end of file +} diff --git a/tfclient/Cargo.toml b/tfclient/Cargo.toml index 43b12fc..605709d 100644 --- a/tfclient/Cargo.toml +++ b/tfclient/Cargo.toml @@ -49,10 +49,3 @@ license-file = "LICENSE.txt" maintainer-scripts = "debian/" systemd-units = { enable = false, unit-name = "tfclient@" } -# Cross config -[target.aarch64-unknown-linux-musl] -pre-build = [ - "wget https://go.dev/dl/go1.20.5.linux-arm64.tar.gz -O /go.tar.gz", - "tar -C /usr/local -xzf /go.tar.gz", - "echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile" -] From 80e6dc05ed1ed140b3247ac5369a7cbadaef8558 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 26 Jun 2023 23:20:07 -0400 Subject: [PATCH 03/15] wrong table name --- Cargo.lock | 2 +- Cross.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6aa746c..7730233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2073,7 +2073,7 @@ dependencies = [ [[package]] name = "nebula-ffi" -version = "0.1.2" +version = "0.1.3" dependencies = [ "bindgen", "gobuild", diff --git a/Cross.toml b/Cross.toml index d613b0e..ee13a4d 100644 --- a/Cross.toml +++ b/Cross.toml @@ -13,6 +13,6 @@ pre-build = [ "apt-get update && apt-get install --assume-yes wget && wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /go.tar.gz && tar -C /usr/local -xzf /go.tar.gz && echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile && touch /go-installed", ] -[target.x86_64-unknown-linux-musl] +[target.x86_64-unknown-linux-musl.env] volumes = [] passthrough = ["GOPATH=/tmp/gopath", "GOCACHE=/tmp/gocache"] From 76af6087894059090a4dfaee920b1bc9bcd775e6 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 08:39:12 -0400 Subject: [PATCH 04/15] tfclient 0.2.1 --- tfclient/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tfclient/Cargo.toml b/tfclient/Cargo.toml index 605709d..fa5ae78 100644 --- a/tfclient/Cargo.toml +++ b/tfclient/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tfclient" -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "An open-source reimplementation of a Defined Networking-compatible client" license = "GPL-3.0-or-later" From 353a96906e87b70102696bed4d0f99b126a08108 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 08:46:19 -0400 Subject: [PATCH 05/15] start work on the voidlinux package builder --- .builds/void.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .builds/void.yml diff --git a/.builds/void.yml b/.builds/void.yml new file mode 100644 index 0000000..4e42515 --- /dev/null +++ b/.builds/void.yml @@ -0,0 +1,26 @@ +image: archlinux +packages: + - xbps +sources: + - https://git.e3t.cc/~core/trifid +tasks: + - archive: | + describe=$(git describe) + if [[ $describe == tfclient* ]]; then + project=tfclient + fi + if [[ $describe == tfcli* ]]; then + project=tfcli + fi + if [[ $describe == trifid-api* ]]; then + project=trifid-api + fi + + pkgver=$(git describe | sed -e 's/$project-v//g' | sed -e 's/-/_/g') + + echo "project=$project" >> ~/.buildenv + echo "pkgver=$pkgver" >> ~/.buildenv + + git archive -o /home/build/trifid/$project/$project-$pkgver.tar.gz --prefix=$project-$pkgver/ HEAD + + echo "$project-$pkgver" From bc7be9da0422bed866a6253615554d9cd09ce3ed Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 08:48:08 -0400 Subject: [PATCH 06/15] require ossl --- .builds/void.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.builds/void.yml b/.builds/void.yml index 4e42515..62c4829 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -1,6 +1,7 @@ image: archlinux packages: - xbps + - openssl sources: - https://git.e3t.cc/~core/trifid tasks: From 833940ce46582218922e0828afb80a65a63ca344 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 08:51:58 -0400 Subject: [PATCH 07/15] use AUR pkg instead --- .builds/void.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.builds/void.yml b/.builds/void.yml index 62c4829..cc7dcc1 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -1,7 +1,8 @@ image: archlinux packages: - - xbps + - xbps-static-bin - openssl + - go sources: - https://git.e3t.cc/~core/trifid tasks: From 639b841e08cf06699f4b5a8eb8e7a4a1e95cda47 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 08:56:08 -0400 Subject: [PATCH 08/15] build packages --- .builds/void.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.builds/void.yml b/.builds/void.yml index cc7dcc1..6d65c94 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -7,6 +7,8 @@ sources: - https://git.e3t.cc/~core/trifid tasks: - archive: | + cd /home/build/trifid + describe=$(git describe) if [[ $describe == tfclient* ]]; then project=tfclient @@ -22,7 +24,7 @@ tasks: echo "project=$project" >> ~/.buildenv echo "pkgver=$pkgver" >> ~/.buildenv - - git archive -o /home/build/trifid/$project/$project-$pkgver.tar.gz --prefix=$project-$pkgver/ HEAD - - echo "$project-$pkgver" + - build: | + cd /home/build/trifid/packages/void_amd64_$project + ./build.sh + sha256sum *.xbps From 3a8565b9f1f572056902f3302d71f42693d57cf2 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:01:10 -0400 Subject: [PATCH 09/15] build packages fix --- .builds/void.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.builds/void.yml b/.builds/void.yml index 6d65c94..70e33ba 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -7,6 +7,10 @@ sources: - https://git.e3t.cc/~core/trifid tasks: - archive: | + curl https://sh.rustup.rs -sSf | sh -s -- -y + source ~/.cargo/env + rustup target add x86_64-unknown-linux-musl + cd /home/build/trifid describe=$(git describe) @@ -25,6 +29,7 @@ tasks: echo "project=$project" >> ~/.buildenv echo "pkgver=$pkgver" >> ~/.buildenv - build: | + source ~/.cargo/env cd /home/build/trifid/packages/void_amd64_$project - ./build.sh + ./build.sh /home/build/trifid $pkgver sha256sum *.xbps From 89f0ed38b36c2d79a6e6e644cb1a37bad26fd736 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:01:40 -0400 Subject: [PATCH 10/15] build packages fix 3 --- .builds/void.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.builds/void.yml b/.builds/void.yml index 70e33ba..29dc6c9 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -3,6 +3,7 @@ packages: - xbps-static-bin - openssl - go + - clang sources: - https://git.e3t.cc/~core/trifid tasks: From 7350903289ccf8170d771cd94d3eb6903ac23ab1 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:03:51 -0400 Subject: [PATCH 11/15] fix check.yml --- .builds/check.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.builds/check.yml b/.builds/check.yml index 3fcc358..270179f 100644 --- a/.builds/check.yml +++ b/.builds/check.yml @@ -15,30 +15,30 @@ tasks: - check-dnapi-rs: | source ~/.cargo/env cd /home/build/trifid/dnapi-rs - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl - check-nebula-ffi: | source ~/.cargo/env cd /home/build/trifid/nebula-ffi - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl - check-tfcli: | source ~/.cargo/env cd /home/build/trifid/tfcli - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl - check-tfclient: | source ~/.cargo/env cd /home/build/trifid/tfclient - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl - check-trifid-api: | source ~/.cargo/env cd /home/build/trifid/trifid-api - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl - check-trifid-pki: | source ~/.cargo/env cd /home/build/trifid/trifid-pki - cargo check --locked --target x86_64-unknown-linux-musl - cargo clippy --locked --target x86_64-unknown-linux-musl + cargo check --target x86_64-unknown-linux-musl + cargo clippy --target x86_64-unknown-linux-musl From 1d627aee7f64a63fda70830f1cf8162033bf916a Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:04:27 -0400 Subject: [PATCH 12/15] fix check.yml and void.yml --- .builds/void.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.builds/void.yml b/.builds/void.yml index 29dc6c9..4ddf112 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -4,6 +4,7 @@ packages: - openssl - go - clang + - musl sources: - https://git.e3t.cc/~core/trifid tasks: From 188e57bc74d529424eac46afb77d2348621a5906 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:11:26 -0400 Subject: [PATCH 13/15] fix pkgver calculation --- .builds/void.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.builds/void.yml b/.builds/void.yml index 4ddf112..6407636 100644 --- a/.builds/void.yml +++ b/.builds/void.yml @@ -16,17 +16,17 @@ tasks: cd /home/build/trifid describe=$(git describe) - if [[ $describe == tfclient* ]]; then - project=tfclient - fi if [[ $describe == tfcli* ]]; then project=tfcli fi + if [[ $describe == tfclient* ]]; then + project=tfclient + fi if [[ $describe == trifid-api* ]]; then project=trifid-api fi - pkgver=$(git describe | sed -e 's/$project-v//g' | sed -e 's/-/_/g') + pkgver=$(git describe | sed -e "s/$project-v//g" | sed -e 's/-/_/g') echo "project=$project" >> ~/.buildenv echo "pkgver=$pkgver" >> ~/.buildenv From 7e8b4254039d19c43f8200697a8467eb78931840 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 09:50:57 -0400 Subject: [PATCH 14/15] fix builds --- packages/void_amd64_tfcli/build.sh | 4 ++-- packages/void_amd64_tfclient/build.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/void_amd64_tfcli/build.sh b/packages/void_amd64_tfcli/build.sh index bd66868..6c63c08 100755 --- a/packages/void_amd64_tfcli/build.sh +++ b/packages/void_amd64_tfcli/build.sh @@ -7,7 +7,7 @@ cd tfcli || exit echo "Building for release, v$2_$3 (+static) (--target x86_64-unknown-musl)" cargo build --release --target x86_64-unknown-linux-musl -cd ../packages/void || exit +cd ../packages/void_amd64_tfcli || exit echo "Creating workdir" rm -rf work @@ -22,4 +22,4 @@ chmod 755 work/usr/bin/tfcli echo "Building XBPS package" -xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r " -n "tfcli-$2_$3" -s "A command-line client for managing trifid-api servers" work \ No newline at end of file +xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r " -n "tfcli-$2_$3" -s "A command-line client for managing trifid-api servers" work diff --git a/packages/void_amd64_tfclient/build.sh b/packages/void_amd64_tfclient/build.sh index f8fb79c..7b330ba 100755 --- a/packages/void_amd64_tfclient/build.sh +++ b/packages/void_amd64_tfclient/build.sh @@ -7,7 +7,7 @@ cd tfclient || exit echo "Building for release, v$2_$3 (+static) (--target x86_64-unknown-musl)" cargo build --release --target x86_64-unknown-linux-musl -cd ../packages/void || exit +cd ../packages/void_amd64_tfclient || exit echo "Creating workdir" rm -rf work @@ -23,4 +23,4 @@ cp -r tfclient work/etc/sv echo "Building XBPS package" -xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r " -n "tfclient-$2_$3" -s "An open-source Rust Defined Networking client" work \ No newline at end of file +xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r " -n "tfclient-$2_$3" -s "An open-source Rust Defined Networking client" work From a9634d835fc7e6f8edc24a17bda0eff7f6b5e7cb Mon Sep 17 00:00:00 2001 From: core Date: Tue, 27 Jun 2023 15:36:58 -0400 Subject: [PATCH 15/15] fix builds again --- packages/void_amd64_tfcli/build.sh | 2 +- packages/void_amd64_tfclient/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/void_amd64_tfcli/build.sh b/packages/void_amd64_tfcli/build.sh index 6c63c08..4b5684e 100755 --- a/packages/void_amd64_tfcli/build.sh +++ b/packages/void_amd64_tfcli/build.sh @@ -17,7 +17,7 @@ mkdir -p work/etc/sv echo "Copying tfcli binary" -cp ../../target/release/tfcli work/usr/bin/tfcli +cp ../../target/x86_64-unknown-linux-musl/release/tfcli work/usr/bin/tfcli chmod 755 work/usr/bin/tfcli echo "Building XBPS package" diff --git a/packages/void_amd64_tfclient/build.sh b/packages/void_amd64_tfclient/build.sh index 7b330ba..cc3aea7 100755 --- a/packages/void_amd64_tfclient/build.sh +++ b/packages/void_amd64_tfclient/build.sh @@ -17,7 +17,7 @@ mkdir -p work/etc/sv echo "Copying tfclient binary" -cp ../../target/release/tfclient work/usr/bin/tfclient +cp ../../target/x86_64-unknown-linux-musl/release/tfclient work/usr/bin/tfclient chmod 755 work/usr/bin/tfclient cp -r tfclient work/etc/sv