make release in custom directory

Hi all,

I'm trying to build FreeBSD from scratch in a custom directory. In my line of testing, I was able to get to start to finish by using the default directories (/usr/src and /usr/obj). However, I would like to now use a custom directory to specify where the source is and where the object files should be located, so that I can build it under Jenkins. I'm aware of the fact that there's a release.sh script that can do everything - build kernel, world, and installer images - however, I would eventually like to insert some additional steps after buildworld and buildkernel which is why I'm doing it this way.

I was succesful in buildworld and buildkernel by specifying the MAKEOBJDIRPREFIX variable in make - but I can't seem to figure out how to build the release iso.

Here's a rough outline of what I'm doing

Code:
cd /path/to/source
make buildkernel KERNCONF=CUSTOM MAKEOBJDIRPREFIX="`realpath ./obj`" SRCCONF="`realpath ./src.conf``" __MAKE_CONF="`realpath ./make.conf``"
make buildworld MAKEOBJDIRPREFIX="`realpath ./obj`" SRCCONF="`realpath ./src.conf`" __MAKE_CONF="`realpath ./make.conf`"
cd release
make release KERNCONF=CUSTOM MAKEOBJDIR="`realpath ../obj`" -DNO_ROOT

The make release failed, so I tried again but this time specifying CHROOTDIR and CHROOTBUILD_SKIP instead, which also didn't work. Here's the output of the current errors that I'm looking at for make release
https://pastebin.com/5BGCrMry

Please let me know if I'm going in the right direction, or if there's a better way to approach this!

Thanks
 
How I build my releases:
Code:
cd /usr/src
make buildworld buildkernel
cd /usr/src/release
make -DNOPORTS -DNODOC -DNOPKGS KERNCONF=GENERIC release
make -DNOPORTS -DNODOC -DNOPKGS KERNCONF=GENERIC DESTDIR=/storage/release/12-stable install
It doesn't matter where your source lives, it doesn't have to be /usr/src/ and you don't have to set anything if you use a different base directory. As long as the structure of the source tree itself remains the same. You already found WRKDIRPREFIX to change the default /usr/obj. You don't have to set anything else. The install stage will create a FTP directory under DESTDIR and will also store the ISO and memory stick images there.
 
How I build my releases:
Code:
cd /usr/src
make buildworld buildkernel
cd /usr/src/release
make -DNOPORTS -DNODOC -DNOPKGS KERNCONF=GENERIC release
make -DNOPORTS -DNODOC -DNOPKGS KERNCONF=GENERIC DESTDIR=/storage/release/12-stable install
It doesn't matter where your source lives, it doesn't have to be /usr/src/ and you don't have to set anything if you use a different base directory. As long as the structure of the source tree itself remains the same. You already found WRKDIRPREFIX to change the default /usr/obj. You don't have to set anything else. The install stage will create a FTP directory under DESTDIR and will also store the ISO and memory stick images there.
Is WRKDIRPREFIX separate from MAKEOBJDIRPREFIX?

This is currently what I'm doing to build the world and kernel
Code:
cd /usr/local/jenkins/workspace/testing
make buildkernel KERNCONF=CUSTOM __MAKE_CONF=`realpath ./make.conf` MAKEOBJDIRPREFIX=`realpath ./obj` -j8
make buildworld SRCCONF=`realpath ./src.conf` __MAKE_CONF=`realpath ./make.conf` MAKEOBJDIRPREFIX=`realpath ./obj` -j8
That part completes succesfully, and I see the directory structure inside the ./obj folder. However, when running a make release similar to what you're running
Code:
make -DNOPORTS -DNODOC -DNOPKGS KERNCONF=CUSTOM release
I get all kinds of errors
https://pastebin.com/3PiaGD6L

This same build procedure works fine with the source in /usr/src and the objects going into /usr/obj, as your setup is, but it seems that the moment I try to change these folders release breaks.
 
Oh, oops. Sorry, WRKDIRPREFIX is actually for building ports (it changes the work/ directory, useful if you have a read-only /usr/ports/). It's indeed MAKEOBJDIRPREFIX for building world and all.
 
I figured out what the issue was - I'm leaving this here for any future readers.

I was specifying a make.conf and src.conf when building the world and kernel, but not when building the release. In those configuration files, I had disabled certain things that make release was trying to include as a dependency. By passing SRCCONF and __MAKE_CONF as environment variables to my make release, I was able to successfully create the ISO.

However, since this is not running as root, it seems like certain binaries and files are not getting their appropriate permissions set as I'm not running as root. For example, bsdinstall rootpass fails because the passwd file doesn't have the correct permissions. As a temporary workaround, I gave my jenkins user access to sudo without a password, but this is obviously not ideal. If anybody else has any experience on building a release dvd iso without root, I would appreciate any pointers.
 
Back
Top