summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-12-09 01:44:07 +0100
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-12-09 01:44:07 +0100
commit307fd5e03d78a23e5f5c9db75c0d5b0495d870cf (patch)
tree5312f2b2864631bf89262c146f7aa90bdc34e525
parentea7997214af886326cc0494111fe98f888d93671 (diff)
downloadmidipix_build-307fd5e03d78a23e5f5c9db75c0d5b0495d870cf.tar.bz2
midipix_build-307fd5e03d78a23e5f5c9db75c0d5b0495d870cf.tar.xz
etc/midipix.sh: fixed & simplified.
-rwxr-xr-xetc/midipix.sh46
1 files changed, 26 insertions, 20 deletions
diff --git a/etc/midipix.sh b/etc/midipix.sh
index cc168d18..78ebca91 100755
--- a/etc/midipix.sh
+++ b/etc/midipix.sh
@@ -1,24 +1,29 @@
-#!/bin/sh
-
-set -o noglob;
-if [ -z "${PATH##/bin:*}" \
--a -z "${PATH##*:/bin:*}" \
--a -z "${PATH##*:/bin}" ]; then
+#!/bin/sh -f
+# Prepend /bin to ${PATH} if it does not contain it.
+if [ -z "${PATH##/bin:*}" -a -z "${PATH##*:/bin:*}" -a -z "${PATH##*:/bin}" ]; then
export PATH="/bin${PATH:+:${PATH}}";
fi;
-while getopts m __; do
-case ${__} in
-m) MIDIPIX_DNAME_DIST=minipix; ;;
-*) echo "usage: $0 [-m] [Cygwin pathname to Midipix root]";
- echo " -m: use Minipix distribution"; exit 0;
-esac; done;
-if [ -n "${1}" ]; then
- MIDIPIX_PATH=$(cygpath -am "${1}"); cd ${MIDIPIX_PATH} || exit 1;
-else
- MIDIPIX_PATH=$(cygpath -am .);
+
+#
+# Process -h/${#} > 1. Set and cd into ${MIDIPIX_PATH} from either
+# ${1} or `native,' prepended w/ ${PWD}.
+if [ "x${1}" = "x-h" ]\
+|| [ ${#} -gt 1 ]; then
+ echo "usage: $0 [-h] [path]";
+ echo "path: absolute or relative Cygwin pathname to Midipix root, e.g. minipix or native.";
+ exit 0;
+fi;
+MIDIPIX_PATH="${1:-native}";
+if [ "${1#/}" = "${1}" ]; then
+ MIDIPIX_PATH="${PWD}/${MIDIPIX_PATH}";
fi;
+cd ${MIDIPIX_PATH} || exit 1;
+
+#
+# Log variables and backup the last libpsxscl.log to libpsxscl.last.
+# Launch chroot(1)ed bash(1) inside ntctty and mintty. Obtain and
+# log the PID of the ntctty process for convenience.
printf "%-35s: %s\n" "Absolute Midipix pathname" "${MIDIPIX_PATH}";
-printf "%-35s: %s\n" "Distribution name" "${MIDIPIX_DNAME_DIST:=native}";
if [ -f libpsxscl.log ]; then
echo Found libpsxscl.log, copying to libpsxscl.last.
if ! cp -p -- libpsxscl.log libpsxscl.last; then
@@ -26,13 +31,14 @@ if [ -f libpsxscl.log ]; then
fi;
fi;
if [ "$(uname -o)" = "Msys" ]; then
+ # MingW workaround (via Elieux.)
export MSYS2_ARG_CONV_EXCL="*";
fi;
mintty -h always -s 120,80 -e /bin/sh -c "
set -o errexit;
- env PATH=${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/lib \
- ${MIDIPIX_DNAME_DIST}/bin/ntctty.exe -e \
- ${MIDIPIX_DNAME_DIST}/bin/chroot ${MIDIPIX_DNAME_DIST} \
+ env PATH=${MIDIPIX_PATH}/lib \
+ bin/ntctty.exe -e \
+ bin/chroot . \
/bin/env PATH=/bin:/lib bash" &
sleep ${SLEEP_DELAY:=0.25};
printf "%-35s: %s\n" "ntctty PID" "$(ps -W | awk '$NF ~ /ntctty\.exe$/{print $1}')";