diff options
author | Rob Landley <rob@landley.net> | 2024-04-01 05:15:39 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2024-04-01 05:15:39 -0500 |
commit | 28316b3621e7473325b0f8c05cdcc883f7e741d7 (patch) | |
tree | 4602cadf6f8492213a934f9b1c8dedc6781940f4 | |
parent | 97b776b705ea26378f58ce3258a021c8bcf4a3ab (diff) | |
download | toybox-28316b3621e7473325b0f8c05cdcc883f7e741d7.tar.gz |
List (installed) debian packages each toybox command lives in.
-rwxr-xr-x | scripts/probes/cmd2dpkg | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/probes/cmd2dpkg b/scripts/probes/cmd2dpkg new file mode 100755 index 00000000..6a9c3489 --- /dev/null +++ b/scripts/probes/cmd2dpkg @@ -0,0 +1,26 @@ +#!/bin/bash + +# Show debian packages host versions of each command live in +# (Alas, not as useful as I thought it would be.) + +[ -x toybox ] || { echo "no ./toybox" >&2; exit 1; } + +declare -A ray + +# Sad that this is NOT in the default path, but less dumb than /bin/sh->dash +PATH="$PATH":/sbin:/usr/sbin + +# Only checks installed packages, puts anything it can't find in none: +for i in $(./toybox) +do + tty -s && echo -n . >&2 + which $i >/dev/null || { ray["none:"]+=" $i"; continue; } + + ray[$(dpkg-query -S $(readlink -f $(which $i)) | toybox cut -DF 1)]+=" $i" +done + +# Print results +for i in ${!ray[@]} +do + echo $i ${ray[$i]} +done |