lib/Tools/install
author aspinall
Thu Apr 14 19:16:07 2005 +0200 (2005-04-14)
changeset 15733 75b9219980d3
parent 15574 b1d1b5bfc464
child 15848 3001067227af
permissions -rwxr-xr-x
Add RDISTDIR option used by Isabelle RPM.
wenzelm@10555
     1
#!/usr/bin/env bash
wenzelm@5362
     2
#
wenzelm@5362
     3
# $Id$
wenzelm@9788
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@5362
     5
#
wenzelm@6417
     6
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     7
wenzelm@5362
     8
wenzelm@9788
     9
PRG=$(basename "$0")
wenzelm@5362
    10
wenzelm@5362
    11
function usage()
wenzelm@5362
    12
{
wenzelm@5362
    13
  echo
wenzelm@6417
    14
  echo "Usage: $PRG [OPTIONS]"
wenzelm@5362
    15
  echo
wenzelm@5403
    16
  echo "  Options are:"
wenzelm@7887
    17
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
wenzelm@7887
    18
  echo "                 (default ISABELLE_HOME)"
aspinall@15733
    19
  echo "    -a RDISTDIR  refer to RDISTDIR as Isabelle distribution"
aspinall@15733
    20
  echo "                 in installed files, for packaging scripts"
aspinall@15733
    21
  echo "                 (default to same value as -d)"
wenzelm@11125
    22
  echo "    -k VERSION   install KDE application icon on desktop"
wenzelm@11125
    23
  echo "                 (for KDE VERSION 1 or 2)"
wenzelm@6417
    24
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    25
  echo
wenzelm@6417
    26
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    27
  echo "  distribution directory."
wenzelm@5362
    28
  echo
wenzelm@5362
    29
  exit 1
wenzelm@5362
    30
}
wenzelm@5362
    31
wenzelm@5362
    32
function fail()
wenzelm@5362
    33
{
wenzelm@5362
    34
  echo "$1" >&2
wenzelm@5362
    35
  exit 2
wenzelm@5362
    36
}
wenzelm@5362
    37
wenzelm@5362
    38
wenzelm@5403
    39
## process command line
wenzelm@5403
    40
wenzelm@5403
    41
# options
wenzelm@5403
    42
wenzelm@6450
    43
NO_OPTS=true
wenzelm@6450
    44
wenzelm@5403
    45
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    46
KDE=""
wenzelm@6417
    47
BINDIR=""
aspinall@15733
    48
RDISTDIR=""
wenzelm@5362
    49
aspinall@15733
    50
while getopts "d:k:p:a:" OPT
wenzelm@5403
    51
do
wenzelm@5403
    52
  case "$OPT" in
wenzelm@5404
    53
    d)
wenzelm@5403
    54
      DISTDIR="$OPTARG"
wenzelm@6450
    55
      NO_OPTS=""
wenzelm@5403
    56
      ;;
wenzelm@6417
    57
    k)
wenzelm@11125
    58
      KDE="$OPTARG"
wenzelm@6450
    59
      NO_OPTS=""
wenzelm@6417
    60
      ;;
wenzelm@6417
    61
    p)
wenzelm@6417
    62
      BINDIR="$OPTARG"
wenzelm@6450
    63
      NO_OPTS=""
wenzelm@6417
    64
      ;;
aspinall@15733
    65
    a)
aspinall@15733
    66
      RDISTDIR="$OPTARG"
aspinall@15733
    67
      NO_OPTS=""
aspinall@15733
    68
      ;;
wenzelm@5403
    69
    \?)
wenzelm@5403
    70
      usage
wenzelm@5403
    71
      ;;
wenzelm@5403
    72
  esac
wenzelm@5403
    73
done
wenzelm@5362
    74
wenzelm@5403
    75
shift $(($OPTIND - 1))
wenzelm@5403
    76
wenzelm@5403
    77
wenzelm@5403
    78
# args
wenzelm@5403
    79
