2 # aegis - project change supervisor
3 # Copyright (C) 2004 Peter Miller;
6 # As a specific exception to the GPL, you are allowed to copy
7 # this source file into your own project and modify it, without
8 # releasing your project under the GPL, unless there is some other
9 # file or condition which would require it.
11 # MANIFEST: shell script to commit changes to CVS
13 # It is assumed that your CVSROOT and CVS_RSH environment variables have
14 # already been set appropriately.
16 # This script is expected to be run as by integrate_pass_notify_command
17 # and as such the baseline has already assumed the shape asked for by
20 # integrate_pass_notify_command =
21 # "$bin/ae-cvs-ci $project $change";
23 # Alternatively, you may wish to tailor this script to the individual
24 # needs of your project. Make it a source file, e.g. "etc/ae-cvs-ci.sh"
25 # and then use the following:
27 # integrate_pass_notify_command =
28 # "$sh ${s etc/ae-cvs-ci} $project $change";
31 USAGE="Usage: $0 <project> <change>"
36 while getopts "hnq" FLAG
50 echo "$0: unknown option ${FLAG}" >&2
56 shift `expr ${OPTIND} - 1`
71 AEGIS_PROJECT=$project
76 module=`echo $project | sed 's|[.].*||'`
78 baseline=`aegis -cd -bl`
80 if test X${TMPDIR} = X; then TMPDIR=/var/tmp; fi
82 TMP=${TMPDIR}/ae-cvs-ci.$$
87 if test X${PWD} != X${TMP}; then
88 echo "$0: ended up in ${PWD}, not ${TMP}" >&2
109 # Create a new CVS work area.
111 # Note: this assumes the module is checked-out into a directory of the
112 # same name. Is there a way to ask CVS where is is going to put a
113 # modules, so we can always get the "cd" right?
115 ${PRINT} cvs co $module
116 ${EXECUTE} cvs co $module > LOG 2>&1
117 if test $? -ne 0; then cat LOG; fail; fi
118 ${EXECUTE} cd $module
121 # Now we need to extract the sources from Aegis and drop them into the
122 # CVS work area. There are two ways to do this.
124 # The first way is to use the generated tarball.
125 # This has the advantage that it has the Makefile.in file in it, and
126 # will work immediately.
128 # The second way is to use aetar, which will give exact sources, and
129 # omit all derived files. This will *not* include the Makefile.in,
130 # and so will not be readily compilable.
132 # gunzip < $baseline/export/${project}.tar.gz | tardy -rp ${project} | tar xf -
133 aetar -send -comp-alg=gzip -o - | tar xzf -
136 # If any new directories have been created we will need to add them
137 # to CVS before we can add the new files which we know are in them,
138 # or they would not have been created. Do this only if the -n option
139 # isn't used, because if it is, we won't have actually checked out the
140 # source and we'd erroneously report that all of them need to be added.
142 if test "X${EXECUTE}" != "X:"
144 find . \( -name CVS -o -name Attic \) -prune -o -type d -print |
148 if [ ! -d "$dir/CVS" ]
150 Command cvs add "$dir"
156 # Use the Aegis meta-data to perform some CVS commands that CVS can't
157 # figure out for itself.
159 aegis -l cf -unf | sed 's| -> [0-9][0-9.]*||' |
160 while read usage action rev filename
162 if test "x$filename" = "x"
168 Command cvs add $filename
171 Command rm -f $filename
172 Command cvs remove $filename
180 # Extract the brief description. We'd like to do this using aesub
181 # or something, like so:
183 # message=`aesub '${version} - ${change description}'`
185 # but the expansion of ${change description} has a lame hard-coded max of
186 # 80 characters, so we have to do this by hand. (This has the slight
187 # benefit of preserving backslashes in front of any double-quotes in
188 # the text; that will have to be handled if we go back to using aesub.)
190 description=`aegis -ca -l | sed -n 's/brief_description = "\(.*\)";$/\1/p'`
191 version=`aesub '${version}'`
192 message="$version - $description"
195 # Now commit all the changes.
197 Command cvs -q commit -m \"$message\"
200 # All done. Clean up and go home.