summaryrefslogtreecommitdiff
path: root/bin/scons-cdist
blob: 58b1bae0a4241e8b48e93d6ec2dceac6ec170966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/bin/sh
#
# Copyright (c) 2005 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

PROG=`basename $0`
NOARGFLAGS="afhlnqrstz"
ARGFLAGS="p:"
ALLFLAGS="${NOARGFLAGS}${ARGFLAGS}"
USAGE="Usage:  ${PROG} [-${NOARGFLAGS}] [-p project] change"

HELP="$USAGE

  -a            Update the latest Aegis baseline (aedist) file.
  -f            Force update, skipping up-front sanity check.
  -h            Print this help message and exit.
  -l            Update the local CVS repository.
  -n            Don't execute, just echo commands.
  -p project    Set the Aegis project.
  -q            Quiet, don't print commands before executing them.
  -r            Rsync the Aegis repository to SourceForge.
  -s            Update the sourceforge.net CVS repository.
  -t            Update the tigris.org CVS repository.
  -z            Update the latest .tar.gz and .zip files.
"

DO=""
PRINT="echo"
EXECUTE="eval"
SANITY_CHECK="yes"

while getopts $ALLFLAGS FLAG; do
    case $FLAG in
    a | l | r | s | t | z )
        DO="${DO}${FLAG}"
        ;;
    f )
        SANITY_CHECK="no"
        ;;
    h )
        echo "${HELP}"
        exit 0
        ;;
    n )
        EXECUTE=":"
        ;;
    p )
        AEGIS_PROJECT="${OPTARG}"
        ;;
    q )
        PRINT=":"
        ;;
    * )
        echo "FLAG = ${FLAG}" >&2
        echo "${USAGE}" >&2
        exit 1
        ;;
    esac
done

shift `expr ${OPTIND} - 1`

if test "X$1" = "X"; then
    echo "${USAGE}" >&2
    exit 1
fi

if test "X${AEGIS_PROJECT}" = "X"; then
    echo "$PROG: No AEGIS_PROJECT set." >&2
    echo "${USAGE}" >&2
    exit 1
fi

if test "X$DO" = "X"; then
    DO="alrstz"
fi

cmd()
{
    $PRINT "$*"
    $EXECUTE "$*"
}

CHANGE=$1

if test "X${SANITY_CHECK}" = "Xyes"; then
    SCM="cvs"
    SCMROOT="/home/scons/CVSROOT/scons"
    DELTA=`aegis -l -ter cd ${CHANGE} | sed -n 's/.*, Delta \([0-9]*\)\./\1/p'`
    if test "x${DELTA}" = "x"; then
        echo "${PROG}:  Could not find delta for change ${CHANGE}." >&2
        echo "Has this finished integrating?  Change ${CHANGE} not distributed." >&2
        exit 1
    fi
    PREV_DELTA=`expr ${DELTA} - 1`
    COMMAND="scons-scmcheck -D ${PREV_DELTA} -d q -p ${AEGIS_PROJECT} -s ${SCM} ${SCMROOT}"
    $PRINT "${COMMAND}"
    OUTPUT=`${COMMAND}`
    if test "X${OUTPUT}" != "X"; then
        echo "${PROG}: ${SCMROOT} is not up to date:" >&2
        echo "${OUTPUT}" >& 2
        echo "Did you skip any changes?  Change ${CHANGE} not distributed." >&2
        exit 1
    fi
fi

if test X$EXECUTE != "X:" -a "X$SSH_AGENT_PID" = "X"; then
    eval `ssh-agent`
    ssh-add
    trap 'eval `ssh-agent -k`; exit' 0 1 2 3 15
fi

cd

BASELINE=`aesub -p ${AEGIS_PROJECT} -c ${CHANGE} '${Project trunk_name}'`

TMPBLAE="/tmp/${BASELINE}.ae"
TMPCAE="/tmp/${AEGIS_PROJECT}.C${CHANGE}.ae"

# Original values for SourceForge.
#SFLOGIN="stevenknight"
#SFHOST="scons.sourceforge.net"
#SFDEST="/home/groups/s/sc/scons/htdocs"

SCONSLOGIN="scons"
SCONSHOST="manam.pair.com"
#SCONSDEST="public_html/production"
SCONSDEST="public_ftp"

#
# Copy the baseline .ae to the constant location on SourceForge.
#
case "${DO}" in
*a* )
    cmd "aedist -s -bl -p ${AEGIS_PROJECT} > ${TMPBLAE}"
    cmd "scp ${TMPBLAE} ${SCONSLOGIN}@${SCONSHOST}:${SCONSDEST}/${BASELINE}.ae"
    cmd "rm ${TMPBLAE}"
    ;;
