mirror of
https://github.com/notwa/rc
synced 2024-11-05 21:39:03 -08:00
44 lines
1.1 KiB
Text
44 lines
1.1 KiB
Text
|
#!/usr/bin/env sh
|
||
|
# YES_ZSH
|
||
|
# YES_BASH
|
||
|
# YES_DASH
|
||
|
# YES_ASH
|
||
|
|
||
|
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 "$@"
|