Rust/sources/update-sources.sh

24 lines
591 B
Bash
Raw Normal View History

2023-05-13 13:58:44 -04:00
#!/usr/bin/env bash
set -eou pipefail
DIRECTORY=$(dirname "$0")
PACKAGES_FILE="$DIRECTORY/packages.txt"
SOURCES_FILE="$DIRECTORY/sources.json"
TEMP_DIR=$(mktemp -d "rust-flake-sources.XXXX" -p $XDG_RUNTIME_DIR)
pushd $TEMP_DIR
echo ""
for package in $(cat "$PACKAGES_FILE")
do
version=$(curl -s "https://crates.io/api/v1/crates/$package" | jq ".crate.max_stable_version" | tr -d '"')
echo "Fetching $package -- $version"
nurl "https://crates.io/crates/$package" "$version" -j | jq ".args" > $package.json
echo ""
done
popd
jq -s "." $TEMP_DIR/* > $SOURCES_FILE
rm -r $TEMP_DIR