#!/bin/sh MP=$1 DP=$2 CMDFILE=$(mktemp /tmp/cmdfile.XXXXXXXXX) CMD_TEMPDIR=$(mktemp -d /tmp/cmddir.XXXXXXX) [ ! -d "${MP}" ] && exit 1 [ ! -d "${DP}" ] && exit 1 n=0 echo "Generating command file ${CMDFILE}" /usr/bin/find -s ${MP}/[a-z]* -type d -depth 1 -maxdepth 1 | \ while read port do cd ${port} # display counter only in a terminal, not in redirections [ -t 1 ] && printf "\r%d" ${n} n=$(( n + 1 )) echo "'/usr/bin/make -C ${port} PORTSDIR=${DP} PORT_DBDIR=/tmp describe >${CMD_TEMPDIR}/$(basename ${port}).log'" >> ${CMDFILE} done echo " done" echo -n "Running commands via xargs. " mkdir -p ${CMD_TEMPDIR} cat ${CMDFILE} | xargs -P 24 -L 1 sh -c echo "done" echo -n "Collecting INDEX information. " find ${CMD_TEMPDIR} -iname "*.log" -type f | xargs cat > /tmp/INDEX /bin/mv /tmp/INDEX ${MP}/INDEX-3 echo "done" echo -n "Cleaning up. " rm ${CMDFILE} rm -fr ${CMD_TEMPDIR} echo "done"