From 28316b3621e7473325b0f8c05cdcc883f7e741d7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 1 Apr 2024 05:15:39 -0500 Subject: [PATCH] List (installed) debian packages each toybox command lives in. --- scripts/probes/cmd2dpkg | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/probes/cmd2dpkg 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 -- 2.39.2