hur.st's bl.aagh

BSD, Ruby, Rust, Rambling

pkg-cruft

Help keep FreeBSD tidy

[ruby] [bsd]

A small Ruby script for helping deal with cruft on pkgng-based systems like FreeBSD.

Perhaps most interesting is the implementation of checkrestart, a feature similar to the Debian-goodies program of the same name, which can find running processes which may need restarting following an upgrade.

# pkg-cruft checkrestart
[MISSING EXECUTABLE] (tmux-2.7)? running as 17319 (tmux)
[MISSING EXECUTABLE] (zsh-5.5.1)? running as 20115 (zsh)
[MISSING EXECUTABLE] (weechat-2.2)? running as 36747 (weechat)
/usr/local/bin/mosh-server (mosh-1.3.2_4) running as 53815 (mosh-server)

This is done by parsing procstat -va, locating executable mappings backed by files without a known path, and then mapping those back to executables and their respective packages.

Accuracy is somewhat limited by the FreeBSD kernel retaining less information about defunct files, but I find it works quite well.

pkg-cruft also supports locating unpackaged files, directories which contain no packaged files, finding binaries using obsolete or missing libraries, and listing packages that are no longer provided upstream.