95 |
|
EOF_CMSCVSROOT_CSH |
96 |
|
|
97 |
|
cat << \EOF_CLCOMMIT > %i/bin/clcommit |
98 |
+ |
#! /bin/sh |
99 |
|
|
100 |
+ |
# commit version 0.9.4 |
101 |
+ |
|
102 |
+ |
# Copyright (C) 1999, 2000, Free Software Foundation |
103 |
+ |
|
104 |
+ |
# This script is Free Software, and it can be copied, distributed and |
105 |
+ |
# modified as defined in the GNU General Public License. A copy of |
106 |
+ |
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html |
107 |
+ |
|
108 |
+ |
# Originally by Gary V. Vaughan <gvaughan@oranda.demon.co.uk> |
109 |
+ |
# Heavily modified by Alexandre Oliva <oliva@dcc.unicamp.br> |
110 |
+ |
|
111 |
+ |
# This scripts eases checking in changes to CVS-maintained projects |
112 |
+ |
# with ChangeLog files. It will check that there have been no |
113 |
+ |
# conflicting commits in the CVS repository and print which files it |
114 |
+ |
# is going to commit to stderr. A list of files to compare and to |
115 |
+ |
# check in can be given in the command line. If it is not given, all |
116 |
+ |
# files in the current directory (and below, unless `-l' is given) are |
117 |
+ |
# considered for check in. |
118 |
+ |
|
119 |
+ |
# The commit message will be extracted from the differences between a |
120 |
+ |
# file named ChangeLog* in the commit list, or named after -C, and the |
121 |
+ |
# one in the repository (unless a message was specified with `-m' or |
122 |
+ |
# `-F'). An empty message is not accepted (but a blank line is). If |
123 |
+ |
# the message is acceptable, it will be presented for verification |
124 |
+ |
# (and possible edition) using the $PAGER environment variable (or |
125 |
+ |
# `more', if it is not set, or `cat', if the `-f' switch is given). |
126 |
+ |
# If $PAGER exits successfully, the modified files (at that moment) |
127 |
+ |
# are checked in, unless `-n' was specified, in which case nothing is |
128 |
+ |
# checked in. |
129 |
+ |
|
130 |
+ |
# usage: commit [-v] [-h] [-f] [-l] [-n] [-q] [-z N] [-C ChangeLog_file] |
131 |
+ |
# [-m msg|-F msg_file] [--] [file|dir ...] |
132 |
+ |
|
133 |
+ |
# -f --fast don't check (unless *followed* by -n), and just |
134 |
+ |
# --force display commit message instead of running $PAGER |
135 |
+ |
# -l --local don't descend into subdirectories |
136 |
+ |
# -m msg --message=msg set commit message |
137 |
+ |
# --msg=msg same as -m |
138 |
+ |
# -F file --file=file read commit message from file |
139 |
+ |
# -C file --changelog=file extract commit message from specified ChangeLog |
140 |
+ |
# -n --dry-run don't commit anything |
141 |
+ |
# -q --quiet run cvs in quiet mode |
142 |
+ |
# -zN --compress=N set compression level (0-9, 0=none, 9=max) |
143 |
+ |
# -v --version print version information |
144 |
+ |
# -h,-? --help print short or long help message |
145 |
+ |
|
146 |
+ |
name=commit |
147 |
+ |
: ${CVS=cvs} |
148 |
+ |
cvsopt= |
149 |
+ |
updateopt= |
150 |
+ |
commitopt= |
151 |
+ |
dry_run=false |
152 |
+ |
commit=: |
153 |
+ |
update=: |
154 |
+ |
log_file="${TMPDIR-/tmp}/commitlog.$$" |
155 |
+ |
|
156 |
+ |
rm -f "$log_file" |
157 |
+ |
trap 'rm -f "$log_file"; exit 1' 1 2 15 |
158 |
+ |
|
159 |
+ |
# this just eases exit handling |
160 |
+ |
main_repeat=":" |
161 |
+ |
while $main_repeat; do |
162 |
+ |
|
163 |
+ |
repeat="test $# -gt 0" |
164 |
+ |
while $repeat; do |
165 |
+ |
case "$1" in |
166 |
+ |
-f|--force|--fast) |
167 |
+ |
update=false |
168 |
+ |
PAGER=cat |
169 |
+ |
shift |
170 |
+ |
;; |
171 |
+ |
-l|--local) |
172 |
+ |
updateopt="$updateopt -l" |
173 |
+ |
commitopt="$commitopt -l" |
174 |
+ |
shift |
175 |
+ |
;; |
176 |
+ |
-m|--message|--msg) |
177 |
+ |
if test $# = 1; then |
178 |
+ |
echo "$name: missing argument for $1" >&2 |
179 |
+ |
break |
180 |
+ |
fi |
181 |
+ |
if test -f "$log_file"; then |
182 |
+ |
echo "$name: you can have at most one of -m and -F" >&2 |
183 |
+ |
break |
184 |
+ |
fi |
185 |
+ |
shift |
186 |
+ |
echo "$1" > "$log_file" |
187 |
+ |
shift |
188 |
+ |
;; |
189 |
+ |
-F|--file) |
190 |
+ |
if test -f "$log_file"; then |
191 |
+ |
echo "$name: you can have at most one of -m and -F" >&2 |
192 |
+ |
break |
193 |
+ |
fi |
194 |
+ |
if test $# = 1; then |
195 |
+ |
echo "$name: missing argument for $1" >&2 |
196 |
+ |
break |
197 |
+ |
fi |
198 |
+ |
shift |
199 |
+ |
if cat < "$1" > "$log_file"; then :; else |
200 |
+ |
break |
201 |
+ |
fi |
202 |
+ |
shift |
203 |
+ |
;; |
204 |
+ |
-C|--[cC]hange[lL]og) |
205 |
+ |
if test $# = 1; then |
206 |
+ |
echo "$name: missing argument for $1" >&2 |
207 |
+ |
break |
208 |
+ |
fi |
209 |
+ |
shift |
210 |
+ |
if test ! -f "$1"; then |
211 |
+ |
echo "$name: ChangeLog file \`$1' does not exist" >&2 |
212 |
+ |
break |
213 |
+ |
fi |
214 |
+ |
ChangeLog="$1" |
215 |
+ |
;; |
216 |
+ |
-n|--dry-run) |
217 |
+ |
PAGER=cat |
218 |
+ |
commit=false |
219 |
+ |
update=true |
220 |
+ |
shift |
221 |
+ |
;; |
222 |
+ |
-q|--quiet) |
223 |
+ |
cvsopt="$cvsopt -q" |
224 |
+ |
shift |
225 |
+ |
;; |
226 |
+ |
-z|--compress) |
227 |
+ |
if test $# = 1; then |
228 |
+ |
echo "$name: missing argument for $1" >&2 |
229 |
+ |
break |
230 |
+ |
fi |
231 |
+ |
case "$2" in |
232 |
+ |
[0-9]) :;; |
233 |
+ |
*) echo "$name: invalid argument for $1" >&2 |
234 |
+ |
break |
235 |
+ |
;; |
236 |
+ |
esac |
237 |
+ |
cvsopt="$cvsopt -z$2" |
238 |
+ |
shift |
239 |
+ |
shift |
240 |
+ |
;; |
241 |
+ |
|
242 |
+ |
-m*|-F*|-C*|-z*) |
243 |
+ |
opt=`echo "$1" | sed '1s/^\(..\).*$/\1/;q'` |
244 |
+ |
arg=`echo "$1" | sed '1s/^-[a-zA-Z0-9]//'` |
245 |
+ |
shift |
246 |
+ |
set -- "$opt" "$arg" ${1+"$@"} |
247 |
+ |
;; |
248 |
+ |
--message=*|--msg=*|--file=*|--[Cc]hange[Ll]og=*|--compress=*) |
249 |
+ |
opt=`echo "$1" | sed '1s/^\(--[^=]*\)=.*/\1/;q'` |
250 |
+ |
arg=`echo "$1" | sed '1s/^--[^=]*=//'` |
251 |
+ |
shift |
252 |
+ |
set -- "$opt" "$arg" ${1+"$@"} |
253 |
+ |
;; |
254 |
+ |
|
255 |
+ |
-v|--version) |
256 |
+ |
sed '/^# '$name' version /,/^# Heavily modified by/ { s/^# //; p; }; d' < $0 |
257 |
+ |
exit 0 |
258 |
+ |
;; |
259 |
+ |
-\?|-h) |
260 |
+ |
sed '/^# usage:/,/# -h/ { s/^# //; p; }; d' < $0 && |
261 |
+ |
echo |
262 |
+ |
echo "run \`$name --help | more' for full usage" |
263 |
+ |
exit 0 |
264 |
+ |
;; |
265 |
+ |
--help) |
266 |
+ |
sed '/^# '$name' version /,/^[^#]/ { /^[^#]/ d; s/^# //; p; }; d' < $0 |
267 |
+ |
exit 0 |
268 |
+ |
;; |
269 |
+ |
--) |
270 |
+ |
shift |
271 |
+ |
repeat=false |
272 |
+ |
;; |
273 |
+ |
-*) |
274 |
+ |
echo "$name: invalid flag $1" >&2 |
275 |
+ |
break |
276 |
+ |
;; |
277 |
+ |
*) |
278 |
+ |
repeat=false |
279 |
+ |
;; |
280 |
+ |
esac |
281 |
+ |
done |
282 |
+ |
# might have used break 2 within the previous loop, but so what |
283 |
+ |
$repeat && break |
284 |
+ |
|
285 |
+ |
$update && \ |
286 |
+ |
if echo "$name: checking for conflicts..." >&2 |
287 |
+ |
($CVS $cvsopt -q -n update $updateopt ${1+"$@"} 2>/dev/null \ |
288 |
+ |
| while read line; do |
289 |
+ |
echo "$line" |
290 |
+ |
echo "$line" >&3 |
291 |
+ |
done | grep '^C') 3>&1 >/dev/null; then |
292 |
+ |
echo "$name: some conflicts were found, aborting..." >&2 |
293 |
+ |
break |
294 |
+ |
fi |
295 |
+ |
|
296 |
+ |
if test ! -f "$log_file"; then |
297 |
+ |
if test -z "$ChangeLog"; then |
298 |
+ |
for f in ${1+"$@"}; do |
299 |
+ |
case "$f" in |
300 |
+ |
ChangeLog* | */ChangeLog*) |
301 |
+ |
if test -z "$ChangeLog"; then |
302 |
+ |
ChangeLog="$f" |
303 |
+ |
else |
304 |
+ |
echo "$name: multiple ChangeLog files: $ChangeLog and $f" >&2 |
305 |
+ |
break |
306 |
+ |
fi |
307 |
+ |
;; |
308 |
+ |
esac |
309 |
+ |
done |
310 |
+ |
fi |
311 |
+ |
|
312 |
+ |
echo "$name: checking commit message..." >&2 |
313 |
+ |
$CVS $cvsopt diff -u ${ChangeLog-ChangeLog} \ |
314 |
+ |
| while read line; do |
315 |
+ |
case "$line" in |
316 |
+ |
"--- "*) :;; |
317 |
+ |
"-"*) |
318 |
+ |
echo "$name: *** Warning: the following line in ChangeLog diff is suspicious:" >&2 |
319 |
+ |
echo "$line" | sed 's/^.//' >&2;; |
320 |
+ |
"+ "*) |
321 |
+ |
echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2 |
322 |
+ |
echo "$line" | sed 's/^.//' >&2;; |
323 |
+ |
"+") echo;; |
324 |
+ |
"+ "*) echo "$line";; |
325 |
+ |
esac |
326 |
+ |
done \ |
327 |
+ |
| sed -e 's,\+ ,,' -e '/./p' -e '/./d' -e '1d' -e '$d' > "$log_file" \ |
328 |
+ |
|| break |
329 |
+ |
# The sed script above removes "+TAB" from the beginning of a line, then |
330 |
+ |
# deletes the first and/or the last line, when they happen to be empty |
331 |
+ |
fi |
332 |
+ |
|
333 |
+ |
if grep '[^ ]' < "$log_file" > /dev/null; then :; else |
334 |
+ |
echo "$name: empty commit message, aborting" >&2 |
335 |
+ |
break |
336 |
+ |
fi |
337 |
+ |
|
338 |
+ |
if grep '^$' < "$log_file" > /dev/null; then |
339 |
+ |
echo "$name: *** Warning: blank lines should not appear within a commit messages." >&2 |
340 |
+ |
echo "$name: *** They should be used to separate distinct commits." >&2 |
341 |
+ |
fi |
342 |
+ |
|
343 |
+ |
${PAGER-more} "$log_file" || break |
344 |
+ |
|
345 |
+ |
sleep 1 # give the user some time for a ^C |
346 |
+ |
|
347 |
+ |
# Do not check for empty $log_file again, even though the user might have |
348 |
+ |
# zeroed it out. If s/he did, it was probably intentional. |
349 |
+ |
|
350 |
+ |
if $commit; then |
351 |
+ |
echo " $CVS $cvsopt commit $commitopt -F $log_file ${1+"$@"} || break" |
352 |
+ |
$CVS $cvsopt commit $commitopt -F $log_file ${1+"$@"} || break |
353 |
+ |
fi |
354 |
+ |
|
355 |
+ |
main_repeat=false |
356 |
+ |
done |
357 |
+ |
|
358 |
+ |
rm -f "$log_file" |
359 |
+ |
|
360 |
+ |
# if main_repeat was not set to `false', we failed |
361 |
+ |
$main_repeat && exit 1 |
362 |
+ |
exit 0 |
363 |
|
EOF_CLCOMMIT |
364 |
|
|
365 |
|
chmod +x %i/bin/projch.sh |
366 |
|
chmod +x %i/bin/projch.csh |
367 |
|
chmod +x %i/bin/cmscvsroot.sh |
368 |
|
chmod +x %i/bin/cmscvsroot.csh |
369 |
+ |
chmod +x %i/bin/clcommit |
370 |
|
|
371 |
|
ln -sf %i/etc/profile.d/init.sh %instroot/%cmsplatf/etc/profile.d/S00cms-cvs-utils.sh |
372 |
|
ln -sf %i/etc/profile.d/init.csh %instroot/%cmsplatf/etc/profile.d/S00cms-cvs-utils.csh |