summaryrefslogtreecommitdiff
path: root/aptdpkgro
blob: 0fcd77ec9480d3fbed7ab26074b0936bec2cd6d5 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/aptdpkgro
  4. # Put together and tweaked by Jonas Smedegaard <dr@jones.dk>
  5. # 2001-2006
  6. #
  7. # $Id: aptdpkgro,v 1.2 2006-07-16 12:33:59 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. while read debname; do
  30. pkg=$(dpkg --info $debname | sed -n 's/^ Package: *//p' | head -n 1)
  31. (dpkg -L "$pkg" 2>/dev/null || true) | grep "$pathmatch" |
  32. while read file; do
  33. [ -f "$file" -a ! -L "$file" ] || continue
  34. dir=`dirname "$file"`;
  35. base=`basename "$file"`;
  36. inode=`find "$file" -printf "%i\n"`
  37. [ -L "$dir/.${base}.dpkg-ro-used.$inode" ] || continue
  38. (cd "$dir" && ln "$base" ".${base}.dpkg-ro-used.$inode")
  39. echo "$dir/.${base}.dpkg-ro-used.$inode"
  40. done >>/var/lib/my_ro_hack.todel
  41. done