Rust/sources/update-sources.sh

24 lines
628 B
Bash
Executable File

#!/usr/bin/env bash
set -eou pipefail
DIRECTORY=$(realpath "$(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 "map({(.pname): .}) | add" $TEMP_DIR/* > $SOURCES_FILE
rm -r $TEMP_DIR