Cannot install packages in NanoBSD

Hi everybody,

I need help in building NanoBSD imge using custom function customize_cmd cust_pkg.

Here is the content of my /usr/src/tools/tools/nanobsd/Pkg directory:
Code:
root@Dell-E1705:/usr/src/tools/tools/nanobsd/Pkg # ls -als
total 26696
   4 drwxr-xr-x  2 root  wheel      512 Nov  4 09:54 .
   4 drwxr-xr-x  9 root  wheel      512 Nov  2 20:44 ..
8896 -rwxr--r--  1 root  wheel  9054024 Nov  4 09:53 pkg-1.20.8.pkg
8896 -rwxr--r--  1 root  wheel  9054652 Nov  2 12:40 pkg.txz
8896 -rwxr--r--  1 root  wheel  9054024 Nov  1 10:52 samba416-4.16.11.pkg
root@Dell-E1705:/usr/src/tools/tools/nanobsd/Pkg #


here is the output of _.cust.cust_pkgng showing the error:
Code:
israel@Dell-E1705:/usr/obj/nanobsd.full $ less _.cust.cust_pkgng
+ cust_pkgng
+ mkdir -p /usr/obj/nanobsd.full/_.w/usr/local/etc
+ local 'PKG_CONF=/usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf'
+ local 'PKGCMD=env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg'
+ touch /usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf
+ grep -Eiq '^PKG_DBDIR:.*' /usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf
+ echo 'PKG_DBDIR: "/var/db/pkg"'
+ [ ! -d /usr/src/tools/tools/nanobsd/Pkg ]
+ find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ basename /usr/src/tools/tools/nanobsd/Pkg/pkg-1.20.8.pkg
+ _NANO_PKG_PACKAGE=pkg-1.20.8.pkg
+ [ -z pkg-1.20.8.pkg -o ! -f /usr/src/tools/tools/nanobsd/Pkg/pkg-1.20.8.pkg ]
+ mkdir -p /usr/obj/nanobsd.full/_.w/_.p
+ mount -t nullfs -o noatime -o ro /usr/src/tools/tools/nanobsd/Pkg /usr/obj/nanobsd.full/_.w/_.p
+ mount -t devfs devfs /usr/obj/nanobsd.full/_.w/dev
+ trap 'umount /usr/obj/nanobsd.full/_.w/dev; umount /usr/obj/nanobsd.full/_.w/_.p ; rm -xrf /usr/obj/nanobsd.full/_.w/_.p' 1 2 15 EXIT
+ CR 'env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/pkg-1.20.8.pkg'
+ chroot /usr/obj/nanobsd.full/_.w /bin/sh -exc 'env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/pkg-1.20.8.pkg'
+ env 'BATCH=YES' 'ASSUME_ALWAYS_YES=YES' 'PKG_DBDIR=/var/db/pkg' 'SIGNATURE_TYPE=none' /usr/sbin/pkg add /_.p/pkg-1.20.8.pkg
pkg: Error fetching [URL]http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/Latest/pkg.txz[/URL]: Host does not resolve
Address resolution failed for [URL]http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly[/URL].
Consider changing PACKAGESITE.
Bootstrapping pkg from pkg+[URL]http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly[/URL], please wait...
+ umount /usr/obj/nanobsd.full/_.w/dev
+ umount /usr/obj/nanobsd.full/_.w/_.p
+ rm -xrf /usr/obj/nanobsd.full/_.w/_.p


I succeeded building the image without this customization function.
And, outside the the NanoBSD building process, i can install packages normally.

Thank you all.
 
There is a patch floating around if you search. Actually two that are needed for various configurations.
Bug reports as well have been filed but ignored patches included.. Search bugzilla.
 
Address resolution failed
That is why I use a different way. Scrape txz files.....


Make sure txz files are scraped from same arch.
 
Looks like you have no internet connection due to a DNS issue.
Thank you elgrande,

I have internet connection indded. I as said, i am able to install any package outside the NanoBSD building process, as shown below when i just finished an update.

Code:
root@Dell-E1705:/home/israel # pkg update
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
root@Dell-E1705:/home/israel #
root@Dell-E1705:/home/israel #
root@Dell-E1705:/home/israel # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (16 candidates): 100%
Processing candidates (16 candidates): 100%
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
        sudo: 1.9.14p3 -> 1.9.14p3_1

Number of packages to be upgraded: 1

2 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching sudo-1.9.14p3_1.pkg: 100%    2 MiB   1.7MB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Upgrading sudo from 1.9.14p3 to 1.9.14p3_1...
[1/1] Extracting sudo-1.9.14p3_1: 100%
You may need to manually remove /usr/local/etc/sudoers if it is no longer needed.
root@Dell-E1705:/home/israel #
 
