-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·55 lines (50 loc) · 1.29 KB
/
install.sh
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
#!/usr/bin/env bash
set -ue
readonly THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%N}}")" && pwd)"
readonly BINMODE=755
readonly LIBMODE=644
readonly SRCMODE=644
readonly PREFIX="${1:-/usr/local}"
readonly PREFIX_BIN="${PREFIX}/bin"
readonly PREFIX_LIB="${PREFIX}/lib/egzact"
readonly PREFIX_SRC="${PREFIX}/lib/egzact/src"
_installbin () {
local _mode="$1" ;shift
local _src="$1" ;shift
local _dst="$1" ;shift
cat <<TEMPLATE > "${_dst}"
#!/bin/bash
exec egison ${_src} -- \$@
TEMPLATE
chmod "${_mode}" "${_dst}"
}
_install () {
local _mode="$1" ;shift
local _src="$1" ;shift
local _dst="$1" ;shift
echo "sed \"1,3s:\\.\\.:${PREFIX}:\" \"${_src}\" > \"${_dst}\""
sed "1,3s:\\.\\.:${PREFIX}:" "${_src}" > "${_dst}"
chmod "${_mode}" "${_dst}"
}
# Install (bin/src)
echo install -d "${PREFIX_SRC}"
install -d "${PREFIX_SRC}"
echo install -d "${PREFIX_BIN}"
install -d "${PREFIX_BIN}"
{
cd "${THIS_DIR}/bin"
for _file in *.egi ;do
_src="${PREFIX_SRC}/${_file}"
_install "${SRCMODE}" "${_file}" "${_src}"
_installbin "${BINMODE}" "${_src}" "${PREFIX_BIN}/${_file/.egi}"
done
}
# Install (lib)
echo install -d "${PREFIX_LIB}"
install -d "${PREFIX_LIB}"
{
cd "${THIS_DIR}/lib/egzact"
for _file in *.egi ;do
_install "${LIBMODE}" "${_file}" "${PREFIX_LIB}/${_file}"
done
}