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 +}