Changeset 14470


Ignore:
Timestamp:
Oct 8, 2005, 5:14:19 AM (15 years ago)
Author:
jmpp
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/portmgr/IndexRegen.sh

    r14469 r14470  
    66# Created by Juan Manuel Palacios,
    77# e-mail: jmpp@opendarwin.org
    8 # Date: 2005/10/2
     8# Updated by Paul Guyot, <pguyot@kallisys.net>
     9# Date: 2005/10/4
    910####
    1011
    1112
    12 PREFIX=/opt/local
    13 PATH=/bin:/usr/bin:${PREFIX}/bin
    14 DPORTS=${PREFIX}/var/db/dports/sources/rsync.rsync.opendarwin.org_dpupdate_dports
    15 SU_OUT=/tmp/dpselfupdate.out
    16 I_OUT=/tmp/portindex.out
    17 FAILURES=/tmp/dp_index_failures.out
    18 LOG=/tmp/regen.out
     13# Configuration
     14# ROOT directory, where everything is. This must exist.
     15ROOT=/Users/paul/darwinports-portindex
     16# SSH key. This must exist.
     17SSH_KEY=${ROOT}/id_dsa
     18# DP user.
     19DP_USER=paul
     20# DP group.
     21DP_GROUP=paul
     22# CVS user.
     23CVS_USER=pguyot
     24# e-mail address to spam in case of failure.
     25SPAM_LOVERS=pguyot@kallisys.net
     26
     27# Other settings (probably don't need to be changed).
     28# CVS root.
     29CVS_ROOT=:ext:${CVS_USER}@cvs.opendarwin.org:/Volumes/src/cvs/od
     30#CVS_ROOT=/Volumes/src/cvs/od # <-- direct access on the same box.
     31# CVS module.
     32CVS_MODULE=darwinports
     33# Wrapper. This gets created.
     34SSH_WRAPPER=${ROOT}/ssh_wrapper
     35# Where to checkout the source code. This gets created.
     36TREE=${ROOT}/source
     37# Where DP will install its world. This gets created.
     38PREFIX=${ROOT}/opt/local
     39# Where DP installs darwinports1.0. This gets created.
     40TCLPKG=${PREFIX}/lib/tcl
     41# Path.
     42PATH=${PREFIX}/bin:/bin:/usr/bin
     43# Log for the e-mail in case of failure.
     44FAILURE_LOG=${ROOT}/failure.log
     45# Something went wrong.
     46FAILED=0
     47# Output of portindex.
     48PORTINDEX_LOG=${ROOT}/portindex.log
     49# Commit message.
     50COMMIT_MSG=${ROOT}/commit.msg
     51# The date.
    1952DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
    20 MAILTO=portmgr@opendarwin.org
    21 RSYNC=/Volumes/bigsrc/darwinports/portindex/
    2253
    23 
    24 cd ${DPORTS}
    25 #port -d selfupdate > ${SU_OUT} 2>&1
    26 port -d sync > ${SU_OUT} 2>&1
    27 if [ $? == 0 ]; then {
    28     rm -f PortIndex && portindex | tee ${I_OUT} | grep -A2 Failed > ${FAILURES}
    29     { cat ${FAILURES}; tail -n 5 ${I_OUT}; } > ${LOG}
    30     cp -f PortIndex ${RSYNC}
    31     cvs ci -F ${LOG} PortIndex
    32     cat ${LOG} | mail -s "Indexing Run on ${DATE}" ${MAILTO}
    33 }
    34 else
    35     cat ${SU_OUT} | mail -s "Indexing Failure on ${DATE}" ${MAILTO}
     54# Create the SSH wrapper if it doesn't exist (comment this for -d /Volumes...)
     55if [ ! -e $SSH_KEY ]; then
     56        echo "Key doesn't exist. The script is configured to find the SSH key at:"
     57        echo "${SSH_KEY}"
     58        exit 1
    3659fi
    3760
    38 rm -f ${SU_OUT} ${IO_UT} ${FAILURES} ${LOG}
     61# Create the SSH wrapper if it doesn't exist  (comment this for -d /Volumes...)
     62if [ ! -x $SSH_WRAPPER ]; then
     63        echo "#!/bin/bash" > $SSH_WRAPPER && \
     64        echo "/usr/bin/ssh -i ${SSH_KEY} \$*" >> $SSH_WRAPPER 1 && \
     65        chmod +x $SSH_WRAPPER \
     66                || (echo "Creation of wrapper failed" ; exit 1)
     67fi
    3968
    40 exit 0
     69# checkout if required, update otherwise.
     70if [ ! -d ${TREE} ]; then
     71        mkdir -p ${TREE} && \
     72        cd ${TREE} && \
     73        CVS_RSH=${SSH_WRAPPER} cvs -q -d $CVS_ROOT co darwinports > $FAILURE_LOG 2>&1 \
     74                || (echo "CVS checkout failed" >> $FAILURE_LOG ; FAILED=1)
     75else
     76        cd ${TREE}/${CVS_MODULE} && \
     77        CVS_RSH=${SSH_WRAPPER} cvs -q update -dP > $FAILURE_LOG 2>&1 \
     78                || (echo "CVS update failed" >> $FAILURE_LOG ; FAILED=1)
     79fi
    4180
     81# (re)configure.
     82if [ ${FAILED} -eq 0 ]; then
     83        cd ${TREE}/${CVS_MODULE}/base/ && \
     84        mkdir -p ${TCLPKG} && \
     85        ./configure \
     86                --prefix=${PREFIX} \
     87                --with-tcl-package=${TCLPKG} \
     88                --with-install-user=${DP_USER} \
     89                --with-install-group=${DP_GROUP} > $FAILURE_LOG 2>&1 \
     90                || (echo "./configure failed" >> $FAILURE_LOG ; FAILED=1)
     91fi
     92
     93# (re)build and (re)install
     94if [ ${FAILED} -eq 0 ]; then
     95        cd ${TREE}/${CVS_MODULE}/base/ && \
     96        (make && make install) > $FAILURE_LOG 2>&1 \
     97                || (echo "make && make install failed" >> $FAILURE_LOG ; FAILED=1)
     98fi
     99
     100# re-index
     101if [ ${FAILED} -eq 0 ]; then
     102        cd ${TREE}/${CVS_MODULE}/dports/ && \
     103        ${PREFIX}/bin/portindex | tee ${PORTINDEX_LOG} | \
     104                grep -A2 Failed > ${COMMIT_MSG} \
     105                || (cat ${PORTINDEX_LOG} > $FAILURE_LOG; \
     106                        echo "portindex failed" >> $FAILURE_LOG; FAILED=1)
     107fi
     108
     109# commit the file.
     110# (COMMIT_MSG contains the list of ports that failed (from grep -A2 Failed))
     111if [ ${FAILED} -eq 0 ]; then
     112        # Append the last 5 lines of the log.
     113        tail -n 5 ${PORTINDEX_LOG} >> ${COMMIT_MSG}
     114       
     115        # Commit the file.
     116        cd ${TREE}/${CVS_MODULE}/dports/ && \
     117        cvs commit PortIndex -F ${COMMIT_MSG} > $FAILURE_LOG 2>&1 \
     118                || (echo "cvs commit failed" >> $FAILURE_LOG ; FAILED=1)
     119fi
     120
     121# spam if something went wrong.
     122if [ ${FAILED} -eq 1 ]; then
     123#       mail -s "AutoIndex Failure on ${DATE}" ${SPAM_LOVERS} < $FAILURE_LOG
     124        cat $FAILURE_LOG
     125fi
     126
     127# trash log files
     128rm -f ${PORTINDEX_LOG} ${COMMIT_MSG} $FAILURE_LOG
Note: See TracChangeset for help on using the changeset viewer.