#!/bin/sh set errexit PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH # ports directories that are not searched for installed packages exclude='chinese|german|japanese|korean|russian|vietnamese' banner () { echo echo ============================================================== echo '>>>' $* echo ============================================================== } # do everything in a subshell that runs in the background # and mails the result to root -- see the end of the script ( echo echo '**************************************************************' echo '**************************************************************' echo echo ' UPDATE AND REBUILD THE PORTS ' echo echo '**************************************************************' echo '**************************************************************' banner started at `date` # work out the names of the installed packages sans version number # and the ports categories in which they can be found pkg_names=`pkg_info | sed -e 's| .*||` pkg_globs=`pkg_info | sed -e 's|-[0-9.]* .*||;s|.*|/usr/ports/*/&|'` pkg_dirs=`ls -d $pkg_globs | egrep -v "^/usr/ports/([A-Z]|($exclude)/)"` banner removing old packages for pkg in $pkg_names do pkg_delete -df $pkg done for dir in $pkg_dirs do banner rebuild in $dir cd $dir make install done banner cleaning up for dir in $pkg_dirs do cd $dir make clean done cd /usr/ports/distfiles rm * banner completed at `date` # see above ) 2>&1 | mail -s `hostname`" ports rebuild run output" root &