midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install_files.subr

Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkgp_install_files() {
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	local _verbose _prefix _ln_target _ln_fname _mkdir_fname	\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_file_fname_src _file_fname_dst;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	if [ "${1}" = "-v" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_verbose=1; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi; _prefix="${1}"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	case "${1}" in
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	@*=*)
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_ln_target="${1%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_ln_target="${_ln_target#@}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_ln_fname="${1#*=}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		if [ "${_ln_fname#/}" = "${_ln_fname}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			_ln_fname="${_prefix:+${_prefix}/}${_ln_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		if [ -e "${_ln_fname}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			ex_build_fileop rm "${_ln_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop ln_symbolic "${_ln_target}" "${_ln_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	/=*)
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_mkdir_fname="${1#/=}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		if [ "${_mkdir_fname#/}" = "${_mkdir_fname}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			_mkdir_fname="${_prefix:+${_prefix}/}${_mkdir_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop mkdir "${_mkdir_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	*)
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_file_fname_src="${1%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_file_fname_dst="${1#*=}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		if [ "${_file_fname_dst#/}" = "${_file_fname_dst}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			_file_fname_dst="${_prefix:+${_prefix}/}${_file_fname_dst}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop cp "${_file_fname_src}" "${_file_fname_dst}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	esac; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkg_install_files() {
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	if [ ${#} -ge 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		pkgp_install_files -v "${@}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	else
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		if [ -n "${PKG_INSTALL_FILES}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 022f7e
			pkgp_install_files -v "${PKG_DESTDIR}" ${PKG_INSTALL_FILES};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# vim:filetype=sh