| |
| |
| |
| |
| rtl_install() { |
| local _verbose="" _prefix="" _chmod_mode="" _dname="" _file_fname_dst="" \ |
| _file_fname_src="" _fname="" _ln_fname="" _ln_target="" _owner_spec="" \ |
| _pname=""; |
| [ "${1}" = "-v" ] && { _verbose=1; shift; }; _prefix="${1}"; shift; |
| |
| while [ ${#} -gt 0 ]; do |
| case "${1}" in |
| -*) |
| _pname="${1#-}"; |
| if [ "${_pname#/}" = "${_pname}" ]; then |
| _pname="${_prefix:+${_prefix}/}${_pname}"; |
| fi; |
| if ! rtl_fileop rm "${_pname}"; then |
| return 1; |
| fi; ;; |
| |
| !*=*) |
| _file_fname_src="${1#!}"; _file_fname_src="${_file_fname_src%=*}"; |
| _file_fname_dst="${1#!}"; _file_fname_dst="${_file_fname_dst#*=}"; |
| if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then |
| _file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}"; |
| fi; |
| if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then |
| _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}"; |
| fi; |
| if ! rtl_fileop mv "${_file_fname_src}" "${_file_fname_dst}"; then |
| return 1; |
| fi; ;; |
| |
| /=*) |
| _dname="${1#/=}"; |
| if [ "${_dname#/}" = "${_dname}" ]; then |
| _dname="${_prefix:+${_prefix}/}${_dname}"; |
| fi; |
| if ! rtl_fileop mkdir "${_dname}"; then |
| return 1; |
| fi; ;; |
| |
| @*=*) |
| _ln_target="${1%=*}"; _ln_target="${_ln_target#@}"; _ln_fname="${1#*=}"; |
| if [ "${_ln_fname#/}" = "${_ln_fname}" ]; then |
| _ln_fname="${_prefix:+${_prefix}/}${_ln_fname}"; |
| fi; |
| if [ -e "${_ln_fname}" ]; then |
| rtl_fileop rm "${_ln_fname}"; |
| fi; |
| if ! rtl_fileop ln_symbolic "${_ln_target}" "${_ln_fname}"; then |
| return 1; |
| fi; ;; |
| |
| m[0-7][0-7][0-7][0-7]=*) |
| _fname="${1#m[0-7][0-7][0-7][0-7]=}"; _chmod_mode="${1%%=*}"; _chmod_mode="${_chmod_mode#m}"; |
| if ! rtl_fileop chmod "${_chmod_mode}" "${_fname}"; then |
| return 1; |
| fi; ;; |
| |
| o*=*) |
| _fname="${1#o*=}"; _owner_spec="${1%%=*}"; _owner_spec="${_owner_spec#o}"; |
| if ! rtl_fileop chown "${_owner_spec}" "${_fname}"; then |
| return 1; |
| fi; ;; |
| |
| *=*) |
| _file_fname_src="${1%=*}"; _file_fname_dst="${1#*=}"; |
| if [ "${_file_fname_src#/}" = "${_file_fname_src}" ]; then |
| _file_fname_src="${_prefix:+${_prefix}/}${_file_fname_src}"; |
| fi; |
| if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then |
| _file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}"; |
| fi; |
| if ! rtl_fileop cp "${_file_fname_src}" "${_file_fname_dst}"; then |
| return 1; |
| fi; ;; |
| esac; shift; |
| done; |
| }; |
| |
| |