#!/bin/sh # ------------------------------------------------------------------------------------------ # 這個程序檔,將 PORTS-Tree 整個更新,並且將已安裝的 Ports 軟體比對之後,若有新版,也做更新。 # ------------------------------------------------------------------------------------------ cd /usr/ports # ------------------------------------------------------------------------------------------ # 抓取更新 PORTS-Tree 的設定檔 # ------------------------------------------------------------------------------------------ fetch ftp://freebsd.csie.nctu.edu.tw/pub/CVSup/cvsupfile-ports # ------------------------------------------------------------------------------------------ # 開始更新 PORTS-Tree # ------------------------------------------------------------------------------------------ /usr/local/bin/cvsup -g -L 2 /usr/ports/cvsupfile-ports sync;sync;sync df -h | mail -s "CVSup-PORTS is done." root # ------------------------------------------------------------------------------------------ # 先檢查有沒有安裝 portupgrade 工具 # ------------------------------------------------------------------------------------------ if [ ! -f /usr/local/sbin/portupgrade ]; then cd /usr/ports/sysutils/portupgrade ; make install clean distclean fi # ------------------------------------------------------------------------------------------ # 先檢查 portupgrade 版本有無更新 # ------------------------------------------------------------------------------------------ portupgradeV=`pkg_info | grep portupgrade | awk '{print $1}' | cut -d- -f2` New_portupgradeV=`grep \DISTVERSION= /usr/ports/sysutils/portupgrade/Makefile | awk '{print $2}'` if [ $portupgradeV = $New_portupgradeV ] then echo "portupgrade 版本相同......" else clear echo "portupgrade 版本不同,先升級 portupgrade 版本......" portupgradeV=`pkg_info | grep portupgrade | awk '{print $1}'` /usr/local/sbin/portupgrade -o /usr/ports/sysutils/portupgrade $portupgradeV fi # ------------------------------------------------------------------------------------------ # 已使用PORTS安裝的軟體,再依更新後的資料做軟體升級 # ------------------------------------------------------------------------------------------ if [ -x /usr/local/sbin/portsdb ]; then /usr/local/sbin/portsdb -Uu fi if [ -x /usr/local/sbin/pkgdb ]; then /usr/local/sbin/pkgdb -F fi if [ -x /usr/local/sbin/portupgrade ]; then /usr/local/sbin/portupgrade -aWyn -l /tmp/portupgrade.log sort /tmp/portupgrade.log | mail -s "`hostname` portupgrade report" root fi