-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathinstall_exe.sh
More file actions
40 lines (38 loc) · 1.2 KB
/
Copy pathinstall_exe.sh
File metadata and controls
40 lines (38 loc) · 1.2 KB
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
# install_exe: copy a file into place and make it executable
#
# ## EXAMPLE
#
# ```bash
# install_exe "${tmpdir}/mytool" "${BINDIR}/mytool"
# ```
#
# DEST is the full destination path, not a directory, and its parent must
# already exist.
#
# This exists because install(1) cannot be used portably. It is not in POSIX,
# and its grammar differs by platform: GNU and BSD accept `install SRC DST`,
# while Solaris and illumos ship the SVR4 version, which does not -- so that
# form fails outright there. cp and chmod are both POSIX.
#
# DEST is unlinked before copying: overwriting a binary that is currently
# executing fails with ETXTBSY on several systems, which is why install(1)
# unlinks first as well.
#
# DEPENDS:
# log, echoerr
#
install_exe() {
_shlib_install_src=$1
_shlib_install_dst=$2
if [ -z "$_shlib_install_src" ] || [ -z "$_shlib_install_dst" ]; then
log_err "install_exe usage: install_exe SOURCE DEST"
return 1
fi
if [ ! -f "$_shlib_install_src" ]; then
log_err "install_exe source '${_shlib_install_src}' does not exist"
return 1
fi
rm -f "$_shlib_install_dst"
cp "$_shlib_install_src" "$_shlib_install_dst" || return 1
chmod 0755 "$_shlib_install_dst" || return 1
}