BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Cleaning and Customizing Your Ports
Pages: 1, 2

Customizing Available Ports

Let's move on to customizing how you interact with the ports collection. When you installed portupgrade, the files /usr/local/etc/pkgtools.conf and /usr/local/etc/pkgtools.conf.sample were installed for you. By default, both files are the same. Make any changes to /usr/local/etc/pkgtools.conf and keep /usr/local/etc/pkgtools.conf.sample as is, to remind you of the original settings.



If you take the time to read this file, you'll find that it is well commented and chock full of neat and useful advice designed to help you get the most out of your ports. I'll highlight some of the more useful options, but do take the time to check out the full file yourself.

For starters, this file allows you to set the environment variables used by the portupgrade suite of utilities. For example, the default temporary directory is /var/tmp. This default can cause problems on small hard drives where disk space is limited on /var. To change this default, search for this line in /usr/local/etc/pkgtools.conf:

#   ENV['PKG_TMPDIR'] ||= '/var/tmp'

and change it to something like this:

ENV['PKG_TMPDIR'] ||= '/usr/tmp'

Remember to remove the comment (#) and to ensure the new temporary directory exists.

Another useful setting is the ignore categories section:

# IGNORE_CATEGORIES: array
#
# This is a list of port categories you want the pkgtools to ignore.
# Typically you want to list language specific categories of the
# languages you don't use.
#
# After configuring this list, you need to rebuild the ports
# database to reflect the changes. (run 'portsdb -Ufu')
#
# e.g.:
#   IGNORE_CATEGORIES = [
#     'chinese',
#     'french',
#     'german',
#     'hebrew',
#     'japanese',
#     'korean',
#     'russian',
#     'ukrainian',
#     'vietnamese',
#   ]

IGNORE_CATEGORIES = [
]

Here, the comments are quite clear. If you decide to take advantage of this option, remove the # from categories you wish to ignore. While the language categories are suggested, you can ignore any category. For example, if you never plan on installing applications from the astro or irc categories, you can include those. Here is a sample edit:

IGNORE_CATEGORIES = [
    'chinese',
    'german',
    'hebrew',
    'japanese',
    'korean',
    'russian',
    'ukrainian',
    'vietnamese',
    'astro',
]

#	  IGNORE_CATEGORIES = [
# 	]

Notice that I remarked the default empty IGNORE_CATEGORIES section. I then removed the remarks from the section listing the categories I'd like to be ignored. I also used the same format to add the astro category. Don't forget to follow the directions in the comments and:

% portsdb -Ufu

once you've saved your edits to this section.

Customizing Individual Port Build Options

One of the handiest settings in this file is the MAKE_ARGS section. Some ports allow you to customize how they build by specifying certain arguments. These arguments are found in the port's Makefile and are usually invoked like this:

% cd /usr/ports/multimedia/mplayer
% make WITH_GUI=yes WITH_FREETYPE=yes install clean

The above make command is equivalent to this invocation:

% make -DWITH_GUI -DWITH_FREETYPE install clean

If you ever plan on using portupgrade to upgrade mplayer and wish to use the same arguments, you have a choice. Either count on your ability to remember to use the m switch to specify your make arguments with portupgrade:

% portupgrade -rRm '-DWITH_GUI' '-DWITH_FREETYPE' mplayer

or spend a moment and add those switches to /usr/local/etc/pkgtools.conf:

MAKE_ARGS = {
    'multimedia/mplayer-*' => 'WITH_GUI=1 WITH_FREETYPE=1',
}

Also in FreeBSD Basics:

Fun with Xorg

Sharing Internet Connections

Building a Desktop Firewall

Using DesktopBSD

Using PC-BSD

Let's pick that apart, as it looks a bit complicated and the syntax is rather picky. Notice that the entire MAKE_ARGS section is enclosed within curly brackets ({ and }). Within those brackets are the particular ports and their make arguments. This means you can keep adding ports to this section, each on their own line, ensuring that all of the ports are between those brackets.

The name of the port itself must be quoted in single quotes (') and includes the name of its subdirectory in the ports collection. The name is followed by the wildcard -*.

The make arguments themselves are also enclosed between single quotes located after the =>. Note that the number 1 is used instead of the word yes and that the arguments are separated by a space.

It's worth your while to spend the few minutes it takes to add your arguments to this section whenever you first build a port that uses arguments. You'll eventually upgrade that port, and it is highly unlikely that you'll even remember that it used arguments, let alone what those actual arguments were.

Ports Tools

Let's finish this series by peeking at the tools section of the ports tree. If you haven't discovered it on your own yet, take a look at:

% more /usr/ports/Tools/scripts/README

Gee, just when you thought you knew everything there was to know about ports, you find there's a whole new stash of useful utilities. Since these are all scripts, don't forget to put a ./ in front of the name as you try out each of the scripts:

% cd /usr/ports/Tools/scripts
% ./consistency-check

I'd suggest trying out each script that piques your interest as you read its description in the README file. If you find some new favorites, consider either copying them or symlinking them to ~/bin so they will be in your path.

I hope you've enjoyed the past few articles on the ports collection. I'll be taking a break from the series over the next few months in order to write a book. Stay tuned for more details.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.


Read more FreeBSD Basics columns.

Return to the BSD DevCenter.




Sponsored by: