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