mirror of
https://github.com/notwa/rc
synced 2024-11-05 08:09:03 -08:00
40 lines
1.1 KiB
Bash
Executable file
40 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
# compat: +ash +bash +dash +zsh
|
|
|
|
disowned() { ### @- find files in system directories that aren't associated with any pacman packages.
|
|
#
|
|
# Lists Pacman disowned files.
|
|
#
|
|
# Authors:
|
|
# Benjamin Boudreau <dreurmail@gmail.com>
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
#
|
|
|
|
TMPDIR=/tmp
|
|
local tmp="$TMPDIR/pacman-disowned-$UID-$$"
|
|
|
|
mkdir -p "$tmp"
|
|
#trap 'rm -rf "$tmp"' EXIT # dangerous, needs fixing
|
|
|
|
pacman --quiet --query --list | sort -u > "$tmp/db"
|
|
|
|
if [ -n "$MSYSTEM" ]; then
|
|
# this excludes /bin due to confusion over symlinks.
|
|
# /lib and /sbin don't exist.
|
|
set -- /clang32 /clang64 /clangarm64 /etc /mingw32 /mingw64 /ucrt64 /usr
|
|
else
|
|
set -- /bin /etc /lib /sbin /usr
|
|
fi
|
|
|
|
find "$@" ! -name lost+found \
|
|
\( -type d -printf '%p/\n' -o -print \) \
|
|
| grep -v '^/etc/pacman.d/gnupg/' \
|
|
| grep -v '^/usr/busybox/' \
|
|
| grep -v '/__pycache__/' \
|
|
| sort -u \
|
|
> "$tmp/fs"
|
|
|
|
comm -23 "$tmp/fs" "$tmp/db"
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || disowned "$@"
|