2009-08-30

FreeBSD - How to use Meta Ports to install group of ports

Often, after a fresh new installation of FreeBSD, we have a set of programs we want to install. The conventional method would be installing it one by one in /usr/ports. Today, we will use meta ports to install the set of applications by just one "make install clean" rather then "cd" into individual directories and do "make install clean" for every ports.

Meta ports are, as the name implies, ports file that describe about the program we are installing. The ports file describe where & what to install for this ports to work. A sample of "where" would be "where to download the source", "where to install it" and so on. As for "what", it would be "what to install to fulfill the dependencies". In this post, we will take advantage of this "what". We will define the dependencies as the list of programs we want to install so that the ports will install it.

This is an example of how to do it :
In this example, the meta ports named "listport" will install "bash", "vim", "unzip" and "rsync" :

1. Make a temporary directory for the meta ports :
mkdir ~/listport;cd ~/listport

2. Create a file call "Makefile", include the following as contents :
# list of ports
# 20090825

PORTNAME=       listport
PORTVERSION=    1.0
CATEGORIES=     misc

MASTER_SITES=
DISTFILES=

MAINTAINER=     psybermonkey

RUN_DEPENDS=bash:${PORTSDIR}/shells/bash \
RUN_DEPENDS=vim:${PORTSDIR}/editors/vim \
RUN_DEPENDS=unzip:${PORTSDIR}/archivers/unzip \
RUN_DEPENDS=rsync:${PORTSDIR}/net/rsync \

NO_WRKSUBDIR=   YES
NO_BUILD=       YES

do-install:

.include <bsd.port.mk>

3. Create a file call "pkg-descr" and put some description in it.

4. Install the meta ports :
make install clean

After the list of ports have successfully installed, remove the meta ports :

1. Remove the temporary directory :
rm -rf ~/listport

2. Un-install the meta ports :
pkg_delete listport-1.0

During the process of un-installing the meta ports, error messages similar to below might appear :
pkg_delete: couldn't open dependency file /var/db/pkg/sudo-1.6.3.7_2/+REQUIRED_BY'

Ignore the error.

Ciao !!!

4 comments:

Edmondas said...

Nice trick!

Metaportų kūrimas | FreeBSD.lt said...

[...] Plačiau [...]

Jason said...

"Makefile", line 23: .include filename must be delimited by '"' or '<'
make: fatal errors encountered -- cannot continue

monkey said...

Hi Edmondas,
Glad you like it. Thanks for submitting this post to FreeBSD News . I hope everyone over there enjoy it. :)

Hi Jason,
There was some text miss out after the ".include" parameter in the "Makefile" which i have fixed. Please try to copy the text and create the Makefile then run it again and see if it works. Do let me know if some thing breaks again. :p