newapkbuild: fetch rust dependencies in prepare phase

Fetch all dependencies in the prepare phase and do not access network
in the following phases.
This commit is contained in:
Jakub Jirutka 2021-12-16 00:19:07 +01:00 committed by Natanael Copa
parent f7f53bac28
commit bf1dae494b

View File

@ -30,6 +30,12 @@ is_github_url() {
return 1
}
prepare_rust() {
cat >>APKBUILD<<__EOF__
cargo fetch --locked
__EOF__
}
# Build sections
build_make() {
cat >>APKBUILD<<__EOF__
@ -104,7 +110,7 @@ __EOF__
build_rust() {
cat >>APKBUILD<<__EOF__
cargo build --release --locked
cargo build --frozen --release
__EOF__
}
@ -150,7 +156,7 @@ __EOF__
check_rust() {
cat >>APKBUILD<<__EOF__
cargo test --release --locked
cargo test --frozen --release
__EOF__
}
@ -199,7 +205,7 @@ __EOF__
package_rust() {
cat >>APKBUILD<<__EOF__
cargo install --locked --path . --root="\$pkgdir/usr"
cargo install --frozen --offline --path . --root="\$pkgdir/usr"
rm "\$pkgdir"/usr/.crates*
__EOF__
}
@ -333,6 +339,21 @@ __EOF__
fi
fi
case "$buildtype" in
rust)
cat >>APKBUILD<<__EOF__
prepare() {
default_prepare
__EOF__
prepare_rust
cat >>APKBUILD<<__EOF__
}
__EOF__
;;
esac
# Create build() function
cat >>APKBUILD<<__EOF__
build() {