[23348] trunk/base/portmgr/IndexRegen.sh

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 29 10:34:20 PDT 2007


Revision: 23348
          http://trac.macosforge.org/projects/macports/changeset/23348
Author:   jmpp at macports.org
Date:     2007-03-29 10:34:20 -0700 (Thu, 29 Mar 2007)

Log Message:
-----------
Merging r23256 & r23347 back into trunk.

Modified Paths:
--------------
    trunk/base/portmgr/IndexRegen.sh

Modified: trunk/base/portmgr/IndexRegen.sh
===================================================================
--- trunk/base/portmgr/IndexRegen.sh	2007-03-29 17:29:50 UTC (rev 23347)
+++ trunk/base/portmgr/IndexRegen.sh	2007-03-29 17:34:20 UTC (rev 23348)
@@ -11,12 +11,12 @@
 
 # Configuration
 LOCKFILE=/tmp/.mp_svn_index_regen.lock
-# ROOT directory, where everything is. This must exist.
+# ROOT directory, where everything is. This needs to exist!
 ROOT=/Users/dluke/Projects/mp_svn_index_regen
-# DP user.
-DP_USER=dluke
-# DP group.
-DP_GROUP=staff
+# MP user.
+MP_USER=dluke
+# MP group.
+MP_GROUP=staff
 # e-mail address to spam in case of failure.
 SPAM_LOVERS=macports-mgr at lists.macosforge.org,dluke at geeklair.net
 
@@ -24,112 +24,95 @@
 SVN_DPORTS_URL=http://svn.macports.org/repository/macports/trunk/dports
 SVN_BASE_URL=http://svn.macports.org/repository/macports/trunk/base
 SVN_CONFIG_DIR=${ROOT}/svnconfig
-# Where to checkout the source code. This gets created.
-TREE=${ROOT}/source
-# Where DP will install its world. This gets created.
+# Where to checkout the source code. This needs to exist!
+SRCTREE=${ROOT}/source
+# Where MP will install its world. This gets created.
 PREFIX=${ROOT}/opt/local
-# Where DP installs darwinports1.0. This gets created.
+# Where MP installs darwinports1.0. This gets created.
 TCLPKG=${PREFIX}/lib/tcl
 # Path.
 PATH=${PREFIX}/bin:/bin:/usr/bin:/opt/local/bin
 # Log for the e-mail in case of failure.
 FAILURE_LOG=${ROOT}/failure.log
-# Something went wrong.
-FAILED=0
 # Commit message.
 COMMIT_MSG=${ROOT}/commit.msg
 # The date.
 DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
 
+
+# Function to spam people in charge if something goes wrong during indexing.
+bail () {
+    mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
+    cleanup; exit 1
+}
+
+# Cleanup fuction for runtime files.
+cleanup () {
+    rm -f $COMMIT_MSG $FAILURE_LOG
+    rm -f $LOCKFILE
+}
+
+
 if [ ! -e $LOCKFILE ]; then
-	touch $LOCKFILE
+    touch $LOCKFILE
 else
-	echo "Index Regen lockfile found, is another index regen running?"
-	exit 1
+    echo "Index Regen lockfile found, is another index regen running?"
+    exit 1
 fi
 
-# checkout if required, update otherwise.
-if [ ! -d ${TREE}/dports ]; then
-		{ echo "SVN update failed, please check out a copy of DP into ${TREE}" >> $FAILURE_LOG ; FAILED=1 ; }
+# Update both the ports tree and base sources, bail out if they don't exist beforehand.
+if [ ! -d ${SRCTREE}/dports/.svn ]; then
+    echo "No dports tree found at ${SRCTREE}. This needs to exist (with proper svn \
+        credentials at ${SVN_CONFIG_DIR}) prior to runnig this script." > $FAILURE_LOG; bail
 else
-	cd ${TREE}/dports && \
+    cd ${SRCTREE}/dports && \
 	svn -q --non-interactive --config-dir $SVN_CONFIG_DIR update > $FAILURE_LOG 2>&1 \
-		|| { echo "SVN update failed" >> $FAILURE_LOG ; FAILED=1 ; }
+	|| { echo "Updating the ports tree from $SVN_DPORTS_URL failed." >> $FAILURE_LOG ; bail ; }
 fi
-
-if [ ! -d ${TREE}/base ]; then
-        { echo "SVN update failed, please check out a copy of DP into ${TREE}" >> $FAILURE_LOG ; FAILED=1 ; }
+if [ ! -d ${SRCTREE}/base/.svn ]; then
+    echo "No base sources found at ${SRCTREE}. This needs to exist (with proper svn \
+        credentials at ${SVN_CONFIG_DIR}) prior to running this script." > $FAILURE_LOG; bail
 else
-    cd ${TREE}/base && \
-    svn -q --non-interactive --config-dir $SVN_CONFIG_DIR update > $FAILURE_LOG 2>&1 \
-        || { echo "SVN update failed" >> $FAILURE_LOG ; FAILED=1 ; }
+    cd ${SRCTREE}/base && \
+	svn -q --non-interactive --config-dir $SVN_CONFIG_DIR update > $FAILURE_LOG 2>&1 \
+       || { echo "Updating the base sources from $SVN_BASE_URL failed." >> $FAILURE_LOG ; bail ; }
 fi
 
-
 # (re)configure.
-if [ $FAILED -eq 0 ]; then
-	cd ${TREE}/base/ && \
-	mkdir -p ${TCLPKG} && \
-	./configure \
-		--prefix=${PREFIX} \
-		--with-tclpackage=${TCLPKG} \
-		--with-install-user=${DP_USER} \
-		--with-install-group=${DP_GROUP} > $FAILURE_LOG 2>&1 \
-		|| { echo "./configure failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
+cd ${SRCTREE}/base/ && \
+    mkdir -p ${TCLPKG} && \
+    ./configure \
+    --prefix=${PREFIX} \
+    --with-tclpackage=${TCLPKG} \
+    --with-install-user=${MP_USER} \
+    --with-install-group=${MP_GROUP} > $FAILURE_LOG 2>&1 \
+    || { echo "./configure script failed." >> $FAILURE_LOG ; bail ; }
 
 # clean
 # (cleaning is useful because we don't want the indexing to fail because dependencies aren't properly computed).
-if [ $FAILED -eq 0 ]; then
-	{ cd ${TREE}/base/ && \
-	make clean > $FAILURE_LOG 2>&1 ; } \
-		|| { echo "make clean failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
+{ cd ${SRCTREE}/base/ && make clean > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make clean failed." >> $FAILURE_LOG ; bail ; }
 
 # (re)build
-if [ $FAILED -eq 0 ]; then
-	{ cd ${TREE}/base/ && \
-	make > $FAILURE_LOG 2>&1 ; } \
-		|| { echo "make failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
+{ cd ${SRCTREE}/base/ && make > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make failed." >> $FAILURE_LOG ; bail ; }
 
 # (re)install
-if [ $FAILED -eq 0 ]; then
-	{ cd ${TREE}/base/ && \
-	make install > $FAILURE_LOG 2>&1 ; } \
-		|| { echo "make install failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
+{ cd ${SRCTREE}/base/ && make install > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make install failed." >> $FAILURE_LOG ; bail ; }
 
 # (re)index
-if [ $FAILED -eq 0 ]; then
-	{ cd ${TREE}/dports/ && \
-	${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
-		|| { echo "portindex failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
+{ cd ${SRCTREE}/dports/ && ${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
+    || { echo "portindex failed." >> $FAILURE_LOG ; bail ; }
 
-# 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 new index using the last 5 lines of the log for the commit message,
+tail -n 5 $FAILURE_LOG > $COMMIT_MSG
+# plus parsing failures, if any.
+echo "" >> $COMMIT_MSG
+grep Failed $FAILURE_LOG >> $COMMIT_MSG
+{ cd ${SRCTREE}/dports/ && \
+    svn --config-dir $SVN_CONFIG_DIR commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
+    || { echo "SVN commit failed." >> $FAILURE_LOG ; bail ; }
 
-# 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 $FAILURE_LOG > $COMMIT_MSG
-	
-	# Actually commit the file.
-	{ cd ${TREE}/dports/ && \
-	svn --config-dir $SVN_CONFIG_DIR commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
-		|| { echo "SVN commit failed" >> $FAILURE_LOG ; FAILED=1 ; }
-fi
-
-# spam if something went wrong.
-if [ $FAILED -ne 0 ]; then
-	mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
-else
-	# trash log files
-	rm -f $COMMIT_MSG $FAILURE_LOG
-fi
-
-rm -f $LOCKFILE
+# At this point the index was committed successfuly, so we cleanup before we exit.
+cleanup

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070329/3af40383/attachment.html


More information about the macports-changes mailing list