elvish_config/aliases/checklinks.elv

41 lines
910 B
Plaintext
Raw Normal View History

2021-11-15 20:20:43 +00:00
use str
2021-12-11 21:09:02 +00:00
fn -check {|f|
use str
2021-11-15 20:20:43 +00:00
var @missings = (try {
doas ldd $f 2>/dev/null | grep 'not found' | eawk {|_ m @_| put $m }
} catch e {
2021-11-15 20:20:43 +00:00
})
if (> (count $missings) 1) {
var p = (tmp E:LC_ALL = C; pacman -Qo $f)
printf "%s seem broken: missing %s\n" $p (str:join ', ' $missings)
2021-11-15 20:20:43 +00:00
}
}
2021-12-11 21:09:02 +00:00
fn -check-executable {|f|
2021-11-15 20:20:43 +00:00
if ?(test -x $f) {
-check $f
}
}
2021-12-11 21:09:02 +00:00
fn -cbin {||
2021-11-15 20:20:43 +00:00
echo (styled 'Searching broken binaries…' bold bright-yellow)
doas find /usr/bin -maxdepth 1 -type f 2>/dev/null | each $-check~
2021-11-15 20:20:43 +00:00
}
2021-12-11 21:09:02 +00:00
fn -clib {||
2021-11-15 20:20:43 +00:00
echo (styled 'Searching broken libs…' bold bright-yellow)
doas find /usr/lib/*.so* -maxdepth 1 -type f 2>/dev/null | each $-check-executable~
2021-11-15 20:20:43 +00:00
}
2021-12-11 21:09:02 +00:00
fn -copt {||
2021-11-15 20:20:43 +00:00
echo (styled 'Searching broken binariess in opt…' bold bright-yellow)
doas find /opt -maxdepth 3 -type f 2>/dev/null | each $-check-executable~
2021-11-15 20:20:43 +00:00
}
2021-12-11 21:09:02 +00:00
edit:add-var checklinks~ {||
2021-11-15 20:20:43 +00:00
-cbin
-clib
-copt
}