Ports building options

From FBSD_tips

Jump to: navigation, search

DRAFT - INCOMPLETE

Or why "Any port in a storm" is a really bad course.

Contents

[edit] rationale

Setting options in a non-interactive way and saving packages built with these options separately is very important when building large port dependency trees. Editting /etc/make.conf can be used to do this, but is dangerous as options simply put there are global to all use of make. Here I will discuss some basic techniques to accomplish setting options but keep the scope of those option confined to ports they apply to. Additionally I will keep groups of applications separated based on common options and for related purposes. Another article will detail how to use these package groups to install onto geared purpose FreeBSD installations.

[edit] Optional prerequisites

(or is "Optional prerequisites" an oxymoron?)

This article is meant as a follow on to Jail building and Ports jail although I have kept it as applicable to general situations. Where I use some feature of the Jail building or Ports jail I will attempt to note it.

[edit] examples

[edit] Include an option file for ports

This will include the ports.conf file, but only when you are invoking make from within the ports tree.

In /etc/make.conf :

.if ${.CURDIR:M*/usr/ports*}
.include "/etc/ports.conf"
.endif

[edit] Based on directories

This will further restrict options based on the directory in the ports tree.

In /etc/ports.conf

.if ${.CURDIR:M*/lang/erlang*}
WITHOUT_ODBC=true
.endif

[edit] Based on defines

Here we make a custom define that bundles together multiple options.

In /etc/ports.conf

.if defined(MY_PROFILE_OPTIONS)
OPTION1=foo
OPTION2=bar
.endif

Now to get the group of options: OPTION1=foo OPTION2=bar, just type make -DMY_PROFILE_OPTIONS.

[edit] Separating the profile results

Once you have your profile worked out, you will want to separate the resulting packages so it don't overwrite other profile's packages. you do this with the PACKAGES variable (see /usr/ports/bsd.port.mk for more options).

In /etc/ports.conf :

.if defined(MY_PROFILE_OPTIONS)
OPTION1=foo
OPTION2=bar
PACKAGES=/usr/local/packages/my_profile/
.endif

[edit] Putting it all together

[edit] Setting up package bundles

Now we will use these conditional defines to group together bundles of customized applications geared for the tasks they will be put towards. We will also keep these customized packages separated from eachother so they can be installed as groups.

We will create a directory heirarchy to hold the groups of options.

/usr/local/ports_configs/options

We will set up a custom flag for a group of options specific to Wordpress : MY_MEDIAWIKI_BUNDLE. This flag will be the name of a file containing all the packages in the same format as pkg_info -o -q would print it out as (hmmmm, I wonder where we will get this list ;) ).

These are the options for this bundle :

.if defined(WORDPRESS_BUNDLE)
PACKAGES=/usr/local/packages/wordpress/
# php options for wordpress
BCMATH=off "bc style precision math functions"
BZ2=on "bzip2 library support"
CALENDAR=off "calendar conversion support"
CTYPE=on "ctype functions"
CURL=off "CURL support"
DBA=off "dba support"
DBASE=off "dBase library support"
DOM=on "DOM support"
EXIF=off "EXIF support"
FILEINFO=off "fileinfo support"
FILTER=on "input filter support"
FRIBIDI=off "FriBidi support"
FTP=off "FTP support"
GD=on "GD library support"
GETTEXT=off "gettext library support"
GMP=off "GNU MP support"
HASH=on "HASH Message Digest Framework"
ICONV=on "iconv support"
IMAP=off "IMAP support"
INTERBASE=off "Interbase 6 database support (Firebird)"
JSON=on "JavaScript Object Serialization support"
LDAP=off "OpenLDAP support"
MBSTRING=on "multibyte string support"
MCRYPT=on "Encryption support"
MHASH=off "Crypto-hashing support"
MING=off "ming shockwave flash support"
MSSQL=off "MS-SQL database support"
MING=off "ming shockwave flash support"
MSSQL=off "MS-SQL database support"
MYSQL=on "MySQL database support"
MYSQLI=off "MySQLi database support"
NCURSES=off "ncurses support (CLI only)"
ODBC=off "unixODBC support"
OPENSSL=on "OpenSSL support"
PCNTL=off "pcntl support (CLI only)"
PCRE=on "Perl Compatible Regular Expression support"
PDF=off "PDFlib support (implies GD)"
PDO=on "PHP Data Objects Interface (PDO)"
PDO_SQLITE=on "PDO sqlite driver"
PGSQL=off "PostgreSQL database support"
POSIX=on "POSIX-like functions"
PSPELL=off "pspell support"
READLINE=off "readline support (CLI only)"
RECODE=off "recode support"
SESSION=on "session support"
SHMOP=off "shmop support"
SIMPLEXML=on "simplexml support"
SNMP=off "SNMP support"
SOAP=off "SOAP support"
SOCKETS=off "sockets support"
SPL=on "Standard PHP Library"
SQLITE=on "sqlite support"
SYBASE_CT=off "Sybase database support"
SYSVMSG=off "System V message support"
SYSVSEM=off "System V semaphore support"
SYSVSHM=off "System V shared memory support"
TIDY=off "TIDY support"
TOKENIZER=on "tokenizer support"
WDDX=off "WDDX support (implies XML)"
XML=on "XML support"
XMLREADER=on "XMLReader support"
XMLRPC=off "XMLRPC-EPI support"
XMLWRITER=on "XMLWriter support"
XSL=off "XSL support (Implies DOM)"
YAZ=off "YAZ support (ANSI/NISO Z39.50)"
ZIP=off "ZIP support"
ZLIB=off "ZLIB support"
.endif

The PACKAGES= option will place the package resulting form a make package or make package-recursive into the directory specified. This will keel different bundles with common packages from stepping on each other.

Once this is set up, here is how t prepare a full set of wordpress packages with these customizations:

cd /usr/ports/www/wordpress
make -DWORDPRESS_BUNDLE package-recursive

[edit] Keeping the environment pristine

Although I no longer use portupgrade itself, it includes a nice little utility for cleaning up a ports tree, portsclean. Using this you can clean all the working directories, eliminate obsolete distfiles and obsolete package tarballs too, (tho I tend to leave those).

cd /usr/ports/ports-mgmt/portupgrade 
make install clean
portsclean --workclean --distclean --libclean

Now we eliminate all the installed packages from with the package tar balls got made.

pkg_delete -a

And we should be back to a pristine building environment. If you created this ports building environment in jail following the Jail building article, you can confirm this using mtree (see What changed for an mtree tutorial).

[edit] Discussion

I like keeping my changes in a separate file from the base system's so that if e.g. mergemaster ever steps on it re-adding it is as simple as putting the include back in.

Related port : /usr/ports/ports-mgmt/portconf

/usr/ports/Mk/ is where the brains of ports resides.

Gongo 16:26, 14 February 2008 (UTC)

Personal tools