|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
# set +o errexit -o noglob -o nounset is assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_install() {
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
local _verbose="" _prefix="" _chmod_mode="" _dname="" _file_fname_dst="" \
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_src="" _fname="" _ln_fname="" _ln_target="" _owner_spec="" \
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_pname="";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
[ "${1}" = "-v" ] && { _verbose=1; shift; }; _prefix="${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
while [ ${#} -gt 0 ]; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
case "${1}" in
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
-*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_pname="${1#-}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if [ "${_pname#/}" = "${_pname}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_pname="${_prefix:+${_prefix}/}${_pname}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if ! rtl_fileop rm "${_pname}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
!*=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_src="${1#!}"; _file_fname_src="${_file_fname_src%=*}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_dst="${1#!}"; _file_fname_dst="${_file_fname_dst#*=}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if ! rtl_fileop mv "${_file_fname_src}" "${_file_fname_dst}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
/=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_dname="${1#/=}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if [ "${_dname#/}" = "${_dname}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_dname="${_prefix:+${_prefix}/}${_dname}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if ! rtl_fileop mkdir "${_dname}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
@*=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_ln_target="${1%=*}"; _ln_target="${_ln_target#@}"; _ln_fname="${1#*=}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ "${_ln_fname#/}" = "${_ln_fname}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_ln_fname="${_prefix:+${_prefix}/}${_ln_fname}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${_ln_fname}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop rm "${_ln_fname}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
7bfc1e |
if ! rtl_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; then
|
|
Lucio Andrés Illanes Albornoz |
7bfc1e |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
m[0-7][0-7][0-7][0-7]=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_fname="${1#m[0-7][0-7][0-7][0-7]=}"; _chmod_mode="${1%%=*}"; _chmod_mode="${_chmod_mode#m}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if ! rtl_fileop chmod "${_chmod_mode}" "${_fname}"; then
|
|
Lucio Andrés Illanes Albornoz |
7bfc1e |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
o*=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_fname="${1#o*=}"; _owner_spec="${1%%=*}"; _owner_spec="${_owner_spec#o}";
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
if ! rtl_fileop chown "${_owner_spec}" "${_fname}"; then
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
*=*)
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
_file_fname_src="${1%=*}"; _file_fname_dst="${1#*=}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9f270b |
if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9f270b |
_file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
9f270b |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
7bfc1e |
if ! rtl_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; then
|
|
Lucio Andrés Illanes Albornoz |
7bfc1e |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
e1a474 |
fi; ;;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
esac; shift;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
# vim:filetype=sh
|