mirror of
https://codeberg.org/kiss-community/repo
synced 2024-12-25 08:40:10 -07:00
8716e4e4a2
The crates.io link for the wasi crate 404s. Upstream have no git tags for versions whatsoever. Using the v1 crates.io API we can download the crate but it ends up being called 'download' rather than 'wasi-bla-bla.crate'. This is temporary until the issue is fixed upstream.
62 lines
1.7 KiB
Bash
Executable File
62 lines
1.7 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# Seeing as this is the only rust package in the
|
|
# repositories (other than rust itself), this will
|
|
# also serve as a reference to writing network-free
|
|
# rust-based packages.
|
|
|
|
# Set the CARGO_HOME variable to the current directory
|
|
# to prevent cargo from touching '$HOME/.cargo'. This
|
|
# keeps the build contained to the package manager's
|
|
# domain.
|
|
export CARGO_HOME=$PWD
|
|
|
|
# Extract each crate and generate a checksum file.
|
|
# This effectively mimics 'cargo vendor' without the
|
|
# network requirement.
|
|
#
|
|
# This allows the package manager to cache each crate
|
|
# and handle them as regular sources.
|
|
(
|
|
cd vendor
|
|
|
|
# Download link for this crate 404s. Mirror link saves
|
|
# the file as 'download' so it must be renamed.
|
|
mv -f download wasi-0.9.0+wasi-snapshot-preview1.crate
|
|
|
|
for crate in *.crate; do
|
|
tar xf "$crate"
|
|
|
|
# Strip the filename from the sha256sum output.
|
|
sha256=$(sha256sum "$crate")
|
|
sha256=${sha256%% *}
|
|
|
|
printf '{"package":"%s","files":{}}\n' "$sha256" \
|
|
> "${crate%.crate}/.cargo-checksum.json"
|
|
done
|
|
)
|
|
|
|
# Cargo reads a "global" configuration file from $CARGO_HOME,
|
|
# as we've set it to $PWD this is where we'll be storing the
|
|
# vendor config.
|
|
mkdir -p .cargo
|
|
|
|
# Create the configuration file to tell cargo to look in the
|
|
# 'vendor' directory for the already downloaded sources
|
|
# rather than crates.io (over network).
|
|
cat <<EOF > .cargo/config
|
|
[source.crates-io]
|
|
replace-with = "vendored-sources"
|
|
|
|
[source.vendored-sources]
|
|
directory = "vendor"
|
|
EOF
|
|
|
|
# Use the '--frozen' flag to tell cargo to skip the network
|
|
# and use whatever dependencies are in the Cargo.[toml|lock]
|
|
# files.
|
|
cargo build --release --frozen
|
|
|
|
mkdir -p "$1/usr/bin"
|
|
cp -f target/release/cbindgen "$1/usr/bin"
|