-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrender_example_graph.sh
More file actions
executable file
·40 lines (36 loc) · 1.05 KB
/
render_example_graph.sh
File metadata and controls
executable file
·40 lines (36 loc) · 1.05 KB
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
#!/bin/bash
#
# This file is part of Canviz. See http://www.canviz.org/
# $Id: render_example_graph.sh 249 2009-01-05 09:15:06Z ryandesign.com $
#
INPUT_GRAPH_DIR=$1
shift
INPUT_GRAPH=$1
shift
OUTPUT_GRAPH_DIR=$1
shift
GRAPHVIZ_PREFIX=$1
shift
GRAPHVIZ_LAYOUTS=$@
if [ -z "$TMPDIR" ]; then
TMPDIR=/tmp
fi
TEMP_GRAPH=$(mktemp "$TMPDIR/canviz.graph.XXXXXXXX")
TEMP_HEADER=$(mktemp "$TMPDIR/canviz.header.XXXXXXXX")
for LAYOUT in $GRAPHVIZ_LAYOUTS; do
GRAPHVIZ_VERSION=$($GRAPHVIZ_PREFIX/bin/$LAYOUT -V 2>&1)
mkdir -p $OUTPUT_GRAPH_DIR/$LAYOUT/$(dirname $INPUT_GRAPH)
(cd $INPUT_GRAPH_DIR && time $GRAPHVIZ_PREFIX/bin/$LAYOUT -Txdot $INPUT_GRAPH > $TEMP_GRAPH) 2> $TEMP_HEADER
if [ -s $TEMP_GRAPH ]; then
NOW=$(TZ=GMT date)
OUTPUT_GRAPH=$OUTPUT_GRAPH_DIR/$LAYOUT/$INPUT_GRAPH.txt
echo "# Generated $NOW by $GRAPHVIZ_VERSION" > $OUTPUT_GRAPH
echo '#' >> $OUTPUT_GRAPH
sed 's/^/# /' < $TEMP_HEADER >> $OUTPUT_GRAPH
echo >> $OUTPUT_GRAPH
cat $TEMP_GRAPH >> $OUTPUT_GRAPH
else
echo "$LAYOUT $INPUT_GRAPH - CRASHED!" 1>&2
fi
done
rm -f $TEMP_GRAPH $TEMP_HEADER