summaryrefslogtreecommitdiff
path: root/aptdpkgclean
blob: e42631ce1031b3172b3a874c3c29360ca8dcbbfa (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/aptdpkgclean
  4. # Put together and tweaked by Jonas Smedegaard <dr@jones.dk>
  5. # 2001-2002
  6. #
  7. # $Id: aptdpkgclean,v 1.1 2002-03-07 16:22:51 jonas Exp $
  8. #
  9. # Auto re-mounting of a readonly /usr
  10. # Put the following in a file below /etc/apt/apt.conf.d:
  11. #
  12. # // Auto re-mounting of a readonly /usr
  13. # // Based on mail from Anthony Towns <aj@azure.humbug.org.au>
  14. # // http://lists.debian.org/debian-devel/2001/debian-devel-200111/msg00212.html
  15. #
  16. # // This is the intended thing:
  17. # // DPkg {
  18. # // Pre-Invoke {"mount -o remount,rw /usr";};
  19. # // Post-Invoke {"mount -o remount,ro /usr";};
  20. # // };
  21. #
  22. # DPkg {
  23. # Pre-Install-Pkgs {"/usr/local/sbin/aptdpkgro";};
  24. # Pre-Invoke {"mount -o remount,rw /usr";};
  25. # Post-Invoke {"/usr/local/sbin/aptdpkgclean; mount -o remount,ro /usr";};
  26. # };
  27. #
  28. pathmatch="^/usr"
  29. cat /var/lib/my_ro_hack.todel | while read file; do
  30. [ -f "$file" ] || continue
  31. N1=`find "$file" -printf "%i\n"`
  32. b=`basename $file`; d=`dirname $file`
  33. XF="${b#.}"; XF="$d/${XF%.dpkg-ro-used.*}"
  34. N2=`find "$XF" -printf "%i\n"` || continue
  35. [ -n "$XF" ] || continue
  36. if [ "$N1" != "$N2" ] && ! fuser -s "$file"; then
  37. rm -f "$file"
  38. else
  39. echo "$file"
  40. fi
  41. done >/var/lib/my_ro_hack.todel.new
  42. mv /var/lib/my_ro_hack.todel.new /var/lib/my_ro_hack.todel