Build guest agent programs as deb packages
It uses cargo-deb to build the guest agent programs as *.deb packages.
In doing so, they are built as static executables.
And the deb files are installed via the localdebs directory.
Bug: 372168347
Bug: 382417268
Test: run terminal with the guest image
Change-Id: I8574ed8c4358ea11880d189c258b2330753b938d
diff --git a/build/debian/build.sh b/build/debian/build.sh
index 3f33ec8..a426d22 100755
--- a/build/debian/build.sh
+++ b/build/debian/build.sh
@@ -156,6 +156,7 @@
source "$HOME"/.cargo/env
rustup target add "${arch}"-unknown-linux-gnu
cargo install cargo-license
+ cargo install cargo-deb
}
download_debian_cloud_image() {
@@ -168,23 +169,11 @@
wget -O - "${url}" | tar xz -C "${outdir}" --strip-components=1
}
-build_rust_binary_and_copy() {
+build_rust_as_deb() {
pushd "$(dirname "$0")/../../guest/$1" > /dev/null
- local release_flag=
- local artifact_mode=debug
- if [[ "$mode" == "release" ]]; then
- release_flag="--release"
- artifact_mode=release
- fi
- RUSTFLAGS="-C linker=${arch}-linux-gnu-gcc" cargo build \
+ cargo deb \
--target "${arch}-unknown-linux-gnu" \
- --target-dir "${workdir}/$1" ${release_flag}
- mkdir -p "${dst}/files/usr/local/bin/$1"
- cp "${workdir}/$1/${arch}-unknown-linux-gnu/${artifact_mode}/$1" "${dst}/files/usr/local/bin/$1/AVF"
- chmod 777 "${dst}/files/usr/local/bin/$1/AVF"
-
- mkdir -p "${dst}/files/usr/share/doc/$1"
- cargo license > "${dst}/files/usr/share/doc/$1/copyright"
+ --output "${debian_cloud_image}/localdebs"
popd > /dev/null
}
@@ -218,9 +207,9 @@
cp -R "$(dirname "$0")/localdebs/" "${debian_cloud_image}/"
build_ttyd
- build_rust_binary_and_copy forwarder_guest
- build_rust_binary_and_copy forwarder_guest_launcher
- build_rust_binary_and_copy shutdown_runner
+ build_rust_as_deb forwarder_guest
+ build_rust_as_deb forwarder_guest_launcher
+ build_rust_as_deb shutdown_runner
}
package_custom_kernel() {