After further review I think the problem is you want ONLY txz files in the nanobsd/pkg/ directory.
The *.pkg files you got in there is confusing the grepper.

Code:
find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ basename /usr/src/tools/tools/nanobsd/Pkg/pkg-1.20.8.pkg
+ _NANO_PKG_PACKAGE=pkg-1.20.8.pkg

Get rid of all files not txz. You have the proper file there but it is confused by *.pkg files.
Build with only pkg.txz for testing.
 
That is why I use a different way. Scrape txz files.....


Make sure txz files are scraped from same arch.
Thank you Philshfry,
Looking at Thread how-to-prevent-pkgsave-files.77744/#post-484609, you say that pkg.txz is required to be included ithe PKG directory. But looking at NanoBSD defaults.sh, the script looks for files named pkg-*.

Code:
#######################################################################
# Install packages from ${NANO_PACKAGE_DIR}

cust_pkgng ( ) (
        mkdir -p ${NANO_WORLDDIR}/usr/local/etc
        local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf"
        local PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg"

        # Ensure pkg.conf points pkg to where the package meta data lives.
        touch ${PKG_CONF}
        if grep -Eiq '^PKG_DBDIR:.*' ${PKG_CONF}; then
                sed -i -e "\|^PKG_DBDIR:.*|Is||PKG_DBDIR: "\"${NANO_PKG_META_BASE}/pkg\""|" ${PKG_CONF}
        else
                echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF}
        fi

        # If the package directory doesn't exist, we're done.
        if [ ! -d ${NANO_PACKAGE_DIR} ]; then
                echo "DONE 0 packages"
                return 0
        fi

        # Find a pkg-* package
        for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
                _NANO_PKG_PACKAGE=`basename "$x"`
        done
        if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGE_DIR}/${_NANO_PKG_PACKAGE}" ]; then
                echo "FAILED: need a pkg/ package for bootstrapping"
                exit 2
        fi

        # 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}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -xrf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT

        # Install pkg-* package
        CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}"

        (
                # Expand any glob characters in pacakge list
                cd "${NANO_PACKAGE_DIR}"
                _PKGS=`find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort | uniq`

                # Show todo
                todo=`echo "$_PKGS" | wc -l`
                echo "=== TODO: $todo"
                echo "$_PKGS"
                echo "==="
:
        else
                echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF}
        fi

        # If the package directory doesn't exist, we're done.
        if [ ! -d ${NANO_PACKAGE_DIR} ]; then
                echo "DONE 0 packages"
                return 0
        fi

        # Find a pkg-* package
        for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
                _NANO_PKG_PACKAGE=`basename "$x"`
        done
        if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGE_DIR}/${_NANO_PKG_PACKAGE}" ]; then
                echo "FAILED: need a pkg/ package for bootstrapping"
                exit 2
        fi

        # 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}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -xrf ${NANO_WORLDDIR}/_.p" 1 2 15 EXIT

        # Install pkg-* package
        CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}"

        (
                # Expand any glob characters in pacakge list
                cd "${NANO_PACKAGE_DIR}"
                _PKGS=`find ${NANO_PACKAGE_LIST} -not -name "${_NANO_PKG_PACKAGE}" -print | sort | uniq`

                # Show todo
                todo=`echo "$_PKGS" | wc -l`
                echo "=== TODO: $todo"
                echo "$_PKGS"
                echo "==="

                # Install packages
                for _PKG in $_PKGS; do
                        CR "${PKGCMD} add /_.p/${_PKG}"
                done
        )

        CR0 "${PKGCMD} info"

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

#######################################################################
,
I already tried with pkg-1.20.8.pkg and pkg.txz both downloaded fron
Code:
 url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly"
, and it didn't work allright.
 
After further review I think the problem is you want ONLY txz files in the nanobsd/pkg/ directory.
The *.pkg files you got in there is confusing the grepper.

Code:
find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ basename /usr/src/tools/tools/nanobsd/Pkg/pkg-1.20.8.pkg
+ _NANO_PKG_PACKAGE=pkg-1.20.8.pkg

Get rid of all files not txz. You have the proper file there but it is confused by *.pkg files.
Build with only pkg.txz for testing.
I thought the result was telling that it found a pkg-1.20.8.pkg file and have added it to the _NANO_PKG_PACKAGE variable.
Ok, I'm trying it right now. I deleted all files in Pkg directory exept pkg.txz. But as the script looks for a file named pkg-*, i think it will not work.
In a few moments i'll have the result of the building process...

