summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-06-27 18:43:41 +0200
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-06-27 18:43:41 +0200
commit77171dc9e46707351014190ef7bf2fbefe1921a7 (patch)
treea4294f8f545503c65dca8ec5cb7cc2ddc31a91ce
parenta9b6f174b5eb33f49956a884b42a6bef6296ac4c (diff)
downloadmidipix_build-77171dc9e46707351014190ef7bf2fbefe1921a7.tar.bz2
midipix_build-77171dc9e46707351014190ef7bf2fbefe1921a7.tar.xz
midipix.sh:
- Detect if ${MIDIPIX_PATH}/native/lib contains shared objects that are symbolic links and offer to convert them to hard links. As this has been a problem numerous times before, midipix.sh now explicitly handles this. - Launch mintty w/ the ntctty default of 80 rows and 120 columns. - Only handle Cygwin pathnames, be they absolute or relative. - Print the ntctty PID 0.25 seconds after launching it and optionally tail(1) -f ${MIDIPIX_PATH}/native/bin/libpsxscl.log if -l was specified, both to aid debugging. - Sanity-check ${MIDIPIX_PATH}/native/bin for required binaries. - Simplify the Midipix shell invocation command sequence; ${PATH} is now initialised to `/bin:/lib' only, absolute pathnames are only used for ${MIDIPIX_PATH}/native/lib in order to launch ntctty.
-rwxr-xr-xmidipix.sh88
1 files changed, 66 insertions, 22 deletions
diff --git a/midipix.sh b/midipix.sh
index e36656db..a800acc6 100755
--- a/midipix.sh
+++ b/midipix.sh
@@ -10,43 +10,87 @@ prepend_path() {
done; export PATH="${_pname_prepend}${PATH:+:${PATH}}";
};
+convert_links_ask() {
+ local _ _link_name _link_target;
+ echo "Warning: ${MIDIPIX_PATH}/native/lib contains shared objects (library"
+ echo "images) that are symbolic links. This is not supported by Midipix at"
+ echo "present and commonly occurs if the binary distribution tarball was"
+ echo "extracted by an application that does not support symbolic links"
+ echo "correctly. This also occurs when a binary distribution was built locally."
+ printf "Convert all shared object symbolic links to hard links? (y|N) ";
+ read _;
+ case "${_}" in
+ [yY]) break; ;;
+ *) echo "Exiting."; exit 5; ;;
+ esac;
+ for _link_name in $(find ${MIDIPIX_PATH}/native/lib \
+ -maxdepth 1 -name \*.so -type l); do
+ _link_target="$(readlink -- "${_link_name}")";
+ if [ -f "${MIDIPIX_PATH}/native/lib/${_link_target}" ]; then
+ echo rm -f -- "${_link_name}";
+ rm -f -- "${_link_name}";
+ echo ln -f -- "${_link_target}" "${_link_name}";
+ ln -f -- "${_link_target}" "${_link_name}";
+ fi;
+ done;
+};
+
+check_prereq_files() {
+ local _fname;
+ for _fname in native/bin/ntctty.exe \
+ native/bin/chroot \
+ native/bin/env \
+ native/bin/bash; do
+ if [ ! -e ${MIDIPIX_PATH}/${_fname} ]; then
+ return 1;
+ fi;
+ done;
+};
+
prepend_path /bin;
if [ "${1}" = -h ]; then
- echo "usage: $0 [drive_letter [dirname]]"; exit 0;
-elif [ ${#} -eq 0 ]; then
- PWD_ABSOLUTE="$(cygpath -am .)" || exit 1;
- MIDIPIX_DRIVE="${PWD_ABSOLUTE%:*}";
- MIDIPIX_PNAME="${PWD_ABSOLUTE#${MIDIPIX_DRIVE}:}";
- unset PWD_ABSOLUTE;
+ echo "usage: $0 [Cygwin pathname to Midipix root]"; exit 0;
+elif [ "${1}" = -l ]; then
+ TAILF_LOG=1; shift;
+fi;
+if [ ${#} -eq 0 ]; then
+ MIDIPIX_PATH="$(cygpath -am .)" || exit 1;
else
- MIDIPIX_DRIVE="${1}"; MIDIPIX_PNAME="${2}";
+ MIDIPIX_PATH="${1}";
fi;
UNAME_OS="$(uname -o)" || exit 2;
-if [ "${MIDIPIX_DRIVE#*[ ]*}" != "${MIDIPIX_DRIVE}" ]\
-|| [ "${MIDIPIX_PNAME#*[ ]*}" != "${MIDIPIX_PNAME}" ]; then
+if [ "${MIDIPIX_PATH#*[ ]*}" != "${MIDIPIX_PATH}" ]; then
echo "Error: drive_letter/dirname must not contain SP (\` ') or VT (\`\\\t') characters.";
exit 3;
fi;
-MIDIPIX_PATH=/${MIDIPIX_DRIVE}${MIDIPIX_PNAME:+/${MIDIPIX_PNAME#/}};
-MIDIPIX_PATH=${MIDIPIX_PATH%/};
-if [ ! -d /proc/cygdrive${MIDIPIX_PATH} ]; then
+if [ ! -d ${MIDIPIX_PATH} ]; then
echo "Error: Midipix path non-existent or invalid (\`${MIDIPIX_PATH}'.)";
exit 4;
+elif [ -n "${NATIVE_LIB_LINKS:=$(find ${MIDIPIX_PATH}/native/lib -maxdepth 1 -name \*.so -type l -print -quit)}" ]; then
+ convert_links_ask || exit 5;
else
- if [ -f /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.log ]; then
- echo Found libpsxscl.log, copying to /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.last.
- cp /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.log \
- /proc/cygdrive${MIDIPIX_PATH}/native/bin/libpsxscl.last || exit 5;
+ check_prereq_files || exit 6;
+ if [ -f ${MIDIPIX_PATH}/native/bin/libpsxscl.log ]; then
+ echo Found libpsxscl.log, copying to ${MIDIPIX_PATH}/native/bin/libpsxscl.last.
+ cp ${MIDIPIX_PATH}/native/bin/libpsxscl.log \
+ ${MIDIPIX_PATH}/native/bin/libpsxscl.last || exit 7;
fi;
- echo "Midipix drive letter.....: ${MIDIPIX_DRIVE}";
- echo "Midipix pathname.........: ${MIDIPIX_PNAME}";
echo "Absolute Midipix pathname: ${MIDIPIX_PATH}";
if [ "${UNAME_OS}" = "Msys" ]; then
export MSYS2_ARG_CONV_EXCL="*";
fi;
- mintty -h always -e /bin/sh -c "
+ mintty -h always -s 120,80 -e /bin/sh -c "
set -o errexit; stty raw -echo;
- cd ${MIDIPIX_PATH}/native/bin;
- export PATH=/proc/cygdrive${MIDIPIX_PATH}/native/bin:/proc/cygdrive${MIDIPIX_PATH}/native/lib;
- ./ntctty.exe -e chroot //${MIDIPIX_PATH#/}/native /bin/bash" &
+ cd ${MIDIPIX_PATH}; \
+ env PATH=${MIDIPIX_PATH}/native/lib \
+ native/bin/ntctty.exe -e \
+ chroot native \
+ /bin/env PATH=/bin:/lib \
+ bash" &
+ sleep 0.25;
+ NTCTTY_PID="$(ps -W | awk '$NF ~ /ntctty\.exe$/{print $1}')";
+ echo "ntctty PID : ${NTCTTY_PID}";
+ if [ ${TAILF_LOG:-0} -eq 1 ]; then
+ tail -f ${MIDIPIX_PATH}/native/bin/libpsxscl.log;
+ fi;
fi;