Bug 238727 - Pkg requires /dev/null which is not available in nanobsd's normal pkg install
Summary: Pkg requires /dev/null which is not available in nanobsd's normal pkg install
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-20 20:22 UTC by mike
Modified: 2021-07-08 05:51 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike 2019-06-20 20:22:26 UTC
When installing custom packages in nanobsd, pkg now requires /dev/null which is not available by default.  I made this simple patch to work around the issue. Not sure if its the correct place to do it or not in /usr/src/tools/tools/nanobsd/defaults.sh 



 # Early customize commands.
 NANO_EARLY_CUSTOMIZE=""
@@ -776,6 +776,7 @@
        fi
 
        # Mount packages into chroot
+       mount -t devfs devfs ${NANO_WORLDDIR}/dev 
        mkdir -p ${NANO_WORLDDIR}/_.p
        mount -t nullfs -o noatime -o ro ${NANO_PACKAGE_DIR} ${NANO_WORLDDIR}/_.p
 
@@ -802,7 +803,7 @@
        )
 
        CR0 "${PKGCMD} info"
-
+       umount ${NANO_WORLDDIR}/dev
        trap - 1 2 15 EXIT
        umount ${NANO_WORLDDIR}/_.p
        rm -rf ${NANO_WORLDDIR}/_.p


Prior to that, the install would fail. More details and logs are in the email thread at 
https://lists.freebsd.org/pipermail/freebsd-embedded/2019-June/002718.html
Comment 1 Warner Losh freebsd_committer freebsd_triage 2019-06-20 22:29:51 UTC
note: my current patch
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 0002373be658..86acab65f67d 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -778,8 +778,9 @@ cust_pkgng ( ) (
        # Mount packages into chroot
        mkdir -p ${NANO_WORLDDIR}/_.p
        mount -t nullfs -o noatime -o ro ${NANO_PACKAGE_DIR} ${NANO_WORLDDIR}/_.p
+       mount -t devfs devfs ${NANO_WORLDDIR}/dev

-       trap "umount ${NANO_WORLDDIR}/_.p ; rm -rf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT
+       trap "umount ${NANO_WORLDDIR}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -rf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT

        # Install pkg-* package
        CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}"
@@ -804,6 +805,7 @@ cust_pkgng ( ) (
        CR0 "${PKGCMD} info"

        trap - 1 2 15 EXIT
+       umount ${NANO_WORLDDIR}/dev
        umount ${NANO_WORLDDIR}/_.p
        rm -rf ${NANO_WORLDDIR}/_.p
 )

adds umount to the trap command. I'll test this (or someone else can) and get it committed.
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-06-21 03:50:05 UTC
A commit references this bug:

Author: imp
Date: Fri Jun 21 03:49:36 UTC 2019
New revision: 349261
URL: https://svnweb.freebsd.org/changeset/base/349261

Log:
  Mount and unmount devfs around calls to add packages.

  pkg now uses /dev/null for some of its operations. NanoBSD's packaging
  stuff didn't mount that for the chroot it ran in, so any config that
  added packages would see the error:
  	pkg: Cannot open /dev/null:No such file or directory
  when trying to actually add those packages. It's easy enough for
  nanobsd to mount /dev and it won't hurt anything that was already
  working and may help things that weren't (like this). I moved the
  mount/unmount pair to be in the right push/pop order from the
  submitted patch.

  PR: 238727
  Submitted by: mike tancsa
  Tested by: Karl Denninger

Changes:
  head/tools/tools/nanobsd/defaults.sh
Comment 3 mike 2019-06-21 14:27:53 UTC
tested / verified on both RELENG_12 and RELENG_11
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-07-08 05:51:50 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c978000da5c6a909e16c0996a93d91068cafb03e

commit c978000da5c6a909e16c0996a93d91068cafb03e
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2019-06-21 03:49:36 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-07-08 05:51:03 +0000

    Mount and unmount devfs around calls to add packages.

    pkg now uses /dev/null for some of its operations. NanoBSD's packaging
    stuff didn't mount that for the chroot it ran in, so any config that
    added packages would see the error:
            pkg: Cannot open /dev/null:No such file or directory
    when trying to actually add those packages. It's easy enough for
    nanobsd to mount /dev and it won't hurt anything that was already
    working and may help things that weren't (like this). I moved the
    mount/unmount pair to be in the right push/pop order from the
    submitted patch.

    PR: 238727
    Submitted by: mike tancsa
    Tested by: Karl Denninger

    (cherry picked from commit 804b78634d543667a37ac459e692fe42c9dd30e8)

 tools/tools/nanobsd/defaults.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)