mirror of
https://github.com/notwa/rc
synced 2024-05-20 10:53:23 -07:00
rewrite pacman-list-disowned, rename to disowned
This commit is contained in:
parent
4f915fc802
commit
ea30451802
43
sh/disowned
Executable file
43
sh/disowned
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/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 "$@"
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# Lists Pacman disowned files.
|
||||
#
|
||||
# Authors:
|
||||
# Benjamin Boudreau <dreurmail@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
TMPDIR=/tmp
|
||||
local tmp="$TMPDIR/pacman-disowned-$UID-$$"
|
||||
local db="$tmp/db"
|
||||
local fs="$tmp/fs"
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
pacman --quiet --query --list | sort --unique > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr \
|
||||
! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
|
Loading…
Reference in New Issue
Block a user