Index: trunk/base/src/portmgr/IndexRegen.sh
===================================================================
--- trunk/base/src/portmgr/IndexRegen.sh	(revision 14470)
+++ trunk/base/src/portmgr/IndexRegen.sh	(revision 14472)
@@ -1,4 +1,3 @@
 #!/bin/bash
-
 
 ####
@@ -10,5 +9,4 @@
 ####
 
-
 # Configuration
 # ROOT directory, where everything is. This must exist.
@@ -19,9 +17,9 @@
 DP_USER=paul
 # DP group.
-DP_GROUP=paul
+DP_GROUP=admin
 # CVS user.
 CVS_USER=pguyot
 # e-mail address to spam in case of failure.
-SPAM_LOVERS=pguyot@kallisys.net
+SPAM_LOVERS=portmgr@opendarwin.org
 
 # Other settings (probably don't need to be changed).
@@ -64,5 +62,5 @@
 	echo "/usr/bin/ssh -i ${SSH_KEY} \$*" >> $SSH_WRAPPER 1 && \
 	chmod +x $SSH_WRAPPER \
-		|| (echo "Creation of wrapper failed" ; exit 1)
+		|| { echo "Creation of wrapper failed" ; exit 1 ; }
 fi
 
@@ -72,13 +70,13 @@
 	cd ${TREE} && \
 	CVS_RSH=${SSH_WRAPPER} cvs -q -d $CVS_ROOT co darwinports > $FAILURE_LOG 2>&1 \
-		|| (echo "CVS checkout failed" >> $FAILURE_LOG ; FAILED=1)
+		|| { echo "CVS checkout failed" >> $FAILURE_LOG ; FAILED=1 ; }
 else
 	cd ${TREE}/${CVS_MODULE} && \
 	CVS_RSH=${SSH_WRAPPER} cvs -q update -dP > $FAILURE_LOG 2>&1 \
-		|| (echo "CVS update failed" >> $FAILURE_LOG ; FAILED=1)
+		|| { echo "CVS update failed" >> $FAILURE_LOG ; FAILED=1 ; }
 fi
 
 # (re)configure.
-if [ ${FAILED} -eq 0 ]; then
+if [ $FAILED -eq 0 ]; then
 	cd ${TREE}/${CVS_MODULE}/base/ && \
 	mkdir -p ${TCLPKG} && \
@@ -88,41 +86,51 @@
 		--with-install-user=${DP_USER} \
 		--with-install-group=${DP_GROUP} > $FAILURE_LOG 2>&1 \
-		|| (echo "./configure failed" >> $FAILURE_LOG ; FAILED=1)
+		|| { echo "./configure failed" >> $FAILURE_LOG ; FAILED=1 ; }
 fi
 
-# (re)build and (re)install
-if [ ${FAILED} -eq 0 ]; then
-	cd ${TREE}/${CVS_MODULE}/base/ && \
-	(make && make install) > $FAILURE_LOG 2>&1 \
-		|| (echo "make && make install failed" >> $FAILURE_LOG ; FAILED=1)
+# (re)build
+if [ $FAILED -eq 0 ]; then
+	{ cd ${TREE}/${CVS_MODULE}/base/ && \
+	make > $FAILURE_LOG 2>&1 ; } \
+		|| { echo "make failed" >> $FAILURE_LOG ; FAILED=1 ; }
 fi
 
-# re-index
-if [ ${FAILED} -eq 0 ]; then
-	cd ${TREE}/${CVS_MODULE}/dports/ && \
-	${PREFIX}/bin/portindex | tee ${PORTINDEX_LOG} | \
-		grep -A2 Failed > ${COMMIT_MSG} \
-		|| (cat ${PORTINDEX_LOG} > $FAILURE_LOG; \
-			echo "portindex failed" >> $FAILURE_LOG; FAILED=1)
+# (re)install
+if [ $FAILED -eq 0 ]; then
+	{ cd ${TREE}/${CVS_MODULE}/base/ && \
+	make install > $FAILURE_LOG 2>&1 ; } \
+		|| { echo "make install failed" >> $FAILURE_LOG ; FAILED=1 ; }
 fi
 
-# commit the file.
-# (COMMIT_MSG contains the list of ports that failed (from grep -A2 Failed))
-if [ ${FAILED} -eq 0 ]; then
-	# Append the last 5 lines of the log.
-	tail -n 5 ${PORTINDEX_LOG} >> ${COMMIT_MSG}
+# (re)index
+if [ $FAILED -eq 0 ]; then
+	{ cd ${TREE}/${CVS_MODULE}/dports/ && \
+	${PREFIX}/bin/portindex | tee $PORTINDEX_LOG > $FAILURE_LOG 2>&1 ; } \
+		|| { echo "portindex failed" >> $FAILURE_LOG ; FAILED=1 ; }
+fi
+
+# check all ports were indexed.
+if [ $FAILED -eq 0 ]; then
+	grep Failed $FAILURE_LOG \
+		&& { echo "some ports couldn\'t be indexed" >> $FAILURE_LOG ; FAILED=1 ; }
+fi
+
+# commit the file if and only if all ports were successfully indexed.
+if [ $FAILED -eq 0 ]; then
+	# Use the last 5 lines of the log for the commit message.
+	tail -n 5 $PORTINDEX_LOG > $COMMIT_MSG
 	
-	# Commit the file.
-	cd ${TREE}/${CVS_MODULE}/dports/ && \
-	cvs commit PortIndex -F ${COMMIT_MSG} > $FAILURE_LOG 2>&1 \
-		|| (echo "cvs commit failed" >> $FAILURE_LOG ; FAILED=1)
+	# Actually commit the file.
+	{ cd ${TREE}/${CVS_MODULE}/dports/ && \
+	cvs commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
+		|| { echo "cvs commit failed" >> $FAILURE_LOG ; FAILED=1 ; }
 fi
 
 # spam if something went wrong.
-if [ ${FAILED} -eq 1 ]; then
-#	mail -s "AutoIndex Failure on ${DATE}" ${SPAM_LOVERS} < $FAILURE_LOG
-	cat $FAILURE_LOG
+if [ $FAILED -ne 0 ]; then
+	mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
+else
+	# trash log files
+	rm -f $PORTINDEX_LOG $COMMIT_MSG $FAILURE_LOG
 fi
 
-# trash log files
-rm -f ${PORTINDEX_LOG} ${COMMIT_MSG} $FAILURE_LOG
