Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame midipix.sh

Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
#!/bin/sh
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
#
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
prepend_path() {
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	local _pname _pname_prepend="${1}" IFS=":";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	for _pname in ${PATH}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
		if [ "${_pname}" = "${_pname_prepend}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
			return;
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	done; export PATH="${_pname_prepend}${PATH:+:${PATH}}";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
};
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
convert_links_ask() {
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	local _ _link_name _link_target;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "Warning: ${MIDIPIX_PATH}/native/lib contains shared objects (library"
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "images) that are symbolic links. This is not supported by Midipix at"
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "present and commonly occurs if the binary distribution tarball was"
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "extracted by an application that does not support symbolic links"
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "correctly. This also occurs when a binary distribution was built locally."
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	printf "Convert all shared object symbolic links to hard links? (y|N) ";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	read _;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	case "${_}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		[yY])	break; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		*)	echo "Exiting."; exit 5; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
	for _link_name in $(find ${MIDIPIX_PATH}/native/lib	\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			-maxdepth 1 -name \*.so -type l); do
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		_link_target="$(readlink -- "${_link_name}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		if [ -f "${MIDIPIX_PATH}/native/lib/${_link_target}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			echo rm -f -- "${_link_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			rm -f -- "${_link_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			echo ln -f -- "${_link_target}" "${_link_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			ln -f -- "${_link_target}" "${_link_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
};
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
check_prereq_files() {
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	local _fname;
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
	for _fname in	native/bin/ntctty.exe			\
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
			native/bin/chroot			\
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
			native/bin/env				\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			native/bin/bash; do
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		if [ ! -e ${MIDIPIX_PATH}/${_fname} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
};
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
prepend_path /bin;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
if [ "${1}" = -h ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "usage: $0 [Cygwin pathname to Midipix root]"; exit 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
elif [ "${1}" = -l ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	TAILF_LOG=1; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
if [ ${#} -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	MIDIPIX_PATH="$(cygpath -am .)" || exit 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
else
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	MIDIPIX_PATH="${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
UNAME_OS="$(uname -o)" || exit 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
if [ "${MIDIPIX_PATH#*[ 	]*}" != "${MIDIPIX_PATH}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	echo "Error: drive_letter/dirname must not contain SP (\` ') or VT (\`\\\t') characters.";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	exit 3;
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
if [ ! -d ${MIDIPIX_PATH} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	echo "Error: Midipix path non-existent or invalid (\`${MIDIPIX_PATH}'.)";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	exit 4;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
elif [ -n "${NATIVE_LIB_LINKS:=$(find ${MIDIPIX_PATH}/native/lib -maxdepth 1 -name \*.so -type l -print -quit)}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	convert_links_ask || exit 5;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
else
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	check_prereq_files || exit 6;
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
	if [ -f ${MIDIPIX_PATH}/libpsxscl.log ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		echo Found libpsxscl.log, copying to ${MIDIPIX_PATH}/libpsxscl.last.
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		cp -p -- ${MIDIPIX_PATH}/libpsxscl.log		\
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
			${MIDIPIX_PATH}/libpsxscl.last || exit 7;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	echo "Absolute Midipix pathname: ${MIDIPIX_PATH}";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	if [ "${UNAME_OS}" = "Msys" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
		export MSYS2_ARG_CONV_EXCL="*";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	mintty -h always -s 120,80 -e /bin/sh -c "
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
		set -o errexit; stty raw -echo;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		cd ${MIDIPIX_PATH};				\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		env PATH=${MIDIPIX_PATH}/native/lib		\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		native/bin/ntctty.exe -e			\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			chroot native				\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			/bin/env PATH=/bin:/lib			\
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
			bash" &
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	sleep 0.25;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	NTCTTY_PID="$(ps -W | awk '$NF ~ /ntctty\.exe$/{print $1}')";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	echo "ntctty PID               : ${NTCTTY_PID}";
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	if [ ${TAILF_LOG:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
		tail -f ${MIDIPIX_PATH}/native/bin/libpsxscl.log;
Lucio Andrés Illanes Albornoz (arab, vxp) 77171d
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
fi;