summaryrefslogtreecommitdiff
path: root/chromium/third_party/lcov/bin/install.sh
blob: 27140f91dd18b1ae3eab10a61f1c262854176355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# install.sh [--uninstall] sourcefile targetfile [install options]
#


# Check for uninstall option
if test "x$1" == "x--uninstall" ; then
  UNINSTALL=true
  SOURCE=$2
  TARGET=$3
  shift 3
else
  UNINSTALL=false
  SOURCE=$1
  TARGET=$2
  shift 2
fi

# Check usage
if test -z "$SOURCE" || test -z "$TARGET" ; then
  echo Usage: install.sh [--uninstall] source target [install options] >&2
  exit 1
fi


#
# do_install(SOURCE_FILE, TARGET_FILE)
#

do_install()
{
  local SOURCE=$1
  local TARGET=$2
  local PARAMS=$3

  install -p -D $PARAMS $SOURCE $TARGET
}


#
# do_uninstall(SOURCE_FILE, TARGET_FILE)
#

do_uninstall()
{
  local SOURCE=$1
  local TARGET=$2

  # Does target exist?
  if test -r $TARGET ; then
    # Is target of the same version as this package?
    if diff $SOURCE $TARGET >/dev/null; then
      rm -f $TARGET
    else
      echo WARNING: Skipping uninstall for $TARGET - versions differ! >&2
    fi
  else
    echo WARNING: Skipping uninstall for $TARGET - not installed! >&2
  fi
}


# Call sub routine
if $UNINSTALL ; then
  do_uninstall $SOURCE $TARGET
else
  do_install $SOURCE $TARGET "$*"
fi

exit 0