midipix / 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) 792796
prepend_path /bin;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
if [ "${1}" = -h ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	echo "usage: $0 [drive_letter [dirname]]"; exit 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
elif [ ${#} -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	PWD_ABSOLUTE="$(cygpath -am .)" || exit 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	MIDIPIX_DRIVE="${PWD_ABSOLUTE%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	MIDIPIX_PNAME="${PWD_ABSOLUTE#${MIDIPIX_DRIVE}:}";
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
	unset PWD_ABSOLUTE;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
else
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	MIDIPIX_DRIVE="${1}"; MIDIPIX_PNAME="${2}";
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) 792796
if [ "${MIDIPIX_DRIVE#*[ 	]*}" != "${MIDIPIX_DRIVE}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
|| [ "${MIDIPIX_PNAME#*[ 	]*}" != "${MIDIPIX_PNAME}" ]; 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) 792796
MIDIPIX_PATH=/${MIDIPIX_DRIVE}${MIDIPIX_PNAME:+/${MIDIPIX_PNAME#/}};
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
MIDIPIX_PATH=${MIDIPIX_PATH%/};
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
if [ ! -d /proc/cygdrive${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) 92d6c5
else
Lucio Andrés Illanes Albornoz (arab, vxp) 30e09b
	if [ -f /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.log ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 30e09b
		echo Found libpsxscl.log, copying to /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.last.
Lucio Andrés Illanes Albornoz (arab, vxp) 30e09b
		cp /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.log	\
Lucio Andrés Illanes Albornoz (arab, vxp) 30e09b
			/proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.last || exit 5;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	echo "Midipix drive letter.....: ${MIDIPIX_DRIVE}";
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
	echo "Midipix pathname.........: ${MIDIPIX_PNAME}";
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) 92d6c5
	mintty -h always -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) 92d6c5
		cd ${MIDIPIX_PATH}/native/bin;
Lucio Andrés Illanes Albornoz (arab, vxp) 544267
		export PATH=/proc/cygdrive${MIDIPIX_PATH}/native/bin:/proc/cygdrive${MIDIPIX_PATH}/native/lib;
Lucio Andrés Illanes Albornoz (arab, vxp) d9bee1
		./ntctty.exe -e chroot //${MIDIPIX_PATH#/}/native /bin/bash" &
Lucio Andrés Illanes Albornoz (arab, vxp) 92d6c5
fi;