Codebase list rust-stfu8 / 4c128e93-5432-4178-b3c8-3e176ad32f81/main dev / filter-binary-crates.sh
4c128e93-5432-4178-b3c8-3e176ad32f81/main

Tree @4c128e93-5432-4178-b3c8-3e176ad32f81/main (Download .tar.gz)

filter-binary-crates.sh @4c128e93-5432-4178-b3c8-3e176ad32f81/main

2f04e9c
 
38f11af
2f04e9c
 
 
 
 
 
 
 
 
 
 
#!/bin/bash
# Filter list of crates by whether they're a binary crate.
set -e

while read crate; do
	if debcargo extract "$crate" >/dev/null 2>/dev/null; then
		dir="$(ls -1d "rust-${crate//_/-}"-*)"
		bin="$(ls -1 "$dir/src/{main.rs,bin/*.rs}" 2>/dev/null | wc -l)"
		if [ "$bin" -gt 0 ] || grep -q '\[\[bin\]\]' "$dir/Cargo.toml"; then
			echo "$crate"
		fi
		rm -rf "$dir"
	fi
done