elvish_config/aliases/checklinks.elv

41 lines
902 B
Plaintext

use str
fn -check {|f|
use str
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)
printf "%s seem broken: missing %s\n" $p (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
}