III. Package Constructor's Guide

Chapter 5. Package components - files, directories and contents

Whenever you're preparing a package from the FreeBSD/OpenBSD ports collection or doing it from scratch, there are a number of files involved which are described in the following sections. Special directions are given for what differs from FreeBSD/OpenBSD ports for each file.

5.1. Makefile

Building, installation and creation of a binary package are all controlled by the package's Makefile.

There is a Makefile for each package. This file includes the standard bsd.pkg.mk file (referenced as "../../mk/bsd.pkg.mk"), which sets all the definitions and actions necessary for the package to compile and install itself. The mandatory fields are the DISTNAME which specifies the base name of the distribution file to be downloaded from the site on the Internet, MASTER_SITES which specifies that site, CATEGORIES which denotes the categories into which the package falls, PKGNAME which is the name of the package and the MAINTAINER name.

The MASTER_SITES may be set to one of the predefined sites:

  • ${MASTER_SITE_XCONTRIB}

  • ${MASTER_SITE_GNU}

  • ${MASTER_SITE_PERL_CPAN}

  • ${MASTER_SITE_TEX_CTAN}

  • ${MASTER_SITE_SUNSITE}

If one of these predefined sites is chosen, you may require the ability to specify a subdirectory of that site. Since these macros may expand to more than one actual site, you must use the following construct to specify a subdirectory:

	${MASTER_SITE_GNU:=subdirectory/name/}
  
Note the trailing slash after the subdirectory name. Use of the deprecated MASTER_SITE_SUBDIR will not work.

Currently the following values are available for CATEGORIES. If more than one is used, they need to be separated by spaces:

archivers    corba        fonts        math         packages     sysutils    
audio        cross        games        mbone        parallel     templates    
benchmarks   databases    graphics     meta-pkgs    pkgtools     test    
biology      devel        ham          misc         plan9        textproc    
cad          distfiles    japanese     mk           print        www    
comms        editors      lang         net          security     x11    
  

See the NetBSD packages(7) manual page for a description of all available options and variables.

Please pay attention to the following gotchas, especially when preparing a package from the FreeBSD ports collection:

  • Remove all MANx and CATx definitions from the package Makefile - NetBSD has implemented automatic manual page handling, and these definitions are obsolete.

  • Add MANCOMPRESSED (if not already there) if manpages are installed in compressed form by the package; Packages that evaluate the MANZ variable on their own should set this[1]. See comment in bsd.pkg.mk.

  • Replace /usr/local by ${PREFIX} in all files (see below)

  • Delete any ``ldconfig'' commands - this will be done automatically for you if the NetBSD platform supports it, and other measures will be taken on platforms which don't. (e.g. NetBSD/Alpha).

  • If modifying a package from the FreeBSD ports collection, preserve their RCS ID: remove the '$'s around the FreeBSD RCS Id, and insert the word FreeBSD, then add a $NetBSD$, i.e.:

    before:

    	# $Id: Makefile,v 1.17 1997/06/16 06:39:51 max Exp$
         

    after:

    	# $NetBSD$
    	# FreeBSD Id: Makefile,v 1.17 1997/06/16 06:39:51 max Exp
         

  • If the package installs any info files, the main info directory file needs to be updated to reflect this fact. NetBSD now has an INFO_FILES definition, which is used to do this. For example, to install the indent.info entry into the info directory file, simply use the

    	INFO_FILES=	indent.info
         
    definition in the package Makefile. If the package does this insertion for you, you should specify USE_GTEXINFO=1 in the package Makefile, to ensure that the pre-requisite GNU texinfo package is installed on your system.

  • Adjust MAINTAINER to be either yourself. Do not leave the FreeBSD value, as it is unlikely that the FreeBSD people will care about NetBSD packages.

  • If there exists a home page for the software in question, please add the variable HOMEPAGE right after MAINTAINER. The value of this variable should be the URL for the home page.

Notes

[1]

The MANZ variable can be set in /etc/mk.conf to install compressed manpages.