Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The FreeBSD Documentation Project
FreeBSD is a registered trademark of The FreeBSD Foundation.
UNIX is a registered trademark of The Open Group in the US and other countries.
Sun, Sun Microsystems, SunOS, Solaris, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
Apple and QuickTime are trademarks of Apple Computer, Inc., registered in the U.S. and other countries.
Macromedia and Flash are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries.
Microsoft, Windows, and Windows Media are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
PartitionMagic is a registered trademark of PowerQuest Corporation in the United States and/or other countries.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the FreeBSD Project was aware of the trademark claim, the designations have been followed by the '™' symbol.
Redistribution and use in source (SGML DocBook) and 'compiled' forms (SGML, HTML, PDF, PostScript, RTF and so forth) with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code (SGML DocBook) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified.
Redistributions in compiled form (transformed to other DTDs, converted to PDF, PostScript, RTF and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Important: THIS DOCUMENTATION IS PROVIDED BY THE FREEBSD DOCUMENTATION PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
exec statement in
wrapper scriptsThe FreeBSD ports collection is the way almost everyone installs applications ("ports") on FreeBSD. Like everything else about FreeBSD, it is primarily a volunteer effort. It is important to keep this in mind when reading this document.
In FreeBSD, anyone may submit a new port, or volunteer to maintain an existing port if it is unmaintained--you do not need any special commit privileges to do so.
So, you are interested in making your own port or upgrading an existing one? Great!
What follows are some guidelines for creating a new port for FreeBSD. If you want to upgrade an existing port, you should read this and then read Chapter 10.
When this document is not sufficiently detailed, you should refer to /usr/ports/Mk/bsd.port.mk, which all port Makefiles include. Even if you do not hack Makefiles daily, it is well commented, and you will still gain much knowledge from it. Additionally, you may send specific questions to the FreeBSD ports mailing list.
Note: Only a fraction of the variables (VAR) that can be overridden are mentioned in this document. Most (if not all) are documented at the start of /usr/ports/Mk/bsd.port.mk; the others probably ought to be. Note that this file uses a non-standard tab setting: Emacs and Vim should recognize the setting on loading the file. Both vi(1) and ex(1) can be set to use the correct value by typing :set tabstop=4 once the file has been loaded.
This section tells you how to do a quick port. In many cases, it is not sufficient, so you will have to read further on into the document.
First, get the original tarball and put it into DISTDIR, which defaults to /usr/ports/distfiles.
Note: The following assumes that the software compiled out-of-the-box, i.e., there was absolutely no change required for the port to work on your FreeBSD box. If you needed to change something, you will have to refer to the next section too.
The minimal Makefile would look something like this:
# New ports collection makefile for: oneko # Date created: 5 December 1994 # Whom: asami # # $FreeBSD$ # PORTNAME= oneko PORTVERSION= 1.1b CATEGORIES= games MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ MAINTAINER= asami@FreeBSD.org COMMENT= A cat chasing a mouse all over the screen MAN1= oneko.1 MANCOMPRESSED= yes USE_IMAKE= yes .include <bsd.port.mk>
See if you can figure it out. Do not worry about the contents of the $FreeBSD$ line, it will be filled in automatically by CVS when the port is imported to our main ports tree. You can find a more detailed example in the sample Makefile section.
There are two description files that are required for any port, whether they actually package or not. They are pkg-descr and pkg-plist. Their pkg- prefix distinguishes them from other files.
This is a longer description of the port. One to a few paragraphs concisely explaining what the port does is sufficient.
Note: This is not a manual or an in-depth description on how to use or compile the port! Please be careful if you are copying from the README or manpage; too often they are not a concise description of the port or are in an awkward format (e.g., manpages have justified spacing). If the ported software has an official WWW homepage, you should list it here. Prefix one of the websites with WWW: so that automated tools will work correctly.
The following example shows how your pkg-descr should look:
This is a port of oneko, in which a cat chases a poor mouse all over the screen. : (etc.) WWW: http://www.oneko.org/
This file lists all the files installed by the port. It is also called the ``packing list'' because the package is generated by packing the files listed here. The pathnames are relative to the installation prefix (usually /usr/local or /usr/X11R6). If you are using the MANn variables (as you should be), do not list any manpages here. If the port creates directories during installation, make sure to add @dirrm lines to remove them when the package is deleted.
Here is a small example:
bin/oneko lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm @dirrm lib/X11/oneko
Refer to the pkg_create(1) manual page for details on the packing list.
Note: It is recommended that you keep all the filenames in this file sorted alphabetically. It will make verifying the changes when you upgrade the port much easier.
Note: Creating a packing list manually can be a very tedious task. If the port installs a large numbers of files, creating the packing list automatically might save time.
There is only one case when pkg-plist can be omitted from a port. If the port installs just a handful of files, and perhaps directories, the files and directories may be listed in the variables PLIST_FILES and PLIST_DIRS, respectively, within the port's Makefile. For instance, we could get along without pkg-plist in the above oneko port by adding the following lines to the Makefile:
PLIST_FILES= bin/oneko \
lib/X11/app-defaults/Oneko \
lib/X11/oneko/cat1.xpm \
lib/X11/oneko/cat2.xpm \
lib/X11/oneko/mouse.xpm
PLIST_DIRS= lib/X11/oneko
Of course, PLIST_DIRS should be left unset if a port installs no directories of its own.
The price for this way of listing port's files and directories is that you cannot use command sequences described in pkg_create(1). Therefore, it is suitable only for simple ports and makes them even simpler. At the same time, it has the advantage of reducing the number of files in the ports collection. Please consider using this technique before you resort to pkg-plist.
Later we will see how pkg-plist and PLIST_FILES can be used to fulfil more sophisticated tasks.
Just type make makesum. The ports make rules will automatically generate the file distinfo.
If a file fetched has its checksum changed regularly and you are certain the source is trusted (i.e. it comes from manufacturer CDs or documentation generated daily), you should specify these files in the IGNOREFILES variable. Then the checksum is not calculated for that file when you run make makesum, but set to IGNORE.
You should make sure that the port rules do exactly what you want them to do, including packaging up the port. These are the important points you need to verify.
pkg-plist does not contain anything not installed by your port
pkg-plist contains everything that is installed by your port
Your port can be installed multiple times using the reinstall target
Your port cleans up after itself upon deinstall
Recommended test ordering
make install
make package
make deinstall
pkg_add package-name
make deinstall
make reinstall
make package
Make sure that there are not any warnings issued in any of the package and deinstall stages. After step 3, check to see if all the new directories are correctly deleted. Also, try using the software after step 4, to ensure that it works correctly when installed from a package.
The most thorough way to automate these steps is via installing the ports tinderbox. This maintains jails in which you can test all of the above steps without changing the state of your running system. Please see ports/ports-mgmt/tinderbox for more information.
Please use portlint to see if your port conforms to our guidelines. The ports-mgmt/portlint program is part of the ports collection. In particular, you may want to check if the Makefile is in the right shape and the package is named appropriately.
First, make sure you have read the DOs and DON'Ts section.
Now that you are happy with your port, the only thing remaining is to put it in the main FreeBSD ports tree and make everybody else happy about it too. We do not need your work directory or the pkgname.tgz package, so delete them now. Next, simply include the output of shar `find port_dir` in a bug report and send it with the send-pr(1) program (see Bug Reports and General Commentary for more information about send-pr(1)). Be sure to classify the bug report as category ports and class change-request (Do not mark the report confidential!). Also add a short description of the program you ported to the ``Description'' field of the PR and the shar to the ``Fix'' field.
Note: You can make our work a lot easier, if you use a good description in the synopsis of the problem report. We prefer something like ``New port: <category>/<portname> <short description of the port>'' for new ports and ``Update port: <category>/<portname> <short description of the update>'' for port updates. If you stick to this scheme, the chance that someone will take a look at your PR soon is much better.
One more time, do not include the original source distfile, the work directory, or the package you built with make package.
After you have submitted your port, please be patient. Sometimes it can take a few months before a port is included in FreeBSD, although it might only take a few days. You can view the list of ports waiting to be committed to FreeBSD.
Once we have looked at your port, we will get back to you if necessary, and put it in the tree. Your name will also appear in the list of Additional FreeBSD Contributors and other files. Isn't that great?!? :-)
Ok, so it was not that simple, and the port required some modifications to get it to work. In this section, we will explain, step by step, how to modify it to get it to work with the ports paradigm.
First, this is the sequence of events which occurs when the user first types make in your port's directory. You may find that having bsd.port.mk in another window while you read this really helps to understand it.
But do not worry if you do not really understand what bsd.port.mk is doing, not many people do... :->
The fetch target is run. The fetch target is responsible for making sure that the tarball exists locally in DISTDIR. If fetch cannot find the required files in DISTDIR it will look up the URL MASTER_SITES, which is set in the Makefile, as well as our main FTP site at ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/, where we put sanctioned distfiles as backup. It will then attempt to fetch the named distribution file with FETCH, assuming that the requesting site has direct access to the Internet. If that succeeds, it will save the file in DISTDIR for future use and proceed.
The extract target is run. It looks for your port's distribution file (typically a gzip'd tarball) in DISTDIR and unpacks it into a temporary subdirectory specified by WRKDIR (defaults to work).
The patch target is run. First, any patches defined in PATCHFILES are applied. Second, if any patch files named patch-* are found in PATCHDIR (defaults to the files subdirectory), they are applied at this time in alphabetical order.
The configure target is run. This can do any one of many different things.
If it exists, scripts/configure is run.
If HAS_CONFIGURE or GNU_CONFIGURE is set, WRKSRC/configure is run.
If USE_IMAKE is set, XMKMF (default: xmkmf -a) is run.
The build target is run. This is responsible for descending into the port's private working directory (WRKSRC) and building it. If USE_GMAKE is set, GNU make will be used, otherwise the system make will be used.
The above are the default actions. In addition, you can define targets pre-something or post-something, or put scripts with those names, in the scripts subdirectory, and they will be run before or after the default actions are done.
For example, if you have a post-extract target defined in your Makefile, and a file pre-build in the scripts subdirectory, the post-extract target will be called after the regular extraction actions, and the pre-build script will be executed before the default build rules are done. It is recommended that you use Makefile targets if the actions are simple enough, because it will be easier for someone to figure out what kind of non-default action the port requires.
The default actions are done by the bsd.port.mk targets do-something. For example, the commands to extract a port are in the target do-extract. If you are not happy with the default target, you can fix it by redefining the do-something target in your Makefile.
Note: The ``main'' targets (e.g., extract, configure, etc.) do nothing more than make sure all the stages up to that one are completed and call the real targets or scripts, and they are not intended to be changed. If you want to fix the extraction, fix do-extract, but never ever change the way extract operates!
Now that you understand what goes on when the user types make, let us go through the recommended steps to create the perfect port.
Get the original sources (normally) as a compressed tarball (foo.tar.gz or foo.tar.Z) and copy it into DISTDIR. Always use mainstream sources when and where you can.
You will need to set the variable MASTER_SITES to reflect where the original tarball resides. You will find convenient shorthand definitions for most mainstream sites in bsd.sites.mk. Please use these sites--and the associated definitions--if at all possible, to help avoid the problem of having the same information repeated over again many times in the source base. As these sites tend to change over time, this becomes a maintenance nightmare for everyone involved.
If you cannot find a FTP/HTTP site that is well-connected to the net, or can only find sites that have irritatingly non-standard formats, you might want to put a copy on a reliable FTP or HTTP server that you control (e.g., your home page).
If you cannot find somewhere convenient and reliable to put the distfile we can ``house'' it ourselves on ftp.FreeBSD.org; however, this is the least-preferred solution. The distfile must be placed into ~/public_distfiles/ of someone's freefall account. Ask the person who commits your port to do this. This person will also set MASTER_SITES to MASTER_SITE_LOCAL and MASTER_SITE_SUBDIR to their freefall username.
If your port's distfile changes all the time without any kind of version update by the author, consider putting the distfile on your home page and listing it as the first MASTER_SITES. If you can, try to talk the port author out of doing this; it really does help to establish some kind of source code control. Hosting your own version will prevent users from getting “checksum mismatch” errors, and also reduce the workload of maintainers of our FTP site. Also, if there is only one master site for the port, it is recommended that you house a backup at your site and list it as the second MASTER_SITES.
If your port requires some additional `patches' that are available on the Internet, fetch them too and put them in DISTDIR. Do not worry if they come from a site other than where you got the main source tarball, we have a way to handle these situations (see the description of PATCHFILES below).
Unpack a copy of the tarball in a private directory and make whatever changes are necessary to get the port to compile properly under the current version of FreeBSD. Keep careful track of everything you do, as you will be automating the process shortly. Everything, including the deletion, addition, or modification of files should be doable using an automated script or patch file when your port is finished.
If your port requires significant user interaction/customization to compile or install, you should take a look at one of Larry Wall's classic Configure scripts and perhaps do something similar yourself. The goal of the new ports collection is to make each port as ``plug-and-play'' as possible for the end-user while using a minimum of disk space.
Note: Unless explicitly stated, patch files, scripts, and other files you have created and contributed to the FreeBSD ports collection are assumed to be covered by the standard BSD copyright conditions.
In the preparation of the port, files that have been added or changed can be picked up with a diff(1) for later feeding to patch(1). Each patch you wish to apply should be saved into a file named patch-* where * indicates the pathname of the file that is patched, such as patch-Imakefile or patch-src-config.h. These files should be stored in PATCHDIR (usually files/, from where they will be automatically applied. All patches must be relative to WRKSRC (generally the directory your port's tarball unpacks itself into, that being where the build is done). To make fixes and upgrades easier, you should avoid having more than one patch fix the same file (e.g., patch-file and patch-file2 both changing WRKSRC/foobar.c).
Please only use characters [-+._a-zA-Z0-9] for naming your patches. Do not use any other characters besides them. Do not name your patches like patch-aa or patch-ab etc, always mention path and file name in patch names.
Do not put RCS strings in patches. CVS will mangle them when we put the files into the ports tree, and when we check them out again, they will come out different and the patch will fail. RCS strings are surrounded by dollar ($) signs, and typically start with $Id or $RCS.
Using the recurse (-r) option to diff(1) to generate
patches is fine, but please take a look at the resulting patches to make sure you do not
have any unnecessary junk in there. In particular, diffs between two backup files, Makefiles when the port uses Imake or GNU
configure, etc., are unnecessary and should be deleted. If you
had to edit configure.in and run autoconf to regenerate configure, do not
take the diffs of configure (it often grows to a few thousand
lines!); define USE_AUTOTOOLS=autoconf:261 and take the diffs of
configure.in.
Also, try to minimize the amount of non-functional whitespace changes in your patches. It is common in Open Source world that projects share large amount of code base, but obey different style and indenting rules. If you take working piece of functionality from one project to fix similar area in another, please be careful: the resulting line patch may be full of non-functional changes. It does not only increase the size of the CVS repository but makes it hard to find out what had exactly caused the problem and what did you change at all.
If you had to delete a file, then you can do it in the post-extract target rather than as part of the patch.
Simple replacements can be performed directly from the port Makefile using the in-place mode of sed(1). This is very useful when you need to patch in a variable value. Example:
post-patch:
@${REINPLACE_CMD} -e 's|for Linux|for FreeBSD|g' ${WRKSRC}/README
@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_LIBS}|' ${WRKSRC}/configure
Quite often, there is a situation when the software being ported, especially if it is primarily developed on Windows®, uses the CR/LF convention for most of its source files. This may cause problems with further patching, compiler warnings, scripts execution (/bin/sh^M not found), etc. To quickly convert all files from CR/LF to just LF, add USE_DOS2UNIX=yes to the port Makefile. A list of files to convert can be specified:
USE_DOS2UNIX= util.c util.h
If you want to convert a group of files across subdirectories, DOS2UNIX_REGEX can be used. Its argument is a find compatible regular expression. More on the format is in re_format(7). This option is useful for converting all files of a given extension, for example all source code files leaving binary files intact:
USE_DOS2UNIX= yes DOS2UNIX_REGEX= .*\.(c|cpp|h)
Include any additional customization commands in your configure script and save it in the scripts subdirectory. As mentioned above, you can also do this with Makefile targets and/or scripts with the name pre-configure or post-configure.
If your port requires user input to build, configure, or install, you must set IS_INTERACTIVE in your Makefile. This will allow ``overnight builds'' to skip your port if the user sets the variable BATCH in his environment (and if the user sets the variable INTERACTIVE, then only those ports requiring interaction are built). This will save a lot of wasted time on the set of machines that continually build ports (see below).
It is also recommended that if there are reasonable default answers to the questions, you check the PACKAGE_BUILDING variable and turn off the interactive script when it is set. This will allow us to build the packages for CDROMs and FTP.
Configuring the Makefile is pretty simple, and again we suggest that you look at existing examples before starting. Also, there is a sample Makefile in this handbook, so take a look and please follow the ordering of variables and sections in that template to make your port easier for others to read.
Now, consider the following problems in sequence as you design your new Makefile:
Does it live in DISTDIR as a standard gzip'd tarball named something like foozolix-1.2.tar.gz? If so, you can go on to the next step. If not, you should look at overriding any of the DISTVERSION, DISTNAME, EXTRACT_CMD, EXTRACT_BEFORE_ARGS, EXTRACT_AFTER_ARGS, EXTRACT_SUFX, or DISTFILES variables, depending on how alien a format your port's distribution file is. (The most common case is EXTRACT_SUFX=.tar.Z, when the tarball is condensed by regular compress, not gzip.)
In the worst case, you can simply create your own do-extract target to override the default, though this should be rarely, if ever, necessary.
The first part of the port's Makefile names the port, describes its version number, and lists it in the correct category.
You should set PORTNAME to the base name of your port, and PORTVERSION to the version number of the port.
The PORTREVISION variable is a monotonically increasing value which is reset to 0 with every increase of PORTVERSION (i.e. every time a new official vendor release is made), and appended to the package name if non-zero. Changes to PORTREVISION are used by automated tools (e.g. pkg_version(1)) to highlight the fact that a new package is available.
PORTREVISION should be increased each time a change is made to the port which significantly affects the content or structure of the derived package.
Examples of when PORTREVISION should be bumped:
Addition of patches to correct security vulnerabilities, bugs, or to add new functionality to the port.
Changes to the port Makefile to enable or disable compile-time options in the package.
Changes in the packing list or the install-time behavior of the package (e.g. change to a script which generates initial data for the package, like ssh host keys).
Version bump of a port's shared library dependency (in this case, someone trying to install the old package after installing a newer version of the dependency will fail since it will look for the old libfoo.x instead of libfoo.(x+1)).
Silent changes to the port distfile which have significant functional differences, i.e. changes to the distfile requiring a correction to distinfo with no corresponding change to PORTVERSION, where a diff -ru of the old and new versions shows non-trivial changes to the code.
Examples of changes which do not require a PORTREVISION bump:
Style changes to the port skeleton with no functional change to what appears in the resulting package.
Changes to MASTER_SITES or other functional changes to the port which do not affect the resulting package.
Trivial patches to the distfile such as correction of typos, which are not important enough that users of the package should go to the trouble of upgrading.
Build fixes which cause a package to become compilable where it was previously failing (as long as the changes do not introduce any functional change on any other platforms on which the port did previously build). Since PORTREVISION reflects the content of the package, if the package was not previously buildable then there is no need to increase PORTREVISION to mark a change.
A rule of thumb is to ask yourself whether a change committed to a port is something which everyone would benefit from having (either because of an enhancement, fix, or by virtue that the new package will actually work at all), and weigh that against that fact that it will cause everyone who regularly updates their ports tree to be compelled to update. If yes, the PORTREVISION should be bumped.
From time to time a software vendor or FreeBSD porter will do something silly and release a version of their software which is actually numerically less than the previous version. An example of this is a port which goes from foo-20000801 to foo-1.0 (the former will be incorrectly treated as a newer version since 20000801 is a numerically greater value than 1).
In situations such as this, the PORTEPOCH version should be increased. If PORTEPOCH is nonzero it is appended to the package name as described in section 0 above. PORTEPOCH must never be decreased or reset to zero, because that would cause comparison to a package from an earlier epoch to fail (i.e. the package would not be detected as out of date): the new version number (e.g. 1.0,1 in the above example) is still numerically less than the previous version (20000801), but the ,1 suffix is treated specially by automated tools and found to be greater than the implied suffix ,0 on the earlier package.
Dropping or resetting PORTEPOCH incorrectly leads to no end of grief; if you do not understand the above discussion, please keep after it until you do, or ask questions on the mailing lists.
It is expected that PORTEPOCH will not be used for the majority of ports, and that sensible use of PORTVERSION can often pre-empt it becoming necessary if a future release of the software should change the version structure. However, care is needed by FreeBSD porters when a vendor release is made without an official version number -- such as a code ``snapshot'' release. The temptation is to label the release with the release date, which will cause problems as in the example above when a new ``official'' release is made.
For example, if a snapshot release is made on the date 20000917, and the previous version of the software was version 1.2, the snapshot release should be given a PORTVERSION of 1.2.20000917 or similar, not 20000917, so that the succeeding release, say 1.3, is still a numerically greater value.
The gtkmumble port, version 0.10, is committed to the ports collection:
PORTNAME= gtkmumble PORTVERSION= 0.10
PKGNAME becomes gtkmumble-0.10.
A security hole is discovered which requires a local FreeBSD patch. PORTREVISION is bumped accordingly.
PORTNAME= gtkmumble PORTVERSION= 0.10 PORTREVISION= 1
PKGNAME becomes gtkmumble-0.10_1
A new version is released by the vendor, numbered 0.2 (it turns out the author actually intended 0.10 to actually mean 0.1.0, not ``what comes after 0.9'' - oops, too late now). Since the new minor version 2 is numerically less than the previous version 10, the PORTEPOCH must be bumped to manually force the new package to be detected as ``newer''. Since it is a new vendor release of the code, PORTREVISION is reset to 0 (or removed from the Makefile).
PORTNAME= gtkmumble PORTVERSION= 0.2 PORTEPOCH= 1
PKGNAME becomes gtkmumble-0.2,1
The next release is 0.3. Since PORTEPOCH never decreases, the version variables are now:
PORTNAME= gtkmumble PORTVERSION= 0.3 PORTEPOCH= 1
PKGNAME becomes gtkmumble-0.3,1
Note: If PORTEPOCH were reset to 0 with this upgrade, someone who had installed the gtkmumble-0.10_1 package would not detect the gtkmumble-0.3 package as newer, since 3 is still numerically less than 10. Remember, this is the whole point of PORTEPOCH in the first place.
Two optional variables, PKGNAMEPREFIX and PKGNAMESUFFIX, are combined with PORTNAME and PORTVERSION to form PKGNAME as ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}. Make sure this conforms to our guidelines for a good package name. In particular, you are not allowed to use a hyphen (-) in PORTVERSION. Also, if the package name has the language- or the -compiled.specifics part (see below), use PKGNAMEPREFIX and PKGNAMESUFFIX, respectively. Do not make them part of PORTNAME.
In some cases, several versions of a program may be present in the ports collection at the same time. Both the index build and the package build system need to be able to see them as different, independent ports, although they may all have the same PORTNAME, PKGNAMEPREFIX, and even PKGNAMESUFFIX. In those cases, the optional LATEST_LINK variable should be set to a different value for all ports except the ``main'' one -- see the editors/vim5 and editors/vim ports, and the www/apache* family for examples of its use. Note that how to choose a ``main'' version -- ``most popular'', ``best supported'', ``least patched'', and so on -- is outside the scope of this handbook's recommendations; we only tell you how to specify the other ports' versions after you have picked a ``main'' one.
The following are the conventions you should follow in naming your packages. This is to have our package directory easy to scan, as there are already thousands of packages and users are going to turn away if they hurt their eyes!
The package name should look like [language[_region]]-name[[-]compiled.specifics]-version.numbers.
The package name is defined as ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}. Make sure to set the variables to conform to that format.
FreeBSD strives to support the native language of its users. The language- part should be a two letter abbreviation of the natural language defined by ISO-639 if the port is specific to a certain language. Examples are ja for Japanese, ru for Russian, vi for Vietnamese, zh for Chinese, ko for Korean and de for German.
If the port is specific to a certain region within the language area, add the two letter country code as well. Examples are en_US for US English and fr_CH for Swiss French.
The language- part should be set in the PKGNAMEPREFIX variable.
The first letter of the name part should be lowercase. (The rest of the name may contain capital letters, so use your own discretion when you are converting a software name that has some capital letters in it.) There is a tradition of naming Perl 5 modules by prepending p5- and converting the double-colon separator to a hyphen; for example, the Data::Dumper module becomes p5-Data-Dumper.
Make sure that the port's name and version are clearly separated and placed into the PORTNAME and PORTVERSION variables. The only reason for PORTNAME to contain a version part is if the upstream distribution is really named that way, as in the textproc/libxml2 or japanese/kinput2-freewnn ports. Otherwise, the PORTNAME should not contain any version-specific information. It is quite normal for several ports to have the same PORTNAME, as the www/apache* ports do; in that case, different versions (and different index entries) are distinguished by the PKGNAMEPREFIX, PKGNAMESUFFIX, and LATEST_LINK values.
If the port can be built with different hardcoded defaults (usually part of the directory name in a family of ports), the -compiled.specifics part should state the compiled-in defaults (the hyphen is optional). Examples are papersize and font units.
The -compiled.specifics part should be set in the PKGNAMESUFFIX variable.
The version string should follow a dash (-) and be a period-separated list of integers and single lowercase alphabetics. In particular, it is not permissible to have another dash inside the version string. The only exception is the string pl (meaning ``patchlevel''), which can be used only when there are no major and minor version numbers in the software. If the software version has strings like ``alpha'', ``beta'', ``rc'', or ``pre'', take the first letter and put it immediately after a period. If the version string continues after those names, the numbers should follow the single alphabet without an extra period between them.
The idea is to make it easier to sort ports by looking at the version string. In particular, make sure version number components are always delimited by a period, and if the date is part of the string, use the yyyy.mm.dd format, not dd.mm.yyyy or the non-Y2K compliant yy.mm.dd format.
Here are some (real) examples on how to convert the name as called by the software authors to a suitable package name:
| Distribution Name | PKGNAMEPREFIX | PORTNAME | PKGNAMESUFFIX | PORTVERSION | Reason |
|---|---|---|---|---|---|
| mule-2.2.2 | (empty) | mule | (empty) | 2.2.2 | No changes required |
| EmiClock-1.0.2 | (empty) | emiclock | (empty) | 1.0.2 | No uppercase names for single programs |
| rdist-1.3alpha | (empty) | rdist | (empty) | 1.3.a | No strings like alpha allowed |
| es-0.9-beta1 | (empty) | es | (empty) | 0.9.b1 | No strings like beta allowed |
| mailman-2.0rc3 | (empty) | mailman | (empty) | 2.0.r3 | No strings like rc allowed |
| v3.3beta021.src | (empty) | tiff | (empty) | 3.3 | What the heck was that anyway? |
| tvtwm | (empty) | tvtwm | (empty) | pl11 | Version string always required |
| piewm | (empty) | piewm | (empty) | 1.0 | Version string always required |
| xvgr-2.10pl1 | (empty) | xvgr | (empty) | 2.10.1 | pl allowed only when no major/minor version numbers |
| gawk-2.15.6 | ja- | gawk | (empty) | 2.15.6 | Japanese language version |
| psutils-1.13 | (empty) | psutils | -letter | 1.13 | Papersize hardcoded at package build time |
| pkfonts | (empty) | pkfonts | 300 | 1.0 | Package for 300dpi fonts |
If there is absolutely no trace of version information in the original source and it is unlikely that the original author will ever release another version, just set the version string to 1.0 (like the piewm example above). Otherwise, ask the original author or use the date string (yyyy.mm.dd) as the version.
When a package is created, it is put under /usr/ports/packages/All and links are made from one or more subdirectories of /usr/ports/packages. The names of these subdirectories are specified by the variable CATEGORIES. It is intended to make life easier for the user when he is wading through the pile of packages on the FTP site or the CDROM. Please take a look at the current list of categories and pick the ones that are suitable for your port.
This list also determines where in the ports tree the port is imported. If you put more than one category here, it is assumed that the port files will be put in the subdirectory with the name in the first category. See below for more discussion about how to pick the right categories.
Here is the current list of port categories. Those marked with an asterisk (*) are virtual categories--those that do not have a corresponding subdirectory in the ports tree. They are only used as secondary categories, and only for search purposes.
Note: For non-virtual categories, you will find a one-line description in the COMMENT in that subdirectory's Makefile.
| Category | Description | Notes |
|---|---|---|
| accessibility | Ports to help disabled users. | |
| afterstep* | Ports to support the AfterStep window manager. | |
| arabic | Arabic language support. | |
| archivers | Archiving tools. | |
| astro | Astronomical ports. | |
| audio | Sound support. | |
| benchmarks | Benchmarking utilities. | |
| biology | Biology-related software. | |
| cad | Computer aided design tools. | |
| chinese | Chinese language support. | |
| comms | Communication software. | Mostly software to talk to your serial port. |
| converters | Character code converters. | |
| databases | Databases. | |
| deskutils | Things that used to be on the desktop before computers were invented. | |
| devel | Development utilities. | Do not put libraries here just because they are libraries--unless they truly do not belong anywhere else, they should not be in this category. |
| dns | DNS-related software. | |
| editors | General editors. | Specialized editors go in the section for those tools (e.g., a mathematical-formula editor will go in math). |
| elisp* | Emacs-lisp ports. | |
| emulators | Emulators for other operating systems. | Terminal emulators do not belong here--X-based ones should go to x11 and text-based ones to either comms or misc, depending on the exact functionality. |
| finance | Monetary, financial and related applications. | |
| french | French language support. | |
| ftp | FTP client and server utilities. | If your port speaks both FTP and HTTP, put it in ftp with a secondary category of www. |
| games | Games. | |
| geography* | Geography-related software. | |
| german | German language support. | |
| gnome* | Ports from the GNOME Project. | |
| gnustep* | Software related to the GNUstep desktop environment. | |
| graphics | Graphics utilities. | |
| hamradio* | Software for amateur radio. | |
| haskell* | Software related to the Haskell language. | |
| hebrew | Hebrew language support. | |
| hungarian | Hungarian language support. | |
| ipv6* | IPv6 related software. | |
| irc | Internet Relay Chat utilities. | |
| japanese | Japanese language support. | |
| java | Software related to the Java language. | The java category shall not be the only one for a port. Save for ports directly related to the Java language, porters are also encouraged not to use java as the main category of a port. |
| kde* | Ports from the K Desktop Environment (KDE) Project. | |
| kld* | Kernel loadable modules. | |
| korean | Korean language support. | |
| lang | Programming languages. | |
| linux* | Linux applications and support utilities. | |
| lisp* | Software related to the Lisp language. | |
| Mail software. | ||
| math | Numerical computation software and other utilities for mathematics. | |
| mbone | MBone applications. | |
| misc | Miscellaneous utilities | Basically things that do not belong anywhere else. If at all possible, try to find a better category for your port than misc, as ports tend to get overlooked in here. |
| multimedia | Multimedia software. | |
| net | Miscellaneous networking software. | |
| net-im | Instant messaging software. | |
| net-mgmt | Networking management software. | |
| net-p2p | Peer to peer network applications. | |
| news | USENET news software. | |
| palm | Software support for the Palm™ series. | |
| parallel* | Applications dealing with parallelism in computing. | |
| pear* | Ports related to the Pear PHP framework. | |
| perl5* | Ports that require Perl version 5 to run. | |
| plan9* | Various programs from Plan9. | |
| polish | Polish language support. | |
| ports-mgmt | Ports for managing, installing and developing FreeBSD ports and packages. | |
| portuguese | Portuguese language support. | |
| Printing software. | Desktop publishing tools (previewers, etc.) belong here too. | |
| python* | Software related to the Python language. | |
| ruby* | Software related to the Ruby language. | |
| rubygems* | Ports of RubyGems packages. | |
| russian | Russian language support. | |
| scheme* | Software related to the Scheme language. | |
| science | Scientific ports that do not fit into other categories such as astro, biology and math. | |
| security | Security utilities. | |
| shells | Command line shells. | |
| spanish* | Spanish language support. | |
| sysutils | System utilities. | |
| tcl* | Ports that use Tcl to run. | |
| textproc | Text processing utilities. | It does not include desktop publishing tools, which go to print. |
| tk* | Ports that use Tk to run. | |
| ukrainian | Ukrainian language support. | |
| vietnamese | Vietnamese language support. | |
| windowmaker* | Ports to support the WindowMaker window manager. | |
| www | Software related to the World Wide Web. | HTML language support belongs here too. |
| x11 | The X Window System and friends. | This category is only for software that directly supports the window system. Do not put regular X applications here; most of them should go into other x11-* categories (see below). If your port is an X application, define USE_XLIB (implied by USE_IMAKE) and put it in the appropriate category. |
| x11-clocks | X11 clocks. | |
| x11-drivers | X11 drivers. | |
| x11-fm | X11 file managers. | |
| x11-fonts | X11 fonts and font utilities. | |
| x11-servers | X11 servers. | |
| x11-themes | X11 themes. | |
| x11-toolkits | X11 toolkits. | |
| x11-wm | X11 window managers. | |
| xfce* | Ports related to the Xfce desktop environment. | |
| zope* | Zope support. |
As many of the categories overlap, you often have to choose which of the categories should be the primary category of your port. There are several rules that govern this issue. Here is the list of priorities, in decreasing order of precedence:
The first category must be a physical category (see above). This is necessary to make the packaging work. Virtual categories and physical categories may be intermixed after that.
Language specific categories always come first. For example, if your port installs Japanese X11 fonts, then your CATEGORIES line would read japanese x11-fonts.
Specific categories are listed before less-specific ones. For instance, an HTML editor should be listed as www editors, not the other way around. Also, you should not list net when the port belongs to any of irc, mail, mbone, news, security, or www, as net is included implicitly.
x11 is used as a secondary category only when the primary category is a natural language. In particular, you should not put x11 in the category line for X applications.
Emacs modes should be placed in the same ports category as the application supported by the mode, not in editors. For example, an Emacs mode to edit source files of some programming language should go into lang.
Ports which install loadable kernel modules should have the virtual category kld in their CATEGORIES line.
misc should not appear with any other non-virtual category. If you have misc with something else in your CATEGORIES line, that means you can safely delete misc and just put the port in that other subdirectory!
If your port truly does not belong anywhere else, put it in misc.
If you are not sure about the category, please put a comment to that effect in your send-pr(1) submission so we can discuss it before we import it. If you are a committer, send a note to the FreeBSD ports mailing list so we can discuss it first. Too often, new ports are imported to the wrong category only to be moved right away. This causes unnecessary and undesirable bloat in the master source repository.
As the Ports Collection has grown over time, various new categories have been introduced. New categories can either be virtual categories--those that do not have a corresponding subdirectory in the ports tree-- or physical categories--those that do. The following text discusses the issues involved in creating a new physical category so that you can understand them before you propose one.
Our existing practice has been to avoid creating a new physical category unless either a large number of ports would logically belong to it, or the ports that would belong to it are a logically distinct group that is of limited general interest (for instance, categories related to spoken human languages), or preferably both.
The rationale for this is that such a change creates a fair amount of work for both the committers and also for all users who track changes to the Ports Collection. In addition, proposed category changes just naturally seem to attract controversy. (Perhaps this is because there is no clear consensus on when a category is ``too big'', nor whether categories should lend themselves to browsing (and thus what number of categories would be an ideal number), and so forth.)
Here is the procedure:
Propose the new category on FreeBSD ports mailing list. You should include a detailed rationale for the new category, including why you feel the existing categories are not sufficient, and the list of existing ports proposed to move. (If there are new ports pending in GNATS that would fit this category, list them too.) If you are the maintainer and/or submitter, respectively, mention that as it may help you to make your case.
Participate in the discussion.
If it seems that there is support for your idea, file a PR which includes both the rationale and the list of existing ports that need to be moved. Ideally, this PR should also include patches for the following:
Makefiles for the new ports once they are repocopied
Makefile for the new category
Makefile for the old ports' categories
Makefiles for ports that depend on the old ports
(for extra credit, you can include the other files that have to change, as per the procedure in the Committer's Guide.)
Since it affects the ports infrastructure and involves not only performing repo-copies
but also possibly running regression tests on the build cluster, the PR should be
assigned to the Ports Management Team <portmgr@FreeBSD.org>.
If that PR is approved, a committer will need to follow the rest of the procedure that is outlined in the Committer's Guide.
Proposing a new virtual category should be similar to the above but much less involved, since no ports will actually have to move. In this case, the only patches to include in the PR would be those to add the new category to the CATEGORIES of the affected ports.
Occasionally someone proposes reorganizing the categories with either a 2-level structure, or some other kind of keyword structure. To date, nothing has come of any of these proposals because, while they are very easy to make, the effort involved to retrofit the entire existing ports collection with any kind of reorganization is daunting to say the very least. Please read the history of these proposals in the mailing list archives before you post this idea; furthermore, you should be prepared to be challenged to offer a working prototype.
The second part of the Makefile describes the files that must be downloaded in order to build the port, and where they can be downloaded from.
DISTNAME is the name of the port as called by the authors of the software. DISTNAME defaults to ${PORTNAME}-${PORTVERSION}, so override it only if necessary. DISTNAME is only used in two places. First, the distribution file list (DISTFILES) defaults to ${DISTNAME}${EXTRACT_SUFX}. Second, the distribution file is expected to extract into a subdirectory named WRKSRC, which defaults to work/${DISTNAME}.
Some vendor's distribution names which do not fit into the ${PORTNAME}-${PORTVERSION}-scheme can be handled automatically by setting DISTVERSION. PORTVERSION and DISTNAME will be derived automatically, but can of course be overridden. The following table lists some examples:
Note: PKGNAMEPREFIX and PKGNAMESUFFIX do not affect DISTNAME. Also note that if WRKSRC is equal to work/${PORTNAME}-${PORTVERSION} while the original source archive is named something other than ${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}, you should probably leave DISTNAME alone-- you are better off defining DISTFILES than having to set both DISTNAME and WRKSRC (and possibly EXTRACT_SUFX).
Record the directory part of the FTP/HTTP-URL pointing at the original tarball in MASTER_SITES. Do not forget the trailing slash (/)!
The make macros will try to use this specification for grabbing the distribution file with FETCH if they cannot find it already on the system.
It is recommended that you put multiple sites on this list, preferably from different continents. This will safeguard against wide-area network problems. We are even planning to add support for automatically determining the closest master site and fetching from there; having multiple sites will go a long way towards helping this effort.
If the original tarball is part of one of the popular archives such as X-contrib, GNU, or Perl CPAN, you may be able refer to those sites in an easy compact form using MASTER_SITE_* (e.g., MASTER_SITE_XCONTRIB, MASTER_SITE_GNU and MASTER_SITE_PERL_CPAN). Simply set MASTER_SITES to one of these variables and MASTER_SITE_SUBDIR to the path within the archive. Here is an example:
MASTER_SITES= ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applications
These variables are defined in /usr/ports/Mk/bsd.sites.mk. There are new entries added all the time, so make sure to check the latest version of this file before submitting a port.
The user can also set the MASTER_SITE_* variables in /etc/make.conf to override our choices, and use their favorite mirrors of these popular archives instead.
If you have one distribution file, and it uses an odd suffix to indicate the compression mechanism, set EXTRACT_SUFX.
For example, if the distribution file was named foo.tgz instead of the more normal foo.tar.gz, you would write:
DISTNAME= foo EXTRACT_SUFX= .tgz
The USE_BZIP2 and USE_ZIP variables automatically set EXTRACT_SUFX to .tar.bz2 or .zip as necessary. If neither of these are set then EXTRACT_SUFX defaults to .tar.gz.
Note: You never need to set both EXTRACT_SUFX and DISTFILES.
Sometimes the names of the files to be downloaded have no resemblance to the name of the port. For example, it might be called source.tar.gz or similar. In other cases the application's source code might be in several different archives, all of which must be downloaded.
If this is the case, set DISTFILES to be a space separated list of all the files that must be downloaded.
DISTFILES= source1.tar.gz source2.tar.gz
If not explicitly set, DISTFILES defaults to ${DISTNAME}${EXTRACT_SUFX}.
If only some of the DISTFILES must be extracted--for example, one of them is the source code, while another is an uncompressed document--list the filenames that must be extracted in EXTRACT_ONLY.
DISTFILES= source.tar.gz manual.html EXTRACT_ONLY= source.tar.gz
If none of the DISTFILES should be uncompressed then set EXTRACT_ONLY to the empty string.
EXTRACT_ONLY=
If your port requires some additional patches that are available by FTP or HTTP, set PATCHFILES to the names of the files and PATCH_SITES to the URL of the directory that contains them (the format is the same as MASTER_SITES).
If the patch is not relative to the top of the source tree (i.e., WRKSRC) because it contains some extra pathnames, set PATCH_DIST_STRIP accordingly. For instance, if all the pathnames in the patch have an extra foozolix-1.0/ in front of the filenames, then set PATCH_DIST_STRIP=-p1.
Do not worry if the patches are compressed; they will be decompressed automatically if the filenames end with .gz or .Z.
If the patch is distributed with some other files, such as documentation, in a gzip'd tarball, you cannot just use PATCHFILES. If that is the case, add the name and the location of the patch tarball to DISTFILES and MASTER_SITES. Then, use the EXTRA_PATCHES variable to point to those files and bsd.port.mk will automatically apply them for you. In particular, do not copy patch files into the PATCHDIR directory--that directory may not be writable.
Note: The tarball will have been extracted alongside the regular source by then, so there is no need to explicitly extract it if it is a regular gzip'd or compress'd tarball. If you do the latter, take extra care not to overwrite something that already exists in that directory. Also, do not forget to add a command to remove the copied patch in the pre-clean target.
(Consider this to be a somewhat ``advanced topic''; those new to this document may wish to skip this section at first).
This section has information on the fetching mechanism known as both MASTER_SITES:n and MASTER_SITES_NN. We will refer to this mechanism as MASTER_SITES:n hereon.
A little background first. OpenBSD has a neat feature inside both DISTFILES and PATCHFILES variables, both files and patches can be postfixed with :n identifiers where n both can be [0-9] and denote a group designation. For example:
DISTFILES= alpha:0 beta:1
In OpenBSD, distribution file alpha will be associated with variable MASTER_SITES0 instead of our common MASTER_SITES and beta with MASTER_SITES1.
This is a very interesting feature which can decrease that endless search for the correct download site.
Just picture 2 files in DISTFILES and 20 sites in MASTER_SITES, the sites slow as hell where beta is carried by all sites in MASTER_SITES, and alpha can only be found in the 20th site. It would be such a waste to check all of them if maintainer knew this beforehand, would it not? Not a good start for that lovely weekend!
Now that you have the idea, just imagine more DISTFILES and more MASTER_SITES. Surely our ``distfiles survey meister'' would appreciate the relief to network strain that this would bring.
In the next sections, information will follow on the FreeBSD implementation of this idea. We improved a bit on OpenBSD's concept.
This section tells you how to quickly prepare fine grained fetching of multiple distribution files and patches from different sites and subdirectories. We describe here a case of simplified MASTER_SITES:n usage. This will be sufficient for most scenarios. However, if you need further information, you will have to refer to the next section.
Some applications consist of multiple distribution files that must be downloaded from a number of different sites. For example, Ghostscript consists of the core of the program, and then a large number of driver files that are used depending on the user's printer. Some of these driver files are supplied with the core, but many others must be downloaded from a variety of different sites.
To support this, each entry in DISTFILES may be followed by a colon and a ``tag name''. Each site listed in MASTER_SITES is then followed by a colon, and the tag that indicates which distribution files should be downloaded from this site.
For example, consider an application with the source split in two parts, source1.tar.gz and source2.tar.gz, which must be downloaded from two different sites. The port's Makefile would include lines like Example 5-1.
Example 5-1. Simplified use of MASTER_SITES:n with 1 file per site
MASTER_SITES= ftp://ftp.example1.com/:source1 \
ftp://ftp.example2.com/:source2
DISTFILES= source1.tar.gz:source1 \
source2.tar.gz:source2
Multiple distribution files can have the same tag. Continuing the previous example, suppose that there was a third distfile, source3.tar.gz, that should be downloaded from ftp.example2.com. The Makefile would then be written like Example 5-2.
Okay, so the previous section example did not reflect your needs? In this section we will explain in detail how the fine grained fetching mechanism MASTER_SITES:n works and how you can modify your ports to use it.
Elements can be postfixed with :n where n is [^:,]+, i.e., n could conceptually be any alphanumeric string but we will limit it to [a-zA-Z_][0-9a-zA-Z_]+ for now.
Moreover, string matching is case sensitive; i.e., n is different from N.
However, the following words cannot be used for postfixing purposes since they yield special meaning: default, all and ALL (they are used internally in item ii). Furthermore, DEFAULT is a special purpose word (check item 3).
Elements postfixed with :n belong to the group n, :m belong to group m and so forth.
Elements without a postfix are groupless, i.e., they all belong to the special group DEFAULT. If you postfix any elements with DEFAULT, you are just being redundant unless you want to have an element belonging to both DEFAULT and other groups at the same time (check item 5).
The following examples are equivalent but the first one is preferred:
MASTER_SITES= alpha MASTER_SITES= alpha:DEFAULT
Groups are not exclusive, an element may belong to several different groups at the same time and a group can either have either several different elements or none at all. Repeated elements within the same group will be simply that, repeated elements.
When you want an element to belong to several groups at the same time, you can use the comma operator (,).
Instead of repeating it several times, each time with a different postfix, we can list several groups at once in a single postfix. For instance, :m,n,o marks an element that belongs to group m, n and o.
All the following examples are equivalent but the last one is preferred:
MASTER_SITES= alpha alpha:SOME_SITE MASTER_SITES= alpha:DEFAULT alpha:SOME_SITE MASTER_SITES= alpha:SOME_SITE,DEFAULT MASTER_SITES= alpha:DEFAULT,SOME_SITE
All sites within a given group are sorted according to MASTER_SORT_AWK. All groups within MASTER_SITES and PATCH_SITES are sorted as well.
Group semantics can be used in any of the following variables MASTER_SITES, PATCH_SITES, MASTER_SITE_SUBDIR, PATCH_SITE_SUBDIR, DISTFILES, and PATCHFILES according to the following syntax:
All MASTER_SITES, PATCH_SITES, MASTER_SITE_SUBDIR and PATCH_SITE_SUBDIR elements must be terminated with the forward slash / character. If any elements belong to any groups, the group postfix :n must come right after the terminator /. The MASTER_SITES:n mechanism relies on the existence of the terminator / to avoid confusing elements where a :n is a valid part of the element with occurrences where :n denotes group n. For compatibility purposes, since the / terminator was not required before in both MASTER_SITE_SUBDIR and PATCH_SITE_SUBDIR elements, if the postfix immediate preceding character is not a / then :n will be considered a valid part of the element instead of a group postfix even if an element is postfixed with :n. See both Example 5-3 and Example 5-4.
Example 5-3. Detailed use of MASTER_SITES:n in MASTER_SITE_SUBDIR
MASTER_SITE_SUBDIR= old:n new/:NEW
Directories within group DEFAULT -> old:n
Directories within group NEW -> new
Example 5-4. Detailed use of MASTER_SITES:n with comma operator, multiple files, multiple sites and multiple subdirectories
MASTER_SITES= http://site1/%SUBDIR%/ http://site2/:DEFAULT \
http://site3/:group3 http://site4/:group4 \
http://site5/:group5 http://site6/:group6 \
http://site7/:DEFAULT,group6 \
http://site8/%SUBDIR%/:group6,group7 \
http://site9/:group8
DISTFILES= file1 file2:DEFAULT file3:group3 \
file4:group4,group5,group6 file5:grouping \
file6:group7
MASTER_SITE_SUBDIR= directory-trial:1 directory-n/:groupn \
directory-one/:group6,DEFAULT \
directory
The previous example results in the following fine grained fetching. Sites are listed in the exact order they will be used.
file1 will be fetched from
MASTER_SITE_OVERRIDE
http://site1/directory-trial:1/
http://site1/directory-one/
http://site1/directory/
http://site2/
http://site7/
MASTER_SITE_BACKUP
file2 will be fetched exactly as file1 since they both belong to the same group
MASTER_SITE_OVERRIDE
http://site1/directory-trial:1/
http://site1/directory-one/
http://site1/directory/
http://site2/
http://site7/
MASTER_SITE_BACKUP
file3 will be fetched from
MASTER_SITE_OVERRIDE
http://site3/
MASTER_SITE_BACKUP
file4 will be fetched from
MASTER_SITE_OVERRIDE
http://site4/
http://site5/
http://site6/
http://site7/
http://site8/directory-one/
MASTER_SITE_BACKUP
file5 will be fetched from
MASTER_SITE_OVERRIDE
MASTER_SITE_BACKUP
file6 will be fetched from
MASTER_SITE_OVERRIDE
http://site8/
MASTER_SITE_BACKUP
How do I group one of the special variables from bsd.sites.mk, e.g., MASTER_SITE_SOURCEFORGE?
See Example 5-5.
Example 5-5. Detailed use of MASTER_SITES:n with MASTER_SITE_SOURCEFORGE
MASTER_SITES= http://site1/ ${MASTER_SITE_SOURCEFORGE:S/$/:sourceforge,TEST/}
DISTFILES= something.tar.gz:sourceforge
something.tar.gz will be fetched from all sites within MASTER_SITE_SOURCEFORGE.
How do I use this with PATCH* variables?
All examples were done with MASTER* variables but they work exactly the same for PATCH* ones as can be seen in Example 5-6.
All current ports remain the same. The MASTER_SITES:n feature code is only activated if there are elements postfixed with :n like elements according to the aforementioned syntax rules, especially as shown in item 7.
The port targets remain the same: checksum, makesum, patch, configure, build, etc. With the obvious exceptions of do-fetch, fetch-list, master-sites and patch-sites.
do-fetch: deploys the new grouping postfixed DISTFILES and PATCHFILES with their matching group elements within both MASTER_SITES and PATCH_SITES which use matching group elements within both MASTER_SITE_SUBDIR and PATCH_SITE_SUBDIR. Check Example 5-4.
fetch-list: works like old fetch-list with the exception that it groups just like do-fetch.
master-sites and patch-sites: (incompatible with older versions) only return the elements of group DEFAULT; in fact, they execute targets master-sites-default and patch-sites-default respectively.
Furthermore, using target either master-sites-all or patch-sites-all is preferred to directly checking either MASTER_SITES or PATCH_SITES. Also, directly checking is not guaran