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 diff --git a/.builds/void.yml b/.builds/void.yml new file mode 100644 index 0000000..6407636 --- /dev/null +++ b/.builds/void.yml @@ -0,0 +1,37 @@ +image: archlinux +packages: + - xbps-static-bin + - openssl + - go + - clang + - musl +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) + 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') + + echo "project=$project" >> ~/.buildenv + echo "pkgver=$pkgver" >> ~/.buildenv + - build: | + source ~/.cargo/env + cd /home/build/trifid/packages/void_amd64_$project + ./build.sh /home/build/trifid $pkgver + sha256sum *.xbps diff --git a/Cargo.lock b/Cargo.lock index e6b777f..15655e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2073,7 +2073,7 @@ dependencies = [ [[package]] name = "nebula-ffi" -version = "0.1.1" +version = "0.1.3" dependencies = [ "bindgen", "gobuild", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "tfclient" -version = "0.2.0" +version = "0.2.1" dependencies = [ "base64 0.21.0", "base64-serde", diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..ee13a4d --- /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.env] +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 4f6178c..a111955 100644 --- a/nebula-ffi/build.rs +++ b/nebula-ffi/build.rs @@ -2,8 +2,20 @@ use std::env; use std::path::PathBuf; use bindgen::CargoCallbacks; use gobuild::BuildMode; +use std::path::Path; fn main() { + // 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"); gobuild::Build::new().buildmode(BuildMode::CShared).file("main.go").compile("nebulaffi"); println!("Go compile success"); diff --git a/packages/void_amd64_tfcli/build.sh b/packages/void_amd64_tfcli/build.sh index bd66868..4b5684e 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 @@ -17,9 +17,9 @@ 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" -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..cc3aea7 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 @@ -17,10 +17,10 @@ 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 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 diff --git a/tfclient/Cargo.toml b/tfclient/Cargo.toml index 41c66ad..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" @@ -47,4 +47,5 @@ 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@" } +