dev/list-outdated.sh: script to scan for outdated crates
Blair Noctis
1 year, 5 months ago
0 | #!/usr/bin/env bash | |
1 | # | |
2 | # $@: optionally provided crates to check for | |
3 | ||
4 | check_command() { | |
5 | if [[ "$(command -v $@ | wc -l)" -ne $# ]]; then | |
6 | echo This script needs $@ to work. | |
7 | exit 1 | |
8 | fi | |
9 | } | |
10 | ||
11 | check_command curl jq | |
12 | ||
13 | pushd src >/dev/null | |
14 | ||
15 | NAMES=* | |
16 | if [ $# -ne 0 ]; then | |
17 | NAMES=$@ | |
18 | fi | |
19 | ||
20 | echo -e "crate\tpackaged\tcrates.io" | |
21 | for name in $NAMES; do | |
22 | if [ ! -e $name/debian/changelog ]; then | |
23 | continue | |
24 | fi | |
25 | curver=$(head -n1 $name/debian/changelog | tr -d '()' | awk '{print $2}' | awk -F- '{print $1}') | |
26 | latestver=$(curl -sSL https://crates.io/api/v1/crates/$name | jq .versions[0].num | tr -d '"') | |
27 | if [ "$curver" != "$latestver" ]; then | |
28 | echo -e "$name\t$curver\t$latestver" | |
29 | fi | |
30 | done | |
31 | ||
32 | popd >/dev/null |