O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  

Buy the book!
BSD Hacks
By Dru Lavigne
May 2004
More Info

Build a Port Without the Ports Tree
While the ports tree is one of the most useful FreeBSD directory structures, you may have systems where it's not appropriate to maintain the entire ports structure
[Discuss (0) | Link to this hack]

On some of your systems, disk space may be an issue. The ports tree tarball itself is a 21 MB download. Once untarred, it will occupy around 500 MB of disk space. That space will continue to grow as you install ports since, by default, source files download into /usr/ports/distfiles.

Does this mean that installing packages is your only alternative? Packages are convenient, but since they are precompiled, you don't have the option of providing your own make arguments to optimize the install for your environment.

One alternative is the anonymous CVS system. Even a minimal install of FreeBSD includes the cvs command. This allows you to check out only the particular port skeleton you need. You'll still have the convenience of the ports collection without actually having to install it.

Finding a Port and Its Dependencies

Next, decide which port you'd like to install. The only disadvantage to not having the entire ports structure is that you need an alternate method of discovering the name of the port you'd like to install. For example, in order to install lynx, I need to know that it is in the www subdirectory and that there are three different versions of lynx to choose from. The easiest way to discover this information is to use the search utility at http://www.freshports.org.

Once you find the port you're looking for, it will indicate the name of its directory. In my example, lynx-2.8.5d17 lives in www/lynx-current.

Now it's a simple matter of checking out that port's skeleton:

# cvs checkout -A -P -l ports/www/lynx-current
cvs server: Updating ports/www/lynx-current
U ports/www/lynx-current/Makefile
U ports/www/lynx-current/distinfo
U ports/www/lynx-current/pkg-descr
U ports/www/lynx-current/pkg-plist

Next, check the port's Makefile to see if there are any dependencies:

# grep DEPENDS /usr/ports/www/lynx-current/Makefile
LIB_DEPENDS=    intl.5:${PORTSDIR}/devel/gettext

As it stands right now, this port will not install, as I don't have the ports skeleton for the dependency devel/gettext. So, I'll download that port skeleton and double-check that that port doesn't have any dependencies:

# cvs checkout -A -P -l ports/devel/gettext
<snip output>
# grep DEPENDS /usr/ports/devel/gettext/Makefile

Okay, it looks like all dependencies are there. I'm ready to build the port:

# cd /usr/ports/www/lynx-current
# make install clean


If disk space is an issue, instead use make install distclean, which will delete the source from /usr/ports/distfiles once the build successfully completes.

That's it. As long as you remember to look for dependencies before you issue your make install command, your minimal ports structure should work as flawlessly as the full ports collection.

Don't forget to use cvs logout when you're finished retrieving the files you need from the CVS server.

See also:

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.