Skip to content

Instantly share code, notes, and snippets.

@AlD
Created September 11, 2012 12:33
Show Gist options
  • Save AlD/3698092 to your computer and use it in GitHub Desktop.
Save AlD/3698092 to your computer and use it in GitHub Desktop.
remove broken packages (unresolved dependencies) from a Slowlaris host
#!/usr/bin/env bash
pushd /var/sadm/pkg &&
for pkg in *; do
[ -f $pkg/install/depend ] &&
egrep '^[PR] ' $pkg/install/depend |
tr '[:space:]' ' ' |
cut -d\ -f2 |
while read dep; do
if ! pkginfo -q $dep; then
echo ${pkg}\'s dependency $dep not found, removing it... >&2
yes | pkgrm $pkg
break 2
fi
done
done
# licensed under GPL, Daniel Albers <[email protected]>, 20120911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment