| •1 |
#!/usr/bin/bash |
| 2 |
|
| 3 |
program_name="$0" |
| 4 |
program_path=$(readlink -f "${program_name%/*}") |
| 5 |
|
| 6 |
# We add || true (which may not be needed without set -e) to be |
| 7 |
# explicit about the fact that this script does not fail even if `opam |
| 8 |
# install --show-actions` does, e.g., because of a non-existent |
| 9 |
# package |
| 10 |
# |
| 11 |
# TODO: Figure out how to use the OPAM API |
| 12 |
# (https://opam.ocaml.org/doc/api/) to call this from OCaml. |
| 13 |
for i in "$@"; do |
| 14 |
echo -n "$i:"; ((echo -n "$(opam install --show-actions "$i" | grep -o '∗\s*install\s*[^ ]*' | sed 's/∗\s*install\s*//g')" | tr '\n' ',') || true); echo |
| 15 |
done | xargs ocaml "${program_path}/sort-by-deps" |