# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-fs/static-dev/static-dev-0.1.ebuild,v 1.15 2013/04/27 09:51:05 vapier Exp $
DESCRIPTION="A minimal, statically managed /dev suitable for vservers"
SRC_URI=""
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
IUSE=""
RDEPEND="sys-apps/makedev"
pkg_preinst() {
if [[ -d ${ROOT}/dev/.udev || -c ${ROOT}/dev/.devfs ]] || \
! awk '{for(n=7;n<=NF;n++){if($n=="-"){n++;break}};if($5 == "/dev" && $n ~ /tmpfs/) exit 1}' /proc/self/mountinfo; then
# We need to use mountinfo which works well inside chroot,
# unlike mtab or /proc/mounts.
# Unfortunately, the format of mountinfo has optional fields
# in the middle and requires rather complex parsing.
echo ""
eerror "We have detected that you currently use udev or devfs or devtmpfs"
eerror "and this ebuild cannot install to the same mount-point."
eerror "Please reinstall the ebuild (as root) like follows:"
eerror ""
eerror "mkdir /tmp/newroot"
eerror "mount -o bind / /tmp/newroot"
eerror "ROOT=/tmp/newroot/ emerge sys-fs/static-dev"
eerror "umount /tmp/newroot"
die "Cannot install on udev/devfs tmpfs."
fi
}
pkg_postinst() {
MAKEDEV -d "${ROOT}"/dev full null ptmx random tty urandom zero
# TODO check actual device numbers
find "${ROOT}"/dev -xdev \( -type c -or -type b \) -and -not \( \
-name full -or \
-name null -or \
-name ptmx -or \
-name random -or \
-name tty -or \
-name urandom -or \
-name zero \) -delete
# remove broken symlinks
find -L "${ROOT}"/dev -xdev -type l -delete
}