thank you
 
After further review I think the problem is you want ONLY txz files in the nanobsd/pkg/ directory.
The *.pkg files you got in there is confusing the grepper.

Code:
find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ basename /usr/src/tools/tools/nanobsd/Pkg/pkg-1.20.8.pkg
+ _NANO_PKG_PACKAGE=pkg-1.20.8.pkg

Get rid of all files not txz. You have the proper file there but it is confused by *.pkg files.
Build with only pkg.txz for testing.


Phishfry,
With only pkg.txz in Pkg directory, i got the following error:
Code:
root@Dell-E1705:/usr/obj/nanobsd.full # less _.cust.cust_pkgng
+ cust_pkgng
+ mkdir -p /usr/obj/nanobsd.full/_.w/usr/local/etc
+ local 'PKG_CONF=/usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf'
+ local 'PKGCMD=env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg'
+ touch /usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf
+ grep -Eiq '^PKG_DBDIR:.*' /usr/obj/nanobsd.full/_.w/usr/local/etc/pkg.conf
+ echo 'PKG_DBDIR: "/var/db/pkg"'
+ [ ! -d /usr/src/tools/tools/nanobsd/Pkg ]
+ find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ [ -z '' -o ! -f /usr/src/tools/tools/nanobsd/Pkg/ ]
+ echo 'FAILED: need a pkg/ package for bootstrapping'
FAILED: need a pkg/ package for bootstrapping
+ exit 2
as i suspected.

what more can i do? I really thougth it would be easier :'‑(
 
Sometime before 13.1 and 12.4 releases, the default extension for all package files was changed from .txz to .pkg, including for the pkg package itself, here pkg-1.20.8.pkg .

Looks like the nanobsd script has been updated to reflect this change. Older *.txz packages likely just need renaming to *.pkg to work with this.

Caveat: I've not used nanobsd.
 
looking at NanoBSD defaults.sh, the script looks for files named pkg-*.

To clarify, "pkg-*", with the hyphen and version number, refers to the pkg executable itself, used to upgrade pkg itself before any others.

pkg.pkg (formerly pkg.txz) on amd64 at least is a symlink to the executable, so that 'pkg bootstrap' works.

ISTR nanobsd uses 'crunched' files, perhaps like in /rescue, so that may be different there.
 
Well looks like he is going to have to solve this issue.
Maybe this:
Are you using a /nanobsd/Files directory? If so try clearing it.
Dear Philshfry,
My resolv.conf seems to be allright, doesn't it?
Code:
root@Dell-E1705:/usr/src/tools/tools/nanobsd # less /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
it points to 192.168.1.1 which is correct.
And /nanobsd/Files only has a root subdir containing scripts concerning updates, save_cfg, cange_password... which seems have nothing to do with a DNS problem. What do you think?
dear smithi, I'm using pkg-1.20.8.pkg samba416-4.16.11.pkg in the Pkg directory, and customize_cmd cust_pkgng in my configuration file.
thank you.
 
it points to 192.168.1.1 which is correct.
Mine looks way different but that is my point.
No two networks are alike.

resolv.conf is actually generated by resolvconf.conf yadda yadda yadda.

So eliminate it for a test run or make it empty..
Heck you said you have successful build, rename it and proceed to build without /Files.
You have lost nothing but time.
Focus on the problem. Getting packages working for build, then hone with customized files.

/etc/resolv.conf These settings are generated by my firewall router box and are default network wide.
Code:
# Generated by resolvconf
search localdomain
nameserver 1.1.1.1
nameserver 8.8.4.4
On machines using DHCP you should have blank /etc/resolv.conf and resolvconf will take care of settings.
Depends on your network....
 
Hi everybody,

I need help in building NanoBSD imge using custom function customize_cmd cust_pkg.

I succeeded building the image without this customization function.
And, outside the the NanoBSD building process, i can install packages normally.

Thank you all.
Just wondering how long it took you to build NanoBSD? It seems to be taking an eternity on my ThinkPad X1... It's been running for over 10 hrs so far and CPU is almost at 100%.
 
Just wondering how long it took you to build NanoBSD? It seems to be taking an eternity on my ThinkPad X1... It's been running for over 10 hrs so far and CPU is almost at 100%.
Hi balanga,

