Skip to content

Instantly share code, notes, and snippets.

@jorrizza
Created October 21, 2011 14:02
Show Gist options
  • Save jorrizza/1303932 to your computer and use it in GitHub Desktop.
Save jorrizza/1303932 to your computer and use it in GitHub Desktop.
Debian broken package finder
#!/bin/sh
BROKEN=""
IFS="
"
for package in `dpkg -l | awk '{ if ($1 == "ii") { print $2 } }'`; do
STATUS="Okay"
printf "Checking %s..." $package
for file in `dpkg -L $package | awk -F": " '{ if ($2) { print $2 } else { print $1 } }'`; do
if [ ! -e "$file" ]; then
STATUS="Broken"
fi
done
printf "%s\n" $STATUS
if [ $STATUS = "Broken" ]; then
BROKEN="$package $BROKEN"
fi
done
printf "Broken packages: %s\n" "$BROKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment