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 Subversion
13 # This script is expected to be run by the integrate_pass_notify_command
14 # and as such the baseline has already assumed the shape asked for by
17 # integrate_pass_notify_command =
18 # "$bin/ae-svn-ci $project $change http://svn.site.com/svn/trunk --username svn_user";
20 # Alternatively, you may wish to tailor this script to the individual
21 # needs of your project. Make it a source file, e.g. "etc/ae-svn-ci.sh"
22 # and then use the following:
24 # integrate_pass_notify_command =
25 # "$sh ${s etc/ae-svn-ci} $project $change http://svn.site.com/svn/trunk --username svn_user";
28 USAGE="Usage: $0 [-hnq] <project> <change> <url> [<co_options>]"
33 while getopts "hnq" FLAG
47 echo "$0: unknown option ${FLAG}" >&2
53 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-svn-ci.$$
87 if test X${PWD} != X${TMP}; then
88 echo "$0: ended up in ${PWD}, not ${TMP}" >&2
109 # Create a new Subversion 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 Subversion where it is going to put a
113 # module, so we can always get the "cd" right?
115 ${PRINT} svn co $svn_url $module $svn_co_flags
116 ${EXECUTE} svn co $svn_url $module $svn_co_flags > 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 # Subversion 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 Subversion 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 .svn -prune -o -type d -print |
148 if [ ! -d "$dir/.svn" ]
150 Command svn add -N "$dir"
156 # Use the Aegis meta-data to perform some commands that Subversion can't
157 # figure out for itself. We use an inline "aer" report script to identify
158 # when a remove-create pair are actually due to a move.
160 aegis -rpt -nph -f - <<_EOF_ |
162 cs = project[project_name()].state.branch.change[change_number()];
164 columns({width = 1000;});
170 moved[file.move] = 1;
176 if (file.action == "remove" && file.move != "")
179 action = file.action;
181 * Suppress printing of any files created as the result of a move.
182 * These are printed as the destination when printing the line for
183 * the file that was *removed* as a result of the move.
185 if (action != "create" || ! moved[file.file_name])
186 print(sprintf("%s %s \\"%s\\" \\"%s\\"", file.usage, action, file.file_name, file.move));
198 Command svn add $srcfile
201 Command rm -f $srcfile
202 Command svn remove $srcfile
205 Command mv $dstfile $dstfile.move
206 Command svn move $srcfile $dstfile
207 Command cp $dstfile.move $dstfile
208 Command rm -f $dstfile.move
216 # Extract the brief description. We'd like to do this using aesub
217 # or something, like so:
219 # message=`aesub '${version} - ${change description}'`
221 # but the expansion of ${change description} has a lame hard-coded max of
222 # 80 characters, so we have to do this by hand. (This has the slight
223 # benefit of preserving backslashes in front of any double-quotes in
224 # the text; that will have to be handled if we go back to using aesub.)
226 description=`aegis -ca -l | sed -n 's/brief_description = "\(.*\)";$/\1/p'`
227 version=`aesub '${version}'`
228 message="$version - $description"
231 # Now commit all the changes.
233 Command svn commit -m \"$message\"
236 # All done. Clean up and go home.