wenzelm@9788
    80
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    81
aspinall@15733
    82
if [ -z "$RDISTDIR" ]; then
aspinall@15733
    83
  RDISTDIR=$DISTDIR
aspinall@15733
    84
fi
wenzelm@5362
    85
wenzelm@5362
    86
## main
wenzelm@5362
    87
wenzelm@6459
    88
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    89
wenzelm@6417
    90
wenzelm@6417
    91
# standalone binaries
wenzelm@5362
    92
wenzelm@6082
    93
#set by configure
skalberg@15574
    94
AUTO_BASH=/bin/bash
wenzelm@10555
    95
wenzelm@10555
    96
case "$AUTO_BASH" in
wenzelm@10555
    97
  /*)
wenzelm@10555
    98
    BASH="$AUTO_BASH"
wenzelm@10555
    99
    ;;
wenzelm@10555
   100
  *)
wenzelm@10555
   101
    BASH="/usr/bin/env bash"
wenzelm@10555
   102
    ;;
wenzelm@10555
   103
esac
wenzelm@5362
   104
wenzelm@6417
   105
if [ -n "$BINDIR" ]; then
wenzelm@6417
   106
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
   107
wenzelm@11550
   108
  for NAME in isatool isabelle-process isabelle-interface
wenzelm@6417
   109
  do
wenzelm@6417
   110
    BIN="$BINDIR/$NAME"
aspinall@15733
   111
    DIST="$RDISTDIR/bin/$NAME"
wenzelm@6417
   112
    echo "installing $BIN"
wenzelm@10555
   113
    echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
   114
    echo >> "$BIN"
wenzelm@9788
   115
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
   116
    chmod +x "$BIN"
wenzelm@6417
   117
  done
wenzelm@11550
   118
  for NAME in Isabelle isabelle
wenzelm@11550
   119
  do
wenzelm@11550
   120
    BIN="$BINDIR/$NAME"
wenzelm@11550
   121
    DIST="$DISTDIR/bin/$NAME"
wenzelm@11550
   122
    echo "installing $BIN"
wenzelm@11550
   123
    cp "$DIST" "$BIN" || fail "Cannot write file: $BIN"
wenzelm@11550
   124
    chmod +x "$BIN"
wenzelm@11550
   125
  done
wenzelm@6417
   126
fi
wenzelm@6417
   127
wenzelm@6417
   128
wenzelm@11125
   129
# install KDE 1.x / 2.x application icon
wenzelm@5403
   130
wenzelm@11125
   131
if [ -n "$KDE" ]; then
wenzelm@11125
   132
  if [ "$KDE" = 1 ]; then
wenzelm@11125
   133
    KDEHOME=~/.kde
wenzelm@11125
   134
    KDEDESKTOP=~/Desktop
wenzelm@11125
   135
    KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
wenzelm@11125
   136
  elif [ "$KDE" = 2 ]; then
wenzelm@11125
   137
    KDEHOME=~/.kde2
wenzelm@11125
   138
    KDEDESKTOP=~/KDesktop
wenzelm@11125
   139
    KDEAPP="$KDEDESKTOP/Isabelle.desktop"
wenzelm@11125
   140
  else
wenzelm@11125
   141
    fail "Unknown KDE version \"$KDE\""
wenzelm@11125
   142
  fi
wenzelm@11127
   143
  mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
wenzelm@6417
   144
wenzelm@11125
   145
  KDEICONS="$KDEHOME/share/icons"
wenzelm@9788
   146
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   147
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   148
wenzelm@9788
   149
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   150
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   151
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   152
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   153
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   154
wenzelm@6417
   155
  echo "installing $KDEAPP"
wenzelm@9788
   156
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   157
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   158
  echo "Type=Application" >> "$KDEAPP"
aspinall@15733
   159
  echo "Exec=\"$RDISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
wenzelm@9788
   160
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   161
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   162
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   163
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   164
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   165
fi