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