<chunkynotes version="1.0" title="FreeBSD Tips">
   <summary>Assorted FreeBSD stuff.</summary>

   <intro>
      The below notes are mostly from my .plan - I also have some
      <a href="fbsd-stable-ml.html">notes cribbed from the FBSD mailing
         lists.</a>
</intro>

<chunk title="Redirecting or deleting port/package dependencies">
<p>This assumes you are managing your ports with one of the tools that
reads <code>/usr/local/etc/pkgtools.conf</code> (e.g. portupgrade).</p>

<p>This won't prevent make from pulling independencies unless you
   define <code>NO_DEPENDS</code> (e.g. in /etc/make.conf).</p>

<p>Inside the <code>ALT_PKGDEP</code> section, map each port you want
redirected to it's target. To delete dependencies, use :delete as the
target. For example:</p>

<sample><src>
  ALT_PKGDEP = {
        'textproc/libxml' => 'textproc/libxml2',
        'devel/ORBit' => 'devel/ORBit2',
        'graphics/imlib' => 'graphics/imlib2',
        'textproc/ispell' => 'textproc/aspell',
        'media/gnome-media' => :delete, #gnome meta-ports won't pull this in
        'media/gstreamer' => :delete,
  }
</src></sample>

<p>Some libraries can't be redirected like this - for example, some
GTK1.x programs will not build with GTK2.x. Remember, this only
redirects the dependencies that portupgrade (et al) use when
installing or upgrading ports. It won't remove existing ports or
prevent you from installing the old ones directly.</p>
</chunk>

<chunk title="Cutting down the buildkernel (and modules) time">
<p>First of all, create a custom kernel config and get rid of stuff
you won't be using. I recommend building a GENERIC kernel as well as
your custom one just in case.</p>

<p>Removing items from the kernel config won't stop <code>make
buildkernel</code> from creating them as modules though. To stop the
modules from being made.</p>

<ul>
   <li>ls -l /boot/kernel/*.ko | sort +4</li>

   <li>Starting with the largest files, check what they are in the man
      pages (e.g. "man nve" for "if_nve.ko") to see if you need
      them.</li>
   <ul>
      <li> The largest modules are usually the ones which take the
        longest to build. They are almost all drivers for wireless
        interfaces you don't have or scsi cards you don't have.
        Occasionally they will be ethernet cards you don't have.</li>
  </ul>

  <li> Add the modules you don't need to WITHOUT_MODULES in /etc/make.conf
   or whatever is included when you build your kernel. If in doubt
   about a particular module, don't add it to the list. In particular,
   don't add the base wireless or ethernet modules to the list, even if
   you don't have a wireless or ethernet card to use.</li>
</ul>
</chunk>

<chunk title="Keeping the locate database sane">

<p>Put any directories which you DON'T want scanned for locate(1) in the
PRUNEPATHS var in <code>/etc/locate.rc</code> - for example:</p>

<sample><src>PRUNEPATHS="/tmp /usr/tmp /var/tmp /var/db/portsnap /scratch"</src></sample>

<p>Filesystems which are not of the type specified in
<code>/etc/locate.rc</code> will not be scanned either.</p>
</chunk>

<chunk title="Quick guide to tracking/updating FreeBSD-STABLE">
   <sample><src>
# csup stable-supfile
# cd /usr/src
# rm -rf /usr/opt/*
# make buildworld
# make buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL
   - (must reboot into single user mode with new kernel)
# mergemaster -p
# make installworld
# mergemaster
   - (get rid of /var/run/temproot when done merging)
   - (reboot into multi-user mode)
</src></sample>

A few extra points:
<ul>
   <li> You *must* complete the mergemaster steps before moving on. If you
  skip any files you must rerun mergemaster or merge manually before
  proceeding to the next step in the process.</li>
  <li> When you reboot into single user, remember you may need to fsck,
     mount -a, turn swapping on if it will be needed, etc.</li>
  <li> If using an option to buildworld you must give it to installworld
     too. For example:</li>
<sample><cli>
      make -DNOPROFILE buildworld
      ...
      make -DNOPROFILE installworld
        </cli></sample>
        <li> Check the mailing lists, usr/src/updating, etc for any potential
           issues</li>
  <li> If building across version boundaries (e.g. -PRERELEASE tags), you
     may need to mergemaster -p before building world. Check
     UPDATING.</li>
  </ul>

  <p>Saving dump (backup) space: You won't need to dump /usr/src
     (unless you have modified source, in which case you should have
     it in version control anyway) and you won't need /usr/obj at all,
     since it's built from src. On my system they take up more than
     the rest of /usr including home directories, so setting "chflags
     nodump" makes a big difference to the number of backup volumes I
     need.</p>

</chunk>

<chunk title="Once-off Live FileSystem Dumps">
   <sample><cli> dump -0 -L -a [-f file or -p pipe] fsmountpoint</cli></sample>

   -0 full backup (no u so it doesn't touch the dumpdates file)<br/>
-L live filesystem - if you specify this dump will take a UFS
snapshot and dump that. Ignored on a read only or unounted fs.<br/>
-a auto-size (so it writes all to the one file instead of doing
volumes... over the first volume file and breaking it)<br/>
<br/>
-h 0  Honour the nodump flag for full (level 0) dumps. Default is to
ignore nodump unless doing an incremental dump.<br/>
<br/>
-f file (can be - for stdout)<br/>
-p pipecommand (e.g. bzip2 or somesuch)<br/>
</chunk>

<chunk title="Random Hints for port authors/maintainers">

   <ul>
      <li> If a daemon is part of the port, install it but make it *DISABLED* by
  default. You could even put a foobard_enable="no" at the bottom of
  /etc/rc.conf.</li>

  <li> If you have many build options, or some pretty important ones, stop
  and tell the user *BEFORE* the start of build (with a pause so they can
  abort and restart)</li>

  <li> Make (pun!) use of the config/showconfig targets.</li>
  </ul>

  <p>Most importantly, TELL THE USER ABOUT IT. And not somewhere in the middle of the build process where it's going to be missed. Do it at the start with a pause for config/build options, and at the end for defaults and post-install configuration.</p>
</chunk>

<chunk title="Getting apache/php/perl slave ports to work">
   <br/>
mod_ssl only ever seems to work properly if installed with Apache
(rather than adding it later), so make sure you choose apache*-modssl*
or add the make options when you install. Judging from assorted
newsgroups and forums this seems to be a common problem.

However, many things (like php*) have dependencies on "apache13" or
"apache2" and not any extended packages/ports. Once you figure out
what
to do it is actually very easy to fix, just add the line
"APACHE_PORT=www/apache13-modssl" (or similar) to /etc/make.conf .

Thanks go to Dr. Matthew J Seaman in the FreeBSD mailing lists for
pointing me in the right direction.
http://lists.freebsd.org/pipermail/freebsd-questions/2004-April/043816.html
   <br/>
</chunk>

</chunkynotes>
