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