Code:
root@Dell-E1705:/usr/src/tools/tools/nanobsd # sysctl hw.model hw.machine hw.ncpu
hw.model: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz
hw.machine: amd64
hw.ncpu: 2
The computer i'm using to experiment is a Inspiron Dell-E1705 as shown. It took a little bit more than 12 hours to build NanoBSD complete without any error, now i'm using -b optiom to build while trying to install packages, and getting error in a few minutes.

Israel
 
Mine looks way different but that is my point.
No two networks are alike.

resolv.conf is actually generated by resolvconf.conf yadda yadda yadda.

So eliminate it for a test run or make it empty..
Heck you said you have successful build, rename it and proceed to build without /Files.
You have lost nothing but time.
Focus on the problem. Getting packages working for build, then hone with customized files.

/etc/resolv.conf These settings are generated by my firewall router box and are default network wide.
Code:
# Generated by resolvconf
search localdomain
nameserver 1.1.1.1
nameserver 8.8.4.4
On machines using DHCP you should have blank /etc/resolv.conf and resolvconf will take care of settings.
Depends on your network....
Hi Phishfry,

I made resolv.conf empty, as you sugested. And it was recriated with the same content as before.

Yes, i can install any package. only installing packages in NanoBSD doesn't work, can it be something wrong in myconf.nano file?. Look below:
Code:
root@Dell-E1705:/usr/obj/nanobsd.full # pkg install nano-7.2
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        nano: 7.2

Number of packages to be installed: 1

The process will require 3 MiB more space.
597 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching nano-7.2.pkg: 100%  597 KiB 610.9kB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Installing nano-7.2...
[1/1] Extracting nano-7.2: 100%
root@Dell-E1705:/usr/obj/nanobsd.full # pkg info nano
nano-7.2
Name           : nano
Version        : 7.2
Installed on   : Thu Nov  9 19:46:05 2023 -03
Origin         : editors/nano
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : editors
Licenses       : GPLv3
Maintainer     : danilo@FreeBSD.org
WWW            : https://www.nano-editor.org/
Comment        : Nano's ANOther editor, an enhanced free Pico clone
Options        :
        DOCS           : on
        EXAMPLES       : on
        NLS            : on
Shared Libs required:
        libintl.so.8
Annotations    :
        FreeBSD_version: 1302001
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 2.73MiB
Description    :
nano is a small, free and friendly editor which aims to replace
Pico, the default editor included in the non-free Pine package.
Rather than just copying Pico's look and feel, nano also implements
some missing (or disabled by default) features in Pico, such as
"search and replace" and "goto line number".
root@Dell-E1705:/usr/obj/nanobsd.full #

Thank you all.
 
Hi folks,
I had some free time in the weekend and tryed a little bit more with NanoBSD.
I found out that pkg(7) was not working properly inside the chrooted environment created by NanoBSD defaults.sh script. It nedded a resolv.conf inside the chrooted environment. ( I got a clue from Thread /threads/installing-pkgs-in-a-diskless-environment.74018/ ).
To solve this i included the line
Code:
cp /etc/resolv.conf ${NANO_WORLDDIR}/etc/resolv.conf
before the croot command.
This solved the problem of DNS error.
It bootstraped pkg(8) properly, and i could get a complete build without any error.

The next isue was that when i tryed to insltall samba416-4.16.11.pkg, i got an error like this
Code:
+ CR 'env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/samba416-4.16.11.pkg'
+ chroot /usr/obj/nanobsd.nano-1/_.w /bin/sh -exc 'env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/samba416-4.16.11.pkg'
+ env 'BATCH=YES' 'ASSUME_ALWAYS_YES=YES' 'PKG_DBDIR=/var/db/pkg' 'SIGNATURE_TYPE=none' /usr/sbin/pkg add /_.p/samba416-4.16.11.pkg
Installing samba416-4.16.11...
pkg: Missing dependency 'avahi-app'

Failed to install the following 1 package(s): /_.p/samba416-4.16.11.pkg
.

After some trial end errors i could get an complete build installing samba416-4.16.11.pkg by changing defaults.sh from
Code:
                # Install packages
                for _PKG in $_PKGS; do
                        CR "${PKGCMD} add /_.p/${_PKG}"
                done

to

Code:
                # Install packages
                for _PKG in $_PKGS; do
                       CR "${PKGCMD} install /_.p/${_PKG}"
                done

The think the same result i would have if i had used
Code:
pkg -d add
in defaults.sh.

I also could get a build wthout error if i downloaded all the samba416-4.16.11.pkg dependencies inside Pkg directory.

I really think it's strange why i had to make these changes in the code, if there are probably hundreds of people that had it working without doing this.

Anyway, realy thank you all that are helping me through this learnig fase in using FreeBSD.
 
Back
Top