PC : 日が経つのが早いような気がします。
--- showversionindex.sh 10 Aug 2006 00:13:39 -0000 1.1 +++ showversionindex.sh 13 Aug 2006 23:17:21 -0000 1.2 @@ -1,18 +1,38 @@ -#!/bin/sh +!/bin/sh +# $Id: showversionindex.sh,v 1.2 2006/08/13 23:17:21 xxxx Exp $ export LANG="C" -export PORTSDB="/usr/local/bin/portsdb" +export PORTS_DIR="/usr/ports" +export PORTSDB="/usr/local/sbin/portsdb" export PORTSDB_FLAGS="" -export PORTVERSION="/usr/local/bin/portversion" -export PORTVERSION_FLAGS="-vL=" +export PORTVERSION="/usr/local/sbin/portversion" +export PORTVERSION_FLAGS="-L=" +export TAR_URL='http://www.freebsd.org/cgi/cvsweb.cgi/ports/%TARGET%/%FN%.tar.gz?tarball=1' -if [ -x "$PORTVERSION" ] ; then +if [ -x "$PORTSDB" -a -x "$PORTVERSION" ] ; then "$PORTSDB" ${PORTSDB_FLAGS} 2>&1 > /dev/null PORTS_NEEDS_UPDATE=`"$PORTVERSION" ${PORTVERSION_FLAGS} | awk '{ print $1 }'` - for EACH_PORTS in $PORTS_NEEDS_UPDATE - do - grep "^$EACH_PORTS" /usr/ports/INDEX \ - | sed 's/\|/ /g' \ - | awk '{ print $2 }'` - done + + if [ "x${PORTS_NEEDS_UPDATE}" != "x" ] ; then + for EACH_PORTS in $PORTS_NEEDS_UPDATE + do + TARGET=`grep "^$EACH_PORTS" "${PORTS_DIR}/INDEX" \ + | sed 's/\|/ /g' \ + | awk '{ print $2 }'` + + if [ "x${TARGET}" != "x" ] ; then + TARGET=`echo "${TARGET}" | sed 's/${PORTS_DIR}\//g'` + + for p in ${TARGET} + do + FN=`basename "${p}"` + TAR_URL=`echo "$TAR_URL" | sed "s/%TARGET%/${p}/"` + TAR_URL=`echo "$TAR_URL" | sed "s/%FN%/${FN}/"` + + fetch "$TAR_URL" 2>&1 > /dev/null \ + || echo "Can't fetch ${TARGET}" >&2 + done + fi + done + fi fi
長いので、びっくりです。 この日記で、ファイルへのリンクを作る流儀が分からないので、いつも直貼りです。