This commit is contained in:
c0repwn3r 2023-07-12 10:33:34 -04:00
commit a47efeb329
Signed by: core
GPG Key ID: FDBF740DADDCEECF
9 changed files with 92 additions and 24 deletions

View File

@ -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

37
.builds/void.yml Normal file
View File

@ -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

4
Cargo.lock generated
View File

@ -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",

18
Cross.toml Normal file
View File

@ -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"]

View File

@ -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"
bindgen = "0.66.1"

View File

@ -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");

View File

@ -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 <core@e3t.cc>" -n "tfcli-$2_$3" -s "A command-line client for managing trifid-api servers" work
xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r <core@e3t.cc>" -n "tfcli-$2_$3" -s "A command-line client for managing trifid-api servers" work

View File

@ -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 <core@e3t.cc>" -n "tfclient-$2_$3" -s "An open-source Rust Defined Networking client" work
xbps-create -A x86_64 -B trifid-build -H https://hub.e3t.cc/~core/trifid -l GPL-3.0-or-later -m "c0repwn3r <core@e3t.cc>" -n "tfclient-$2_$3" -s "An open-source Rust Defined Networking client" work

View File

@ -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 <core@e3t.cc>"
copyright = "e3team <admin@e3t.cc>"
license-file = "LICENSE.txt"
maintainer-scripts = "debian/"
systemd-units = { enable = false, unit-name = "tfclient@" }
systemd-units = { enable = false, unit-name = "tfclient@" }