"Fossies" - the Fresh Open Source Software Archive

Member "tmv-1.1.3/install" (30 Oct 2005, 3379 Bytes) of package /linux/privat/old/tmv-1.1.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 # copyright 2003-2005 Gene Pavlovsky <heilong@bluebottle.com>
    4 #
    5 # this is free software; you can redistribute it and/or modify
    6 # it under the terms of the GNU General Public License as published by
    7 # the Free Software Foundation; either version 2 of the License, or
    8 # (at your option) any later version.
    9 #
   10 # install/uninstall: tmv install/uninstall script.
   11 
   12 install=ginstall
   13 which "$install" &>/dev/null || install=install
   14 
   15 project=tmv
   16 version=1.1.3
   17 prefix=/usr/local
   18 bindir=$prefix/bin
   19 
   20 bin_scripts='
   21         tmv
   22         tmv-strip
   23         tmv-ul
   24         tmv-l'
   25 
   26 if ! cd $(dirname "$0"); then
   27   echo "Failed to cd to '$(dirname "$0")'." >&4
   28   exit 1
   29 fi
   30 
   31 mode=$(basename "$0")
   32 if test "$mode" != install -a "$mode" != uninstall; then
   33   echo "Must be called either as install or as uninstall."
   34   exit 1
   35 fi
   36 
   37 while test $# -gt 0; do
   38   case $1 in
   39     --*=*)
   40       optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//')
   41     ;;
   42     *)
   43       optarg=
   44     ;;
   45   esac
   46 
   47   case $1 in
   48     --prefix=*)
   49       prefix="$optarg"
   50       bindir="$prefix/bin"
   51     ;;
   52     --bindir=*)
   53       bindir="$optarg"
   54     ;;
   55     -n|--dry-run)
   56       dry_run=yes
   57     ;;
   58     --help)
   59       {
   60         echo "Usage: $0 [options]"
   61         echo
   62         echo "${mode}s $project $version."
   63         echo
   64         echo "Options:"
   65         echo -e "      --help\t\t\tprint this help, then exit"
   66         echo -e "      --version\t\t\tprint version number, then exit"
   67         echo -e "      --prefix=DIR\t\tinstallation prefix       [/usr/local]"
   68         echo -e "      --bindir=DIR\t\tuser executables          [\$prefix/bin]"
   69         echo -e "  -n, --dry-run\t\t\tdon't run any commands, just print them"
   70       } >&2
   71       exit 2
   72     ;;
   73     --version)
   74       echo "$project $version" >&2
   75       exit 2
   76     ;;
   77     *)
   78       echo "unrecognized option \"$1\"" >&2
   79       exit 1
   80     ;;
   81   esac
   82 
   83   shift
   84 done
   85 
   86 test "$mode" = install &&
   87   echo "installing $project $version to:" ||
   88   echo "uninstalling $project $version from:"
   89 echo
   90 echo "  prefix=$prefix"
   91 echo "  bindir=$bindir"
   92 echo
   93 echo -n "press enter to continue... "
   94 read
   95 echo
   96 
   97 isint()
   98 {
   99   test $# -eq 0 && return 1
  100   while test $# -gt 0; do
  101     test "$1" -eq 0 2>/dev/null
  102     test $? -eq 2 && return 1
  103     shift
  104   done
  105   return 0
  106 }
  107 
  108 strstr()
  109 {
  110   declare i=0 skip
  111   isint "$3" && skip=$3 || skip=0
  112   while test $i -le $((${#1}-${#2})); do
  113     if test "${1:i:${#2}}" = "$2"; then
  114       if test $skip -gt 0; then
  115         let --skip
  116         let ++i
  117         continue
  118       fi
  119       echo $i
  120       return 0
  121     fi
  122     let ++i
  123   done
  124   return 1
  125 }
  126 
  127 run()
  128 {
  129   test "${1:0:3}" != "sed" && eval echo "$1"
  130   test "$dry_run" = yes || eval $1
  131 }
  132 
  133 symlink_do()
  134 {
  135   pos=$(strstr "$2" '->') || return 0
  136   symlink_dest="$bindir/${2:0:$pos}"
  137   if test "$1" = install; then
  138     symlink_src="${2:$((pos+2))}"
  139     run 'ln -sf $symlink_src $symlink_dest'
  140   elif test "$1" = uninstall; then
  141     run 'rm -f $symlink_dest'
  142   fi
  143   continue
  144 }
  145 
  146 if test "$mode" = install; then
  147   run '$install -d -m 755 "$bindir"'
  148   for i in $bin_scripts; do
  149     symlink_do install $i
  150     run '$install -m 755 bin/$i.sh "$bindir/$i"'
  151     run 'sed -i -e "s/@project@/$project/g" -e "s/@version@/$version/g" "$bindir/$i"'
  152   done
  153 else
  154   for i in $bin_scripts; do
  155     symlink_do uninstall $i
  156     run 'rm -f "$bindir/$i"'
  157   done
  158   run 'rmdir "$bindir" 2>/dev/null'
  159 fi
  160 
  161 test "$mode" = uninstall && run 'rmdir "$prefix" 2>/dev/null'