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: |
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.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 9 of 9.
-
Customizing ports
2004-03-09 01:38:31 mtsachev [Reply | View]
The best way I found for customizing ports is to put your settings in a Makefile.local. That way it's easier to add comments and find your settings faster.
-
Nice article
2003-09-30 05:45:05 anonymous2 [Reply | View]
Way to go Dru, love reading your articles as they are clear, concise and to the point, and whats more you seem to writing articles on what I need at the time. To clean ports out before I went to the /usr/ports and did a make clean, 36 hours later it finished. This only took about 2 mins !!
Keep up the excellent articles.
Matt.
-
great article
2003-09-19 20:11:39 anonymous2 [Reply | View]
Another great article from Dru - Want to thank you for the articles which have a lot of informative info. It's great not spending 50 dollars for a 800 page technical book...since they are some what redundant after buying and reading a couple of them. After getting a feel for ports and your articles on IPFW...I have converted ALL of my machines to FreeBSD. Keep up the good work.
-
Port Understanding
2003-09-19 13:22:05 anonymous2 [Reply | View]
Hello Dru
First, I have to thank you for your decent articles. After I spent time in finding a pin in a heystack from somewhere else, I finally can make the old machine become the server because of your instructions.
I am very new with FreeBSD, specially the installation. If possible, I'd like you to brief on "Port". I mean English in English. I read several times in the Handbook, and I still cannot understand and figure out what I should do. I did not install the ports at the first installation. I tried to do with the Post-Installation, but it didn't work. It said it could not match the port with my version (4.5 Release) on FTP. I tried to get the ports from the original CD's, and it did not work either. My goal is to install MySQL database on the box. Please help.
Thank you for your articles.
Pong
-
I'm going to marry Dru
2003-09-19 09:43:35 anonymous2 [Reply | View]
She just doesn't know it yet.
:)
-
"local" ports?
2003-09-19 09:35:52 anonymous2 [Reply | View]
Any tips on creating and integrating ports for local software? I.e. we have a custom App on a number of servers and I'd love to set it up as a port so that portupgrade can handle upgrades and installs!
I see portupgrade has some hooks for "local" categories but I'd like to see some more info and examples on how to do this!


