Advertisement
Guest User

Untitled

a guest
Nov 14th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # get list of all installed packages
  4. dpkg -l | grep ^ii | sed 's/ii  \([^ ]*\).*$/\1/' > /tmp/list
  5.  
  6. # get list of auto installed packages
  7. apt-mark showauto > /tmp/autopkg
  8.  
  9. for pkg in `cat list`
  10. do
  11.  
  12. RES=`dpkg -L $pkg | grep -c /usr/include`
  13.  
  14. if [ $RES -gt 0 ]; then
  15.    # reinstall package
  16.    echo "Reinstalling [$pkg] with $RES matches found." 
  17.    apt-get install --reinstall $pkg
  18.  
  19.    if [ `grep -c $pkg /tmp/autopkg` -eq 1 ]; then
  20.         echo "Remarking [$pkg] as auto installed."
  21.     apt-mark auto $pkg
  22.    fi
  23. fi
  24.  
  25. done
  26.  
  27. rm /tmp/list
  28. rm /tmp/autopkg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement