Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 469620

Summary: sys-fs/static-dev fails in chroots when host is using devtmpfs
Product: Gentoo Linux Reporter: Roy Bamford <neddyseagoon>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal CC: alexander, backbone, gentoo, himbeere, mpagano
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=454404
Whiteboard:
Package list:
Runtime testing required: ---

Description Roy Bamford gentoo-dev 2013-05-12 20:45:42 UTC
emerge sys-fs/static-dev always fails as /proc is checked for devtmpfs, which is always in use unless you are already using sys-fs/static-dev


Reproducible: Always

Steps to Reproduce:
1. Get into a chroot as part of an install with /dev not bind mounted
2. emerge sys-fs/static-dev
3. watch the install fail.
Actual Results:  
 * We have detected that you currently use udev or devfs or devtmpfs
 * and this ebuild cannot install to the same mount-point.
 * Please reinstall the ebuild (as root) like follows:
 * 
 * mkdir /tmp/newroot
 * mount -o bind / /tmp/newroot
 * ROOT=/tmp/newroot/ emerge sys-fs/static-dev
 * umount /tmp/newroot
 * ERROR: sys-fs/static-dev-0.1 failed (preinst phase):
 *   Cannot install on udev/devfs tmpfs.


Expected Results:  
>>> Install static-dev-0.1-r1 into /var/tmp/portage/sys-fs/static-dev-0.1-r1/image/ category sys-fs
>>> Completed installing static-dev-0.1-r1 into /var/tmp/portage/sys-fs/static-dev-0.1-r1/image/

>>> Done.

and lots of shiny /dev special nodes in /dev

Patch to fix it
--- static-dev-0.1.ebuild       2013-04-27 10:01:32.000000000 +0000
+++ static-dev-0.1-r1.ebuild    2013-05-12 20:30:53.448610460 +0000
@@ -14,8 +14,7 @@
 RDEPEND="sys-apps/makedev"
 
 pkg_preinst() {
-       if [[ -d ${ROOT}/dev/.udev || -c ${ROOT}/dev/.devfs ]] || \
-          ! awk '$2 == "/dev" && $3 == "devtmpfs" { exit 1 }' /proc/mounts ; then
+       if [[ -d ${ROOT}/dev/.udev || -c ${ROOT}/dev/.devfs ]]; then
                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."
Comment 1 SpanKY gentoo-dev 2013-05-14 16:20:08 UTC
that patch is incorrect as it breaks non-chroot builds
Comment 2 Alexander Tsoy 2013-05-14 16:34:10 UTC
Could we introduce build USE flag? If use build, then do nothing. This would be useful in catalyst builds, as catalyst create almost all necessary device nodes.
Comment 3 SpanKY gentoo-dev 2013-05-14 18:13:09 UTC
(In reply to comment #2)

that won't really help.  people are installing this package by hand.  catalyst builds pretty much all default to udev.
Comment 4 Alexander Tsoy 2013-05-14 18:29:28 UTC
(In reply to comment #3)

This is at least very useful in stage4 builds. I use them as templates for openvz containers.
Comment 5 Alexander Tsoy 2013-05-14 20:52:52 UTC
Hmm. I'm wrong. "build" use flag is only enabled on early stages. =/
Comment 6 Thomas Stein 2013-06-21 14:45:08 UTC
Hello.

Is there any progress on this bug? sys-fs/static-dev is pulled in but does not compile:

>>> Installing (1 of 1) sys-fs/static-dev-0.1

 * We have detected that you currently use udev or devfs or devtmpfs
 * and this ebuild cannot install to the same mount-point.
 * Please reinstall the ebuild (as root) like follows:
 * 
 * mkdir /tmp/newroot
 * mount -o bind / /tmp/newroot
 * ROOT=/tmp/newroot/ emerge sys-fs/static-dev
 * umount /tmp/newroot
 * ERROR: sys-fs/static-dev-0.1 failed (preinst phase):
 *   Cannot install on udev/devfs tmpfs.
 * 
 * Call stack:
 *     ebuild.sh, line  93:  Called pkg_preinst
 *   environment, line 141:  Called die
 * The specific snippet of code:
 *           die "Cannot install on udev/devfs tmpfs.";
 * 
 * If you need support, post the output of `emerge --info '=sys-fs/static-dev-0.1'`,
 * the complete build log and the output of `emerge -pqv '=sys-fs/static-dev-0.1'`.
 * The complete build log is located at '/var/tmp/portage/sys-fs/static-dev-0.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-fs/static-dev-0.1/temp/environment'.
 * Working directory: '/usr/lib64/portage/pym'
 * S: '/var/tmp/portage/sys-fs/static-dev-0.1/work/static-dev-0.1'
!!! FAILED preinst: 1

>>> Failed to install sys-fs/static-dev-0.1, Log file:
Comment 7 Steve L 2014-07-24 19:11:58 UTC
(In reply to SpanKY from comment #1)
> that patch is incorrect as it breaks non-chroot builds

So fix it. It'd be better wrapped in a function:

using_udevfs(){
   [[ -e ${ROOT}dev/.udev || -e ${ROOT}dev/.devfs ]] && return
   [[ $ROOT = / ]] && [[ -e /proc/mounts ]] || return
   ! awk '$2 == "/dev" && $3 == "devtmpfs" { exit 1 }' /proc/mounts
}

if using_udevfs; then
  eerror..
fi

I switched -d and -c to -e, to make it easier to block in a chroot situation; less FS access for general case, but switch it back if you prefer, ofc.
Comment 8 Philipp Psurek 2014-09-07 12:36:41 UTC
after

mkdir /tmp/newroot
mount -o bind / /tmp/newroot
ROOT=/tmp/newroot/ emerge -1 sys-fs/static-dev

I get

 * Package:    sys-fs/static-dev-0.1
 * Repository: gentoo
 * Maintainer: base-system@gentoo.org
 * USE:        arm elibc_glibc kernel_linux userland_GNU
 * FEATURES:   preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Source unpacked in /var/tmp/portage/sys-fs/static-dev-0.1/work
>>> Compiling source in /var/tmp/portage/sys-fs/static-dev-0.1/work ...
>>> Source compiled.
>>> Test phase [not enabled]: sys-fs/static-dev-0.1

>>> Install static-dev-0.1 into /var/tmp/portage/sys-fs/static-dev-0.1/image/ category sys-fs
>>> Completed installing static-dev-0.1 into /var/tmp/portage/sys-fs/static-dev-0.1/image/

./
>>> Done.
 * checking 0 files for package collisions
>>> Merging sys-fs/static-dev-0.1 to /tmp/newroot/

 * We have detected that you currently use udev or devfs or devtmpfs
 * and this ebuild cannot install to the same mount-point.
 * Please reinstall the ebuild (as root) like follows:
 * 
 * mkdir /tmp/newroot
 * mount -o bind / /tmp/newroot
 * ROOT=/tmp/newroot/ emerge sys-fs/static-dev
 * umount /tmp/newroot
 * ERROR: sys-fs/static-dev-0.1::gentoo failed (preinst phase):
 *   Cannot install on udev/devfs tmpfs.
 * 
 * Call stack:
 *     ebuild.sh, line  93:  Called pkg_preinst
 *   environment, line 139:  Called die
 * The specific snippet of code:
 *           die "Cannot install on udev/devfs tmpfs.";
 * 
 * If you need support, post the output of `emerge --info '=sys-fs/static-dev-0.1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-fs/static-dev-0.1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-fs/static-dev-0.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-fs/static-dev-0.1/temp/environment'.
 * Working directory: '/usr/lib/portage/pym'
 * S: '/var/tmp/portage/sys-fs/static-dev-0.1/work/static-dev-0.1'
!!! FAILED preinst: 1


on

Portage 2.2.8-r1 (default/linux/arm/13.0/armv7a, gcc-4.7.3, glibc-2.19-r1, 3.4.90-00253-ge37d760 armv7l)
Timestamp of tree: Sun, 07 Sep 2014 09:45:01 +0000
Comment 9 SpanKY gentoo-dev 2014-11-17 02:19:26 UTC
Commit message: Only check for devtmpfs when installing into /
http://sources.gentoo.org/sys-fs/static-dev/static-dev-0.1.ebuild?r1=1.15&r2=1.16
Comment 10 Toralf F├Ârster gentoo-dev 2015-10-29 12:49:27 UTC
I run today into the same issue at the tinderbox and doe wonder why the ebuild checks this just at install phase ?
Wouldn't it be better to fully reject the emerge request ? :


>>> Completed installing static-dev-0.1 into /var/tmp/portage/sys-fs/static-dev-0.1/image/


 * We have detected that you currently use udev or devfs or devtmpfs
 * and this ebuild cannot install to the same mount-point.
 * ERROR: sys-fs/static-dev-0.1::gentoo failed (preinst phase):
 *   Cannot install on udev/devfs tmpfs.
 * 
 * Call stack:
 *     ebuild.sh, line  93:  Called pkg_preinst
 *   environment, line 228:  Called abort

assignee: base-system@gentoo.org
Comment 11 SpanKY gentoo-dev 2015-10-29 21:57:20 UTC
(In reply to Toralf F├Ârster from comment #10)

it's done at pkg_preinst, not src_install.  historically, that was the only phase that this could be done.

with EAPI=5, we could change it to pkg_pretend, and we could check MERGE_TYPE.  but it still wouldn't help when you do:
(1) chroot
(2) bind mount /dev

by definition, static-dev requires write access to /dev/
Comment 12 SpanKY gentoo-dev 2015-10-29 22:02:08 UTC
http://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cc958c3d516d66978ecb1b8835518fedf4cce950

i don't think there's anything more we can do here