blob: 5273a5caf155a54c4a9941023d614b9129185ce3 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de>
# set +o errexit -o noglob -o nounset is assumed.
#
rtl_install() {
local _ri_verbose="" _ri_prefix="" \
_ri_chmod_mode="" _ri_dname="" _ri_file_fname_dst="" _ri_file_fname_src="" \
_ri_fname="" _ri_ln_fname="" _ri_ln_target="" _ri_owner_spec="" _ri_pname="";
if [ "${1}" = "-v" ]; then
_ri_verbose=1; shift;
fi;
_ri_prefix="${1}"; shift;
while [ ${#} -gt 0 ]; do
case "${1}" in
-*)
_ri_pname="${1#-}";
if [ "${_ri_pname#/}" = "${_ri_pname}" ]; then
_ri_pname="${_ri_prefix:+${_ri_prefix}/}${_ri_pname}";
fi;
if ! rtl_fileop rm "${_ri_pname}"; then
return 1;
fi; ;;
!*=*)
_ri_file_fname_src="${1#!}"; _ri_file_fname_src="${_ri_file_fname_src%=*}";
_ri_file_fname_dst="${1#!}"; _ri_file_fname_dst="${_ri_file_fname_dst#*=}";
if [ "${_ri_file_fname_src#/}" = "${_ri_file_fname_src}" ]; then
_ri_file_fname_src="${_ri_prefix:+${_ri_prefix}/}${_ri_file_fname_src}";
fi;
if [ "${_ri_file_fname_dst#/}" = "${_ri_file_fname_dst}" ]; then
_ri_file_fname_dst="${_ri_prefix:+${_ri_prefix}/}${_ri_file_fname_dst}";
fi;
if ! rtl_fileop mv "${_ri_file_fname_src}" "${_ri_file_fname_dst}"; then
return 1;
fi; ;;
/=*)
_ri_dname="${1#/=}";
if [ "${_ri_dname#/}" = "${_ri_dname}" ]; then
_ri_dname="${_ri_prefix:+${_ri_prefix}/}${_ri_dname}";
fi;
if ! rtl_fileop mkdir "${_ri_dname}"; then
return 1;
fi; ;;
@*=*)
_ri_ln_target="${1%=*}"; _ri_ln_target="${_ri_ln_target#@}"; _ri_ln_fname="${1#*=}";
if [ "${_ri_ln_fname#/}" = "${_ri_ln_fname}" ]; then
_ri_ln_fname="${_ri_prefix:+${_ri_prefix}/}${_ri_ln_fname}";
fi;
if [ -e "${_ri_ln_fname}" ]; then
rtl_fileop rm "${_ri_ln_fname}";
fi;
if ! rtl_fileop ln_symbolic "${_ri_ln_target}" "${_ri_ln_fname}"; then
return 1;
fi; ;;
m[0-7][0-7][0-7][0-7]=*)
_ri_fname="${1#m[0-7][0-7][0-7][0-7]=}"; _ri_chmod_mode="${1%%=*}"; _ri_chmod_mode="${_ri_chmod_mode#m}";
if ! rtl_fileop chmod "${_ri_chmod_mode}" "${_ri_fname}"; then
return 1;
fi; ;;
o*=*)
_ri_fname="${1#o*=}"; _ri_owner_spec="${1%%=*}"; _ri_owner_spec="${_ri_owner_spec#o}";
if ! rtl_fileop chown "${_ri_owner_spec}" "${_ri_fname}"; then
return 1;
fi; ;;
*=*)
_ri_file_fname_src="${1%=*}"; _ri_file_fname_dst="${1#*=}";
if [ "${_ri_file_fname_src#/}" = "${_ri_file_fname_src}" ]; then
_ri_file_fname_src="${_ri_prefix:+${_ri_prefix}/}${_ri_file_fname_src}";
fi;
if [ "${_ri_file_fname_dst#/}" = "${_ri_file_fname_dst}" ]; then
_ri_file_fname_dst="${_ri_prefix:+${_ri_prefix}/}${_ri_file_fname_dst}";
fi;
if ! rtl_fileop cp "${_ri_file_fname_src}" "${_ri_file_fname_dst}"; then
return 1;
fi; ;;
esac; shift;
done;
return 0;
};
# vim:filetype=sh textwidth=0
|