Changeset 14470 for trunk/base
- Timestamp:
- Oct 8, 2005, 5:14:19 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/portmgr/IndexRegen.sh
r14469 r14470 6 6 # Created by Juan Manuel Palacios, 7 7 # e-mail: jmpp@opendarwin.org 8 # Date: 2005/10/2 8 # Updated by Paul Guyot, <pguyot@kallisys.net> 9 # Date: 2005/10/4 9 10 #### 10 11 11 12 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. 15 ROOT=/Users/paul/darwinports-portindex 16 # SSH key. This must exist. 17 SSH_KEY=${ROOT}/id_dsa 18 # DP user. 19 DP_USER=paul 20 # DP group. 21 DP_GROUP=paul 22 # CVS user. 23 CVS_USER=pguyot 24 # e-mail address to spam in case of failure. 25 SPAM_LOVERS=pguyot@kallisys.net 26 27 # Other settings (probably don't need to be changed). 28 # CVS root. 29 CVS_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. 32 CVS_MODULE=darwinports 33 # Wrapper. This gets created. 34 SSH_WRAPPER=${ROOT}/ssh_wrapper 35 # Where to checkout the source code. This gets created. 36 TREE=${ROOT}/source 37 # Where DP will install its world. This gets created. 38 PREFIX=${ROOT}/opt/local 39 # Where DP installs darwinports1.0. This gets created. 40 TCLPKG=${PREFIX}/lib/tcl 41 # Path. 42 PATH=${PREFIX}/bin:/bin:/usr/bin 43 # Log for the e-mail in case of failure. 44 FAILURE_LOG=${ROOT}/failure.log 45 # Something went wrong. 46 FAILED=0 47 # Output of portindex. 48 PORTINDEX_LOG=${ROOT}/portindex.log 49 # Commit message. 50 COMMIT_MSG=${ROOT}/commit.msg 51 # The date. 19 52 DATE=$(date +'%A %Y-%m-%d at %H:%M:%S') 20 MAILTO=portmgr@opendarwin.org21 RSYNC=/Volumes/bigsrc/darwinports/portindex/22 53 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...) 55 if [ ! -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 36 59 fi 37 60 38 rm -f ${SU_OUT} ${IO_UT} ${FAILURES} ${LOG} 61 # Create the SSH wrapper if it doesn't exist (comment this for -d /Volumes...) 62 if [ ! -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) 67 fi 39 68 40 exit 0 69 # checkout if required, update otherwise. 70 if [ ! -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) 75 else 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) 79 fi 41 80 81 # (re)configure. 82 if [ ${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) 91 fi 92 93 # (re)build and (re)install 94 if [ ${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) 98 fi 99 100 # re-index 101 if [ ${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) 107 fi 108 109 # commit the file. 110 # (COMMIT_MSG contains the list of ports that failed (from grep -A2 Failed)) 111 if [ ${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) 119 fi 120 121 # spam if something went wrong. 122 if [ ${FAILED} -eq 1 ]; then 123 # mail -s "AutoIndex Failure on ${DATE}" ${SPAM_LOVERS} < $FAILURE_LOG 124 cat $FAILURE_LOG 125 fi 126 127 # trash log files 128 rm -f ${PORTINDEX_LOG} ${COMMIT_MSG} $FAILURE_LOG
Note: See TracChangeset
for help on using the changeset viewer.