esac

#
# Copy the latest .tar.gz and .zip files to the constant location on
# SourceForge.
#
case "${DO}" in
*z* )
    BUILD_DIST=`aegis -p ${AEGIS_PROJECT} -cd -bl`/build/dist
    SCONS_SRC_TAR_GZ=`echo ${AEGIS_PROJECT} | sed 's/scons./scons-src-/'`*.tar.gz
    SCONS_SRC_ZIP=`echo ${AEGIS_PROJECT} | sed 's/scons./scons-src-/'`*.zip
    cmd "scp ${BUILD_DIST}/${SCONS_SRC_TAR_GZ} ${SCONSLOGIN}@${SCONSHOST}:${SCONSDEST}/scons-src-latest.tar.gz"
    cmd "scp ${BUILD_DIST}/${SCONS_SRC_ZIP} ${SCONSLOGIN}@${SCONSHOST}:${SCONSDEST}/scons-src-latest.zip"
esac

#
# Sync Aegis tree with SourceForge.
#
# Cribbed and modified from Peter Miller's same-named script in
# /home/groups/a/ae/aegis/aegis at SourceForge.
#
# Guide to what this does with rsync:
#
#   --rsh=ssh          use ssh for the transfer
#   -l                 copy symlinks as symlinks
#   -p                 preserve permissions
#   -r                 recursive
#   -t                 preserve times
#   -z                 compress data
#   --stats            file transfer statistics
#   --exclude          exclude files matching the pattern
#   --delete           delete files that don't exist locally
#   --delete-excluded  delete files that match the --exclude patterns
#   --progress         show progress during the transfer
#   -v                 verbose
#
# We no longer use the --stats option.
#
case "${DO}" in
*r* )
    LOCAL=/home/scons/scons
    REMOTE=/home/groups/s/sc/scons/scons
    cmd "/usr/bin/rsync --rsh='ssh -l stevenknight' \
            -l -p -r -t -z \
            --exclude build \
            --exclude '*,D' \
            --exclude '*.pyc' \
            --exclude aegis.log \
            --exclude '.sconsign*' \
            --delete --delete-excluded \
            --progress -v \
            ${LOCAL}/. scons.sourceforge.net:${REMOTE}/."
    ;;
esac

#
# Sync the CVS tree with the local repository.
#
case "${DO}" in
*l* )
    (
        export CVSROOT=/home/scons/CVSROOT/scons
        #cmd "ae2cvs -X -aegis -p ${AEGIS_PROJECT} -c ${CHANGE} -u $HOME/SCons/baldmt.com/scons"
        cmd "ae-cvs-ci ${AEGIS_PROJECT} ${CHANGE}"
    )
    ;;
esac

#
# Sync the Subversion tree with Tigris.org.
#
case "${DO}" in
*t* )
    (
        SVN=http://scons.tigris.org/svn/scons
        case ${AEGIS_PROJECT} in
        scons.0.96 )
            SVN_URL=${SVN}/branches/core
            ;;
        scons.0.96.513 )
            SVN_URL=${SVN}/branches/sigrefactor
            ;;
        * )
            echo "$PROG: Don't know SVN branch for '${AEGIS_PROJECT}'" >&2
            exit 1
            ;;
        esac
        SVN_CO_FLAGS="--username stevenknight"
        #cmd "ae2cvs -X -aegis -p ${AEGIS_PROJECT} -c ${CHANGE} -u $HOME/SCons/tigris.org/scons"
        cmd "ae-svn-ci ${AEGIS_PROJECT} ${CHANGE} ${SVN_URL} ${SVN_CO_FLAGS}"
    )
    ;;
esac

#
# Sync the CVS tree with SourceForge.
#
case "${DO}" in
*s* )
    (
        export CVS_RSH=ssh
        export CVSROOT=:ext:stevenknight@scons.cvs.sourceforge.net:/cvsroot/scons
        #cmd "ae2cvs -X -aegis -p ${AEGIS_PROJECT} -c ${CHANGE} -u $HOME/SCons/sourceforge.net/scons"
        cmd "ae-cvs-ci ${AEGIS_PROJECT} ${CHANGE}"
    )
    ;;
esac

#
# Send the change .ae to the scons-aedist mailing list
#
# The subject requires editing by hand...
#
#aedist -s -p ${AEGIS_PROJECT} ${CHANGE} > ${TMPCAE}
#aegis -l -p ${AEGIS_PROJECT} -c ${CHANGE} cd |
#        pine -attach_and_delete ${TMPCAE} scons-aedist@lists.sourceforge.net