Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_rtl_install.subr

Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_rtl_install() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _verbose _prefix _ln_target _ln_fname _mkdir_fname	\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_file_fname_src _file_fname_dst;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ "${1}" = "-v" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_verbose=1; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi; _prefix="${1}"; shift;
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 (arab, vxp) ec19f0
	@*=*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_ln_target="${1%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_ln_target="${_ln_target#@}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_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 (arab, vxp) ec19f0
			ex_rtl_fileop rm "${_ln_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_fileop ln_symbolic "${_ln_target}" "${_ln_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	/=*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_mkdir_fname="${1#/=}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			_mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_fileop mkdir "${_mkdir_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_file_fname_src="${1%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_file_fname_dst="${1#*=}";
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 (arab, vxp) ec19f0
		ex_rtl_fileop cp "${_file_fname_src}" "${_file_fname_dst}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		;;
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