src/Tools/jEdit/makedist
author wenzelm
Mon, 19 Jan 2009 15:56:58 +0100
changeset 34480 017fae24829f
parent 34478 095e5cae6656
child 34512 14d70378f1c7
permissions -rwxr-xr-x
simplified implicit convertion Int => Position;

#!/usr/bin/env bash
#
# makedist -- make Isabelle/jEdit distribution

## self references

PRG=$(basename "$0")
THIS=$(cd "$(dirname "$0")"; pwd)
SUPER=$(cd "$THIS/.."; pwd)


## diagnostics

JEDIT_HOME="/home/isajedit/jedit-orig/4.3pre16"
SCALA_HOME="/home/scala/current"

function usage()
{
  echo
  echo "Usage: $PRG [OPTIONS]"
  echo
  echo "  Options are:"
  echo "    -j DIR       specify original jEdit distribution"
  echo "                 (default: $JEDIT_HOME)"
  echo "    -s DIR       specify Scala distribution"
  echo "                 (default: $SCALA_HOME)"
  echo
  echo "  Produce Isabelle/jEdit distribution from Netbeans build"
  echo "  in $THIS/dist"
  echo
  exit 1
}

fail()
{
  echo "$1" >&2
  exit 2
}


## process command line

# options

while getopts "j:s:" OPT
do
  case "$OPT" in
    j)
      JEDIT_HOME="$OPTARG"
      ;;
    s)
      SCALA_HOME="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -ne 0 ] && usage


## main

cd "$THIS/dist" || fail "Bad directory: $THIS/dist"


# target name

VERSION=$(basename "$JEDIT_HOME")
JEDIT="jedit-${VERSION}"

rm -rf "$JEDIT" jedit
mkdir "$JEDIT"
ln -s "$JEDIT" jedit


# copy stuff

[ "$JEDIT_HOME/jedit.jar" ] || fail "Bad original jEdit directory: $JEDIT_HOME"
cp -R "$JEDIT_HOME/." "$JEDIT/."
rm -rf "$JEDIT/jEdit" "$JEDIT/build-support"

mkdir -p "$JEDIT/jars"

[ "$SCALA_HOME/lib/scala-library.jar" ] || fail "Bad Scala directory: $SCALA_HOME"
cp "$SCALA_HOME/lib/scala-library.jar" "$JEDIT/jars/"

cp -R "$THIS/dist-template/." "$JEDIT/."

perl -i -e 'while (<>) { if (m/NAME="javacc"/) {
  print qq,<MODE NAME="isabelle" FILE="isabelle.xml" FILE_NAME_GLOB="*.thy"/>\n\n,; }
  print; }' "$JEDIT/modes/catalog"

cp jars/Isabelle-jEdit.jar "$JEDIT/jars/isabelle.jar"
cp jars/lib/Pure.jar "$JEDIT/jars/isabelle-Pure.jar"
cp jars/lib/core-renderer.jar "$JEDIT/jars/"
cp jars/lib/ErrorList.jar "$JEDIT/jars/"
cp jars/lib/SideKick.jar "$JEDIT/jars/"


# build archive

echo "${JEDIT}.tar.gz"
tar czf "${JEDIT}.tar.gz" "$JEDIT" jedit
ln -sf "${JEDIT}.tar.gz" jedit.tar.gz