$Id: portrebuild.php 298 2009-12-30 01:53:00Z gjb $

cat portrebuild.sh

This is a script I wrote to automate reinstalling my needed ports after major system changes, such as major version upgrades (ie, 7-STABLE to 8-CURRENT).

You will need to edit to fit your needs. Don't blame me if it breaks your system.

The file is located here.
The file containing the port list is here.
#!/bin/sh

#####################################################################
## Filename: portbuilder.sh
## Author:   Glen J Barber
## Date:     1 September 2009
## Purpose:  Automatically rebuild and package ports
## $Id: portbuilder.sh 298 2009-12-30 01:53:00Z gjb $
#####################################################################

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
PORTS=`cat portlist.txt`
PORTSDIR=/usr/ports

echo "============================================="
echo "!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!"
echo " THIS SCRIPT WILL REMOVE ALL INSTALLED PORTS "
echo 
echo " IF THIS IS NOT WHAT YOU WANT TO DO, STOP NOW"
echo "!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!"
echo "============================================="
echo 
echo "Final warning: Do you want to continue? y/N  "

read input
if [ "$input" != "y" ]
then
	echo "Operation aborted by user"
	exit 1
fi

# remove everything
pkg_delete -av

# update the tree
portsnap fetch update

echo "==============================================================="
echo "Beginning removal of configurations"
echo "==============================================================="

for i in $PORTS
do
        make -C ${PORTSDIR}/${i} rmconfig-recursive
done


echo "==============================================================="
echo "Beginning configurations"
echo "==============================================================="

for i in $PORTS
do
	make -C ${PORTSDIR}/${i} config-recursive
done

echo "==============================================================="
echo "Beginning fetch sequence"
echo "==============================================================="

for i in $PORTS
do
	make -C ${PORTSDIR}/${i} fetch-recursive
done

echo "==============================================================="
echo "Beginning installations"
echo "==============================================================="

for i in $PORTS
do
	make -C ${PORTSDIR}/${i} install
done

echo "==============================================================="
echo "Beginning packaging"
echo "==============================================================="

for i in $PORTS
do
        make -C ${PORTSDIR}/${i} package-recursive
done


## don't build:
pkg_add http://freebsd.dev-urandom.com/packages/openoffice/i386/diablo-jdk-1.6.0.07.02_5.tbz
pkg_add -r vim-lite
pkg_add -r opera
pkg_add -r firefox3
pkg_add -r xpdf

exit 0