Standard Source Build Process


Now that you have the latest source code for the version you want, you can try to build it. If everything goes well, building from source is completely routine. (If something goes wrong, you're stuck relying on your brain, which is a situation I personally prefer to not be in.) We'll first document how the process should work and then proceed to discuss some of the issues you might encounter.

First, be completely certain that you have backed up any data that you or your users might still feel attached to, as upgrading from source adds an additional layer of risk to the upgrade process. If in doubt, back up!

Review the Upgrading Mini-FAQ very closely for the version you're upgrading to, as discussed earlier in this chapter. Generally speaking, there should be no issue with upgrading to an newer version of the same release of OpenBSD-stable — for example, no special preparations should be necessary to upgrade from OpenBSD 3.2-stable as of December to OpenBSD 3.2-stable as of March. If you are upgrading to a newer release of OpenBSD or to OpenBSD-current, you must follow all of the steps listed in the Upgrading Mini-FAQ.

Working as Root

While you can use sudo(1) for everything while upgrading your system, it's simplest to actually become root before starting the upgrade. Running these operations as root may not fit with your security stance, however. Add an entry like the below for sudo in /etc/mk.conf, and the build process will call sudo(8) at appropriate times.

 SUDO=/usr/bin/sudo 

You will still need to add sudo(8) calls to the various preparatory commands — for example, "make obj" will become "sudo make obj." If your build machine is slow, you may have to enter your password repeatedly. You can get around that by not requiring a password to run commands as root, but that also may not fit your security stance.

For the rest of this section, I will assume that you are logged in as root.

The Build Commands

First, make sure you have a /usr/obj directory. This is where the build process will store the actual binaries, and pieces thereof, that it creates. You do not want the system to build the binaries under the /usr/src directory! If you do not have a /usr/obj directory, create one.

Now go into the /usr/src directory. All commands from this point on will be run under /usr/src, unless specified otherwise.

If you have compiled errata on this system, or if you have previously upgraded from source, you might have old binary objects scattered throughout your source tree. These binaries will interfere with the upgrade process, and need to be removed. To be absolutely certain you have eliminated all binaries from your source tree, run the following command.

 # find . -type l -name obj | xargs rm # make cleandir # rm -rf /usr/obj/* 

Now that you have blown away any binaries lurking in the source tree, create a new directory hierarchy for the new binaries.

 # make obj 

You will see several screens of output as make(1) builds a directory tree under /usr/obj and sets appropriate symlinks from the source tree to those new directories.

Before you can install your freshly built software, you must tell the system to create any necessary directories for new programs. The /etc/ directory frequently needs new directories as programs are enhanced. You can do this as we show here.

 # cd /usr/src/etc # make DESTDIR=/ distrib-dirs 

Make(1) will spit out a few lines about directories and links it creates.

Now that you have some basic preparations, build a new GENERIC kernel from source and install it. You could use a custom kernel for this, but if something goes wrong you will have to try to decide whether your kernel or your source code is at fault. Play it safe, use the GENERIC kernel. This new kernel must be considered experimental; keep your old kernel as an emergency backup! Fortunately, building the whole operating system from source code is an excellent stress test of a kernel.

Reboot on your new kernel. Do not attempt to build a new system on an old kernel, especially when upgrading to OpenBSD-current, or you may find the build failing because of missing or incompatible system calls.

Once your system has rebooted on the new kernel, go to /usr/src and type:

 # make build 

This one command will build the entire system from source and install it on the system! On an Athlon 1800+, the build takes less than an hour. On a Pentium 50, this can take days. Eventually, you'll see something like the following:

 ..... cd /usr/src/share/man && exec make makedb /usr/libexec/makewhatis /usr/share/man # 

The last stage of the build process is to run makewhatis(1) on the manual page collection, so the new man pages can be easily searched.

The system is now in a state similar to what it would be after installing the new distributions from a CD-ROM or FTP. You still need to merge /etc/ and take care of any actions recommended in the Upgrading Mini-FAQ. I recommend the following process. First, install the updated Apache manual.

 # cd /usr/src/usr.sbin/httpd # make -f Makefile.bsd-wrapper distribution 

Check the Upgrade Mini-FAQ, and remove any programs or files it targets, then run mergemaster(8). Reboot one last time, and if the system comes back up you have successfully upgraded!

Source Upgrade Problems

If the upgrade from source process does not work, you need to fire up your brain cells and debug it. Start by reading the error message you received, and try to figure out what it means.

Don't forget, there is a delay between the appearance of an issue and the Upgrade Mini-FAQ being updated. Definitely search the mailing list archives for other people having this issue. Frequently, new users or groups that are added to the system cause upgrade problems; you can easily work around these problems by adding the user or group.

It is also possible that you grabbed the system source at a moment when some committer was in the middle of a large commit or on one of those rare occasions when the build process was broken. Wait a day, update your source repository again, and try to build the source code once more.

If you hack on the source code yourself, perhaps you broke the upgrade process. Try removing your changes and start again from a clean source code tree.

If all else fails, follow the standard troubleshooting process discussed in Chapter 1. People upgrading from source are generally expected to be able to troubleshoot compilation problems, however.

If you have trouble, remember you can always upgrade to snapshots and releases from CD-ROM. Upgrading from source is only for the advanced user; if you're not yet an advanced user, this is something to work toward.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net