Merge pull request #457 from vivien/text-variable
[tig.git] / tools / install.sh
blob89cd969fbc0786573c192a12d5ce79d4613f9cb5
1 #!/bin/sh
3 # Install data or executable file.
5 # Usage: $0 {data|bin} src dest
7 # Copyright (c) 2014 Jonas Fonseca <jonas.fonseca@gmail.com>
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 set -e
21 data="$1"
22 src="$2"
23 dest="$3"
24 mode=0755
25 trash=
27 case "$data" in data)
28 mode=0644
29 esac
31 install -d "$dest"
33 if [ "$V" = "@" ]; then
34 echo "$src -> $dest"
37 # Replace fake /etc-path
38 case "$src" in doc/*)
39 dest="$dest/$(basename "$src")"
40 sed "s#++SYSCONFDIR++#${sysconfdir}#" < "$src" > "$src+"
41 trash="$src+"
42 src="$src+"
43 esac
45 install -p -m "$mode" "$src" "$dest"
47 if [ -n "$trash" ]; then
48 rm -f "$trash"