lib/Tools/install
author wenzelm
Fri Sep 01 17:50:36 2000 +0200 (2000-09-01)
changeset 9788 df671fa2562a
parent 7934 42836b6c4c73
child 10030 950580516dfa
permissions -rwxr-xr-x
GPLed;
more robust handling of spaces in args / file names;
wenzelm@5362
     1
#!/bin/bash
wenzelm@5362
     2
#
wenzelm@5362
     3
# $Id$
wenzelm@9788
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@9788
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@5362
     6
#
wenzelm@6417
     7
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     8
wenzelm@5362
     9
wenzelm@9788
    10
PRG=$(basename "$0")
wenzelm@5362
    11
wenzelm@5362
    12
function usage()
wenzelm@5362
    13
{
wenzelm@5362
    14
  echo
wenzelm@6417
    15
  echo "Usage: $PRG [OPTIONS]"
wenzelm@5362
    16
  echo
wenzelm@5403
    17
  echo "  Options are:"
wenzelm@7887
    18
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
wenzelm@7887
    19
  echo "                 (default ISABELLE_HOME)"
wenzelm@6417
    20
  echo "    -k           install KDE application icon on Desktop"
wenzelm@6417
    21
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    22
  echo
wenzelm@6417
    23
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    24
  echo "  distribution directory."
wenzelm@5362
    25
  echo
wenzelm@5362
    26
  exit 1
wenzelm@5362
    27
}
wenzelm@5362
    28
wenzelm@5362
    29
function fail()
wenzelm@5362
    30
{
wenzelm@5362
    31
  echo "$1" >&2
wenzelm@5362
    32
  exit 2
wenzelm@5362
    33
}
wenzelm@5362
    34
wenzelm@5362
    35
wenzelm@5403
    36
## process command line
wenzelm@5403
    37
wenzelm@5403
    38
# options
wenzelm@5403
    39
wenzelm@6450
    40
NO_OPTS=true
wenzelm@6450
    41
wenzelm@5403
    42
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    43
KDE=""
wenzelm@6417
    44
BINDIR=""
wenzelm@5362
    45
wenzelm@6417
    46
while getopts "d:kp:" OPT
wenzelm@5403
    47
do
wenzelm@5403
    48
  case "$OPT" in
wenzelm@5404
    49
    d)
wenzelm@5403
    50
      DISTDIR="$OPTARG"
wenzelm@6450
    51
      NO_OPTS=""
wenzelm@5403
    52
      ;;
wenzelm@6417
    53
    k)
wenzelm@6417
    54
      KDE=true
wenzelm@6450
    55
      NO_OPTS=""
wenzelm@6417
    56
      ;;
wenzelm@6417
    57
    p)
wenzelm@6417
    58
      BINDIR="$OPTARG"
wenzelm@6450
    59
      NO_OPTS=""
wenzelm@6417
    60
      ;;
wenzelm@5403
    61
    \?)
wenzelm@5403
    62
      usage
wenzelm@5403
    63
      ;;
wenzelm@5403
    64
  esac
wenzelm@5403
    65
done
wenzelm@5362
    66
wenzelm@5403
    67
shift $(($OPTIND - 1))
wenzelm@5403
    68
wenzelm@5403
    69
wenzelm@5403
    70
# args
wenzelm@5403
    71
wenzelm@9788
    72
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    73
wenzelm@5362
    74
wenzelm@5362
    75
## main
wenzelm@5362
    76
wenzelm@6459
    77
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    78
wenzelm@6417
    79
wenzelm@6417
    80
# standalone binaries
wenzelm@5362
    81
wenzelm@6082
    82
#set by configure
wenzelm@6082
    83
AUTO_BASH=/bin/bash
wenzelm@5362
    84
wenzelm@6417
    85
if [ -n "$BINDIR" ]; then
wenzelm@6417
    86
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    87
wenzelm@6417
    88
  for NAME in isatool isabelle Isabelle
wenzelm@6417
    89
  do
wenzelm@6417
    90
    BIN="$BINDIR/$NAME"
wenzelm@6417
    91
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
    92
    echo "installing $BIN"
wenzelm@9788
    93
    echo "#!$AUTO_BASH" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
    94
    echo >> "$BIN"
wenzelm@9788
    95
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
    96
    chmod +x "$BIN"
wenzelm@6417
    97
  done
wenzelm@6417
    98
fi
wenzelm@6417
    99
wenzelm@6417
   100
wenzelm@6417
   101
# install KDE application icon
wenzelm@5403
   102
wenzelm@6417
   103
KDEHOME=~/.kde
wenzelm@6417
   104
KDEAPP=~/Desktop/Isabelle.kdelnk
wenzelm@9788
   105
KDEICONS="$KDEHOME/share/icons"
wenzelm@6417
   106
wenzelm@6417
   107
if [ "$KDE" = true ]; then
wenzelm@9788
   108
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   109
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   110
wenzelm@9788
   111
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   112
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   113
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   114
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   115
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   116
wenzelm@6417
   117
  echo "installing $KDEAPP"
wenzelm@9788
   118
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   119
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   120
  echo "Type=Application" >> "$KDEAPP"
wenzelm@9788
   121
  echo "Exec=$DISTDIR/bin/Isabelle %f" >> "$KDEAPP"
wenzelm@9788
   122
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   123
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   124
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   125
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   126
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   127
wenzelm@9788
   128
  echo "Please refresh your KDE now!"
wenzelm@6417
   129
fi