source: trunk/base/portmgr/IndexRegen.sh @ 15338

Last change on this file since 15338 was 15338, checked in by jmpp, 15 years ago

Submitted by: jmpp@
Reviewed by: jberry@

The pormgr/ dir is now out of src/, as it doesn't have much to do with our sources.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#!/bin/bash
2
3####
4# PortIndex regen automation script.
5# Created by Juan Manuel Palacios,
6# e-mail: jmpp@opendarwin.org
7# Updated by Paul Guyot, <pguyot@kallisys.net>
8# $Id: IndexRegen.sh,v 1.1 2005/12/06 20:47:42 jmpp Exp $
9####
10
11# Configuration
12# ROOT directory, where everything is. This must exist.
13ROOT=/Users/pguyot/dp-portindex
14# SSH key. This must exist.
15SSH_KEY=${ROOT}/id_dsa
16# DP user.
17DP_USER=pguyot
18# DP group.
19DP_GROUP=darwinports
20# CVS user.
21CVS_USER=pguyot
22# e-mail address to spam in case of failure.
23SPAM_LOVERS=portmgr@opendarwin.org
24
25# Other settings (probably don't need to be changed).
26# CVS root.
27CVS_ROOT=:ext:${CVS_USER}@cvs.opendarwin.org:/Volumes/src/cvs/od
28#CVS_ROOT=/Volumes/src/cvs/od # <-- direct access on the same box.
29# CVS module.
30CVS_MODULE=darwinports
31# Wrapper. This gets created.
32SSH_WRAPPER=${ROOT}/ssh_wrapper
33# Where to checkout the source code. This gets created.
34TREE=${ROOT}/source
35# Where DP will install its world. This gets created.
36PREFIX=${ROOT}/opt/local
37# Where DP installs darwinports1.0. This gets created.
38TCLPKG=${PREFIX}/lib/tcl
39# Path.
40PATH=${PREFIX}/bin:/bin:/usr/bin
41# Log for the e-mail in case of failure.
42FAILURE_LOG=${ROOT}/failure.log
43# Something went wrong.
44FAILED=0
45# Commit message.
46COMMIT_MSG=${ROOT}/commit.msg
47# The date.
48DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
49
50# Create the SSH wrapper if it doesn't exist (comment this for -d /Volumes...)
51if [ ! -e $SSH_KEY ]; then
52        echo "Key doesn't exist. The script is configured to find the SSH key at:"
53        echo "${SSH_KEY}"
54        exit 1
55fi
56
57# Create the SSH wrapper if it doesn't exist  (comment this for -d /Volumes...)
58if [ ! -x $SSH_WRAPPER ]; then
59        echo "#!/bin/bash" > $SSH_WRAPPER && \
60        echo "/usr/bin/ssh -i ${SSH_KEY} \$*" >> $SSH_WRAPPER 1 && \
61        chmod +x $SSH_WRAPPER \
62                || { echo "Creation of wrapper failed" ; exit 1 ; }
63fi
64
65# checkout if required, update otherwise.
66if [ ! -d ${TREE} ]; then
67        mkdir -p ${TREE} && \
68        cd ${TREE} && \
69        CVS_RSH=${SSH_WRAPPER} cvs -q -d $CVS_ROOT co darwinports > $FAILURE_LOG 2>&1 \
70                || { echo "CVS checkout failed" >> $FAILURE_LOG ; FAILED=1 ; }
71else
72        cd ${TREE}/${CVS_MODULE} && \
73        CVS_RSH=${SSH_WRAPPER} cvs -q update -dP > $FAILURE_LOG 2>&1 \
74                || { echo "CVS update failed" >> $FAILURE_LOG ; FAILED=1 ; }
75fi
76
77# (re)configure.
78if [ $FAILED -eq 0 ]; then
79        cd ${TREE}/${CVS_MODULE}/base/ && \
80        mkdir -p ${TCLPKG} && \
81        ./configure \
82                --prefix=${PREFIX} \
83                --with-tclpackage=${TCLPKG} \
84                --with-install-user=${DP_USER} \
85                --with-install-group=${DP_GROUP} > $FAILURE_LOG 2>&1 \
86                || { echo "./configure failed" >> $FAILURE_LOG ; FAILED=1 ; }
87fi
88
89# clean
90# (cleaning is useful because we don't want the indexing to fail because dependencies aren't properly computed).
91if [ $FAILED -eq 0 ]; then
92        { cd ${TREE}/${CVS_MODULE}/base/ && \
93        make clean > $FAILURE_LOG 2>&1 ; } \
94                || { echo "make clean failed" >> $FAILURE_LOG ; FAILED=1 ; }
95fi
96
97# (re)build
98if [ $FAILED -eq 0 ]; then
99        { cd ${TREE}/${CVS_MODULE}/base/ && \
100        make > $FAILURE_LOG 2>&1 ; } \
101                || { echo "make failed" >> $FAILURE_LOG ; FAILED=1 ; }
102fi
103
104# (re)install
105if [ $FAILED -eq 0 ]; then
106        { cd ${TREE}/${CVS_MODULE}/base/ && \
107        make install > $FAILURE_LOG 2>&1 ; } \
108                || { echo "make install failed" >> $FAILURE_LOG ; FAILED=1 ; }
109fi
110
111# (re)index
112if [ $FAILED -eq 0 ]; then
113        { cd ${TREE}/${CVS_MODULE}/dports/ && \
114        ${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
115                || { echo "portindex failed" >> $FAILURE_LOG ; FAILED=1 ; }
116fi
117
118# check all ports were indexed.
119if [ $FAILED -eq 0 ]; then
120        grep Failed $FAILURE_LOG \
121                && { echo "some ports couldn\'t be indexed" >> $FAILURE_LOG ; FAILED=1 ; }
122fi
123
124# commit the file if and only if all ports were successfully indexed.
125if [ $FAILED -eq 0 ]; then
126        # Use the last 5 lines of the log for the commit message.
127        tail -n 5 $FAILURE_LOG > $COMMIT_MSG
128       
129        # Actually commit the file.
130        { cd ${TREE}/${CVS_MODULE}/dports/ && \
131        CVS_RSH=${SSH_WRAPPER} cvs commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
132                || { echo "cvs commit failed" >> $FAILURE_LOG ; FAILED=1 ; }
133fi
134
135# spam if something went wrong.
136if [ $FAILED -ne 0 ]; then
137        mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
138else
139        # trash log files
140        rm -f $COMMIT_MSG $FAILURE_LOG
141fi
142
Note: See TracBrowser for help on using the repository browser.