From 91b807267f0156a7f30c228c1b12d6a2930c1c88 Mon Sep 17 00:00:00 2001 From: Benjamin VAUDOUR Date: Mon, 15 Nov 2021 21:20:43 +0100 Subject: [PATCH] Ajout de checklinks --- aliases/checklinks.elv | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 aliases/checklinks.elv diff --git a/aliases/checklinks.elv b/aliases/checklinks.elv new file mode 100644 index 0000000..edacd04 --- /dev/null +++ b/aliases/checklinks.elv @@ -0,0 +1,39 @@ +use str + +fn -check [f]{ + var @missings = (try { + sudo ldd $f 2>/dev/null | grep 'not found' | eawk [_ m @_]{ put $m } + } except e { + }) + if (> (count $missings) 1) { + var p = (LC_ALL=C pacman -Qo $f) + echo $p' seem broken: missing '(str:join ', ' $missings) + } +} + +fn -check-executable [f]{ + if ?(test -x $f) { + -check $f + } +} + +fn -cbin []{ + echo (styled 'Searching broken binaries…' bold bright-yellow) + sudo find /usr/bin -maxdepth 1 -type f 2>/dev/null | each $-check~ +} + +fn -clib []{ + echo (styled 'Searching broken libs…' bold bright-yellow) + sudo find /usr/lib/*.so* -maxdepth 1 -type f 2>/dev/null | each $-check-executable~ +} + +fn -copt []{ + echo (styled 'Searching broken binariess in opt…' bold bright-yellow) + sudo find /opt -maxdepth 3 -type f 2>/dev/null | each $-check-executable~ +} + +edit:add-var checklinks~ []{ + -cbin + -clib + -copt +}