abinfo "Installing Rust nightly version ..."
# FIXME: bpf-linker requires BPF target, which is only available in nightly builds
export RUSTUP_INIT_SKIP_PATH_CHECK=yes
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
export PATH="$HOME"/.cargo/bin:"$PATH"
rustup component add rust-src --toolchain nightly

abinfo "Building mitmproxy-rs ..."
cd "$SRCDIR"/mitmproxy-rs/
maturin build --release --strip
cd "$SRCDIR"/mitmproxy-linux/
maturin build --release --strip

abinfo "Installing mitmproxy-rs ..."
for wheel in "$SRCDIR"/target/wheels/*.whl; do
    python3 -m installer --destdir="$PKGDIR" "${wheel}"
done
