Skip to content
Permalink
Browse files

Update of the script (as it is on my opendarwin ~).

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@14472 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
pguyot committed Oct 8, 2005
1 parent 83155c3 commit 57b707dd7acf122fb2e7b2d320228ba6b4fac1c4
Showing with 43 additions and 35 deletions.
  1. +43 −35 src/portmgr/IndexRegen.sh
@@ -1,6 +1,5 @@
#!/bin/bash


####
# PortIndex regen automation script.
# Created by Juan Manuel Palacios,
@@ -9,7 +8,6 @@
# Date: 2005/10/4
####


# Configuration
# ROOT directory, where everything is. This must exist.
ROOT=/Users/paul/darwinports-portindex
@@ -18,11 +16,11 @@ SSH_KEY=${ROOT}/id_dsa
# DP user.
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).
# CVS root.
@@ -63,66 +61,76 @@ 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)
|| { 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)
|| { 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} && \
./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)
|| { 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)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

# (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

# 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)
# 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.
# (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 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

0 comments on commit 57b707d

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