i like to run a server with a read-only root most of the time. but obviously when upgrading packages, i need to remount it read-write. so in my bashrc hook, i tried something like: case ${EBUILD_PHASE} in preinst) mount / -o remount,rw ;; postinst) (sleep 10s; mount / -o remount,ro) & ;; esac but portage does an access("/", W_OK) before my bashrc is called and so aborts before it can be remounted.
I guess we can just remove the existing check and add something like this just before calling preinst in ebuild.sh: [[ -w $ROOT ]] || die "$ROOT is not writable" There's also the issue of pkg_setup which may require write access. I suppose we can just let it die be itself if necessary, though.
yeah, i'm aware of the pkg_setup part, but not too many packages do that. and ones that do should be doing error checking. your suggested check looks sane to me. it would also produce a better log output i think as the current one simply exits with a single line like: access(/, W_OK)