Skip to content
Permalink
Browse files

Submitted by: pguyot@

Paul's proposed (untested?) additions to provide the script with a proper
environment in order to perform successful "cvs ci" 's on the freshly generated
Index, so that it exists both in CVS and rsync all the time.

NOTE: I currently don't have the time to pursue this further until completion
and I don't want anyone to think I'm holding it back. So if anyone feels up to the
challenge then please be my guest! I admit I have no idea how the scenario will finally
look like if these additions are adopted, what the script's requirements will be, what box
it will run on, under what permissions and what dp installation it will need/use.
So please test thouroughly before pushing live and replacing what currently works,
though admittedly in a limited fashion.

PS: Once the Index is again constantly refreshed in CVS through this script, developers
should still keep from committing one themselves, as this could cause potential clashes
with an Index that is known to be accurate (based on a 100% guaranteed "clean" dports/ tree).

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@14470 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
jmpalacios committed Oct 8, 2005
1 parent a79e85c commit 83155c356cf6a51d54086c52d870b45879ae825f
Showing with 112 additions and 25 deletions.
  1. +112 −25 src/portmgr/IndexRegen.sh
@@ -5,37 +5,124 @@
# PortIndex regen automation script.
# Created by Juan Manuel Palacios,
# e-mail: jmpp@opendarwin.org
# Date: 2005/10/2
# Updated by Paul Guyot, <pguyot@kallisys.net>
# Date: 2005/10/4
####


PREFIX=/opt/local
PATH=/bin:/usr/bin:${PREFIX}/bin
DPORTS=${PREFIX}/var/db/dports/sources/rsync.rsync.opendarwin.org_dpupdate_dports
SU_OUT=/tmp/dpselfupdate.out
I_OUT=/tmp/portindex.out
FAILURES=/tmp/dp_index_failures.out
LOG=/tmp/regen.out
# Configuration
# ROOT directory, where everything is. This must exist.
ROOT=/Users/paul/darwinports-portindex
# SSH key. This must exist.
SSH_KEY=${ROOT}/id_dsa
# DP user.
DP_USER=paul
# DP group.
DP_GROUP=paul
# CVS user.
CVS_USER=pguyot
# e-mail address to spam in case of failure.
SPAM_LOVERS=pguyot@kallisys.net

# Other settings (probably don't need to be changed).
# CVS root.
CVS_ROOT=:ext:${CVS_USER}@cvs.opendarwin.org:/Volumes/src/cvs/od
#CVS_ROOT=/Volumes/src/cvs/od # <-- direct access on the same box.
# CVS module.
CVS_MODULE=darwinports
# Wrapper. This gets created.
SSH_WRAPPER=${ROOT}/ssh_wrapper
# Where to checkout the source code. This gets created.
TREE=${ROOT}/source
# Where DP will install its world. This gets created.
PREFIX=${ROOT}/opt/local
# Where DP installs darwinports1.0. This gets created.
TCLPKG=${PREFIX}/lib/tcl
# Path.
PATH=${PREFIX}/bin:/bin:/usr/bin
# Log for the e-mail in case of failure.
FAILURE_LOG=${ROOT}/failure.log
# Something went wrong.
FAILED=0
# Output of portindex.
PORTINDEX_LOG=${ROOT}/portindex.log
# Commit message.
COMMIT_MSG=${ROOT}/commit.msg
# The date.
DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
MAILTO=portmgr@opendarwin.org
RSYNC=/Volumes/bigsrc/darwinports/portindex/


cd ${DPORTS}
#port -d selfupdate > ${SU_OUT} 2>&1
port -d sync > ${SU_OUT} 2>&1
if [ $? == 0 ]; then {
rm -f PortIndex && portindex | tee ${I_OUT} | grep -A2 Failed > ${FAILURES}
{ cat ${FAILURES}; tail -n 5 ${I_OUT}; } > ${LOG}
cp -f PortIndex ${RSYNC}
cvs ci -F ${LOG} PortIndex
cat ${LOG} | mail -s "Indexing Run on ${DATE}" ${MAILTO}
}

# Create the SSH wrapper if it doesn't exist (comment this for -d /Volumes...)
if [ ! -e $SSH_KEY ]; then
echo "Key doesn't exist. The script is configured to find the SSH key at:"
echo "${SSH_KEY}"
exit 1
fi

# Create the SSH wrapper if it doesn't exist (comment this for -d /Volumes...)
if [ ! -x $SSH_WRAPPER ]; then
echo "#!/bin/bash" > $SSH_WRAPPER && \
echo "/usr/bin/ssh -i ${SSH_KEY} \$*" >> $SSH_WRAPPER 1 && \
chmod +x $SSH_WRAPPER \
|| (echo "Creation of wrapper failed" ; exit 1)
fi

# checkout if required, update otherwise.
if [ ! -d ${TREE} ]; then
mkdir -p ${TREE} && \
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)
else
cat ${SU_OUT} | mail -s "Indexing Failure on ${DATE}" ${MAILTO}
cd ${TREE}/${CVS_MODULE} && \
CVS_RSH=${SSH_WRAPPER} cvs -q update -dP > $FAILURE_LOG 2>&1 \
|| (echo "CVS update failed" >> $FAILURE_LOG ; FAILED=1)
fi

# (re)configure.
if [ ${FAILED} -eq 0 ]; then
cd ${TREE}/${CVS_MODULE}/base/ && \
mkdir -p ${TCLPKG} && \
./configure \
--prefix=${PREFIX} \
--with-tcl-package=${TCLPKG} \
--with-install-user=${DP_USER} \
--with-install-group=${DP_GROUP} > $FAILURE_LOG 2>&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)
fi

rm -f ${SU_OUT} ${IO_UT} ${FAILURES} ${LOG}
# 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)
fi

exit 0
# 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}

# 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)
fi

# spam if something went wrong.
if [ ${FAILED} -eq 1 ]; then
# mail -s "AutoIndex Failure on ${DATE}" ${SPAM_LOVERS} < $FAILURE_LOG
cat $FAILURE_LOG
fi

# trash log files
rm -f ${PORTINDEX_LOG} ${COMMIT_MSG} $FAILURE_LOG

0 comments on commit 83155c3

Please sign in to comment.
You can’t perform that action at this time.