bootstrapping /usr/sbin/pkg inside a jail

Fbsd8 fbsd8 at a1poweruser.com
Wed May 7 22:42:02 UTC 2014


Craig Rodrigues wrote:
> On Wed, May 7, 2014 at 1:46 PM, Fbsd8 <fbsd8 at a1poweruser.com> wrote:
>> Craig Rodrigues wrote:
> 
>> Thank you Craig for your work around. But the fact is the bootstrap pkg
>> program should work from within a jail. This looks like a bug that needs a
>> PR.
> 
> /usr/sbin/pkg behaves differently on FreeBSD 9
> vs. FreeBSD 10.  You can see the source code in /usr/src/usr.bin/pkg/
> to see how it works.
> 
> Before you run /usr/sbin/pkg for the first time, you need to check if
> any of the following are true in your jail:
> 
> (1)  Is something setting PACKAGESITE in your environment?
> (2)  Do you have any files:
>           /usr/local/etc/pkg.conf
>          /usr/local/etc/pkg/repos/*
> 
> If any of those things are true, they will affect the behavior of /usr/sbin/pkg.
> You will need to delete those files and unset the variable, and then
> apply the workaround
> at: https://github.com/freenas/freenas/blob/master/build/ports/install-ports.sh#L29
> 
> You can try filing a bug against pkg, but the pkg developers might
> tell you that this
> is a bootstrapping problem which is fixed in newer versions of FreeBSD.
> 
> --
> Craig
> 

Figured out the problem.
To create my jail filesystem I download and uncompress the base.txz file 
just like bsdinstall does. This base filesystem has a environment 
variable PACKAGESITE populated with the content needed by the old 
pkg_add -r command which is no longer part of the 10.0 base. bsdinstall 
must do an unsetenv PACKAGESITE on that environment variable during the 
install process to prepare the system for pkgng.

The solution for me is after creating my jail filesystem from the 
base.txz file, I start the jail and then jexec jailname tcsh to open a 
console to the jail. From inside of the jail I issue "unsetenv 
PACKAGESITE" to disable that environment variable. Then issue pkg and 
the pkg bootstrap works as expected.

Now global system environment variables must be saved in some file that 
gets read during the system boot process. Does anyone know where that 
file is located and what its called?











More information about the freebsd-questions mailing list