Packages and Ports

Kudos to Jordan Hubbard


Adding new software in FreeBSD is very easy.  You have two options, packages or ports.  Both packages and ports understand dependenices and will install the appropreate dependenices before the specified application.  Packages are the binary form of applications and ports are the source code form of applications.  The Ports collection does not contain the source code but a collection of files which automates the download, compile, and installation of the source code for over 7000 applications.

For packages and ports check:
    /usr/ports
    /cdrom/packages
    www.freebsd.org/ports
    www.freshports.org
    ftp.freebsd.org/pub/FreeBSD/ports/packages/

Packages

Packages come in tar.gz format.  They are usually located under /packages on the cdrom or from ftp.freebsd.org/pub/FreeBSD/ports/packages/.  You can also get them using the "pkg_add -r" command explained later on this page.

Tools:
    pkg_add
    pkg_delete
    pkg_info
    pkg_version


Installing a package

Local - the package is on the local host
    # pkg_add pkgname-verson.tgz

Remote - the package is not on the local host
    # pkg_add -r pkgname

Removing a package
    # pkg_delete pkgname-version

List packages install (shows versions)
    # pkg_info

Compare version of package installed with current version available in the local ports.
    # pkg_version
            Results:
                   =    same
                   <    installed version older
                   >    installed version newer
                   ?    installed not found in ports index
                   *    multiple version


All package information is stored within the /var/db/pkg directory. The installed file list and descriptions of each package can be found within files in this directory.


Ports

Choose to install the ports collection during installation, if not you can install from /stand/sysinstall or cvsup (Handbook A.6.2)

A port skeleton is a minimal set of files that tell your FreeBSD system how to cleanly compile and install a program. Each port skeleton includes:

Makefile            - How it should be compiled & where to install
distinfo              - list of files to download and check sum
files(dir)            - patches and other support files
pkg-comment    - one line discription
pkg-descr           - multi line discription
pkg-plist            - list of files installed/ to be removed
pkg-message      - special situations


Finding the port to install

    # whereis pname

    # cd /usr/ports
    # make search name=pname

    # cd /usr/ports
    # make search key=string
        where "string" is the text to look for.
        case is insenitive

List of ports
    /usr/ports/INDEX

Installing a port

    # cd /usr/ports/collection/port
    # make install

Removing a port

    # cd /usr/ports/collection/port
    # make deinstall

    If you used "clean" then you must remove the port with pkg_delete

The downloaded tarballs are stored in /usr/ports/distfiles.  You can delete them manually or use "make distclean".  To delete the source code "make clean" from /usr/ports/collection/pkg.

List files before downloading
    # make fetch-list

Only download files
    # make fetch

Download and extract files
    # make extract

Download, extract, and patch files
    # make patch


Post installation

Read any documentation
Edit any configuration files
Does it start at boot up and all that implies.

Example:  just installed foobar

1. Get full name of pkg.
    # pkg_info |grep foobar
or
    # ls /var/db/pkg |grep foobar
or
    # pkg_info -I 'foobar*'

all return foobar-0.9.6

2.  What files did it install?  Look for man doc etc.
    # pkg_info -L foobar-0.9.6 | less

3.  Additional info
    # pkg_info foobar-0.9.6

good idea to know how the package/application works (in terms of configuration) before you install.


Next Setting up X
Index