33030
|
1 |
#!/bin/bash
|
|
2 |
|
|
3 |
# Get an absolute path to this script, since that determines the top-level
|
|
4 |
# directory.
|
|
5 |
this_script_dir=`dirname $0`
|
|
6 |
TOPDIR=`cd $this_script_dir/../.. > /dev/null && pwd`
|
|
7 |
|
|
8 |
GREP=grep
|
|
9 |
MD_FILE=$TOPDIR/README-builds.md
|
|
10 |
HTML_FILE=$TOPDIR/README-builds.html
|
|
11 |
|
|
12 |
# Locate the markdown processor tool and check that it is the correct version.
|
|
13 |
locate_markdown_processor() {
|
|
14 |
if [ -z "$MARKDOWN" ]; then
|
|
15 |
MARKDOWN=`which markdown 2> /dev/null`
|
|
16 |
if [ -z "$MARKDOWN" ]; then
|
|
17 |
echo "Error: Cannot locate markdown processor" 1>&2
|
|
18 |
exit 1
|
|
19 |
fi
|
|
20 |
fi
|
|
21 |
|
|
22 |
# Test version
|
|
23 |
MARKDOWN_VERSION=`$MARKDOWN -version | $GREP version`
|
|
24 |
if [ "x$MARKDOWN_VERSION" != "xThis is Markdown, version 1.0.1." ]; then
|
|
25 |
echo "Error: Expected markdown version 1.0.1." 1>&2
|
|
26 |
echo "Actual version found: $MARKDOWN_VERSION" 1>&2
|
|
27 |
echo "Download markdown here: https://daringfireball.net/projects/markdown/" 1>&2
|
|
28 |
exit 1
|
|
29 |
fi
|
|
30 |
|
|
31 |
}
|
|
32 |
|
|
33 |
# Verify that the source markdown file looks sound.
|
|
34 |
verify_source_code() {
|
|
35 |
TOO_LONG_LINES=`$GREP -E -e '^.{80}.+$' $MD_FILE`
|
|
36 |
if [ "x$TOO_LONG_LINES" != x ]; then
|
|
37 |
echo "Warning: The following lines are longer than 80 characters:"
|
|
38 |
$GREP -E -e '^.{80}.+$' $MD_FILE
|
|
39 |
fi
|
|
40 |
}
|
|
41 |
|
|
42 |
# Convert the markdown file to html format.
|
|
43 |
process_source() {
|
|
44 |
echo "Generating html file from markdown"
|
|
45 |
cat > $HTML_FILE << END
|
|
46 |
<html>
|
|
47 |
<head>
|
|
48 |
<title>OpenJDK Build README</title>
|
|
49 |
</head>
|
|
50 |
<body>
|
|
51 |
END
|
|
52 |
markdown $MD_FILE >> $HTML_FILE
|
|
53 |
cat >> $HTML_FILE <<END
|
|
54 |
</body>
|
|
55 |
</html>
|
|
56 |
END
|
|
57 |
echo "Done"
|
|
58 |
}
|
|
59 |
|
|
60 |
locate_markdown_processor
|
|
61 |
verify_source_code
|
|
62 |
process_source
|