Comment 18 for bug 974584

Serge Hallyn (serge-hallyn) wrote :

From the debian bug, here is my new suggestion for a replacement for the ischroot case in initscripts.postinst:

=============================
if ischroot; then
        # Symlink /var/run from /run
        # Note var/run is relative
        if compat_link /var/run /run; then
                # Symlink /var/lock from /run/lock
                # Note that it's really /var/run/lock
                compat_link /var/lock /run/lock

                # Symlink /dev/shm from /run/shm
                # Note that it's really /var/run/shm
  [ ! -d /run/shm ] && mkdir /run/shm
  if [ ! mountpoint -q /dev ]; then
   [ ! -d /dev/shm ] && compat_link /run/shm /dev/shm
  else
   compat_link /dev/shm /run/shm
  fi
        fi
# Host system, not a chroot.
else
=============================

So if the chroot has /dev/ bind-mounted from the host, assume they
always will, and will want /run/shm as a symlink to /dev/shm.

Otherwise if /dev/shm exists, leave it alone, because we're definately
not in debootstrap.

Otherwise, assume /dev and /run won't get cleaned up at 'shutdown'
(chroot exit) so set up *exactly* what we want to see as the end
result: /dev/shm as a symbolic link to /run/shm.