summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-09-12 18:12:51 +0200
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-09-12 18:40:56 +0200
commit222d371ae9448a5c163e3df9f58225e7f1e1f6fd (patch)
tree7027d11362ae6d8e0cdc5669f4124d4e62e00608
parent7a180c32c293e0e4d91fae0580aaea4cd5b5ad97 (diff)
downloadmidipix_build-222d371ae9448a5c163e3df9f58225e7f1e1f6fd.tar.bz2
midipix_build-222d371ae9448a5c163e3df9f58225e7f1e1f6fd.tar.xz
Adds midipix_check.sh and a simplified midipix.sh.
-rw-r--r--998.midipix_sh.build2
-rwxr-xr-xmidipix.sh142
-rwxr-xr-xmidipix_check.sh51
3 files changed, 86 insertions, 109 deletions
diff --git a/998.midipix_sh.build b/998.midipix_sh.build
index a44b7c93..f6a9c22d 100644
--- a/998.midipix_sh.build
+++ b/998.midipix_sh.build
@@ -4,7 +4,7 @@
if ! is_build_script_done install; then
(cd ${MIDIPIX_BUILD_PWD};
- tar -cpf - midipix.sh README \
+ tar -cpf - midipix_check.sh midipix.sh README \
'Create `Midipix mintty shell'\'' shortcut.vbs' |\
tar -C ${PREFIX} -xpf -);
chmod +x ${PREFIX}/midipix.sh;
diff --git a/midipix.sh b/midipix.sh
index f40f2c53..65913c40 100755
--- a/midipix.sh
+++ b/midipix.sh
@@ -1,114 +1,40 @@
#!/bin/sh
-#
-prepend_path() {
- local _pname _pname_prepend="${1}" IFS=":";
- for _pname in ${PATH}; do
- if [ "${_pname}" = "${_pname_prepend}" ]; then
- return;
- fi;
- 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 6; ;;
- 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 ${MIDIPIX_DNAME_ROOT}/bin/ntctty.exe \
- ${MIDIPIX_DNAME_ROOT}/bin/chroot \
- ${MIDIPIX_DNAME_ROOT}/bin/env \
- ${MIDIPIX_DNAME_ROOT}/bin/bash; do
- if [ ! -e ${MIDIPIX_PATH}/${_fname} ]; then
- return 1;
- fi;
- done;
-};
-
-prepend_path /bin;
-while [ ${#} -gt 0 ]; do
- if [ "${1}" = -h ]; then
- echo "usage: $0 [-h] [-l] [-m] [Cygwin pathname to Midipix root]";
- echo " -l: tail(1) -f libpsxscl.log";
- echo " -m: use Minipix root";
- exit 0;
- elif [ "${1}" = -l ]; then
- ARG_TAILF_LOG=1; shift;
- elif [ "${1}" = -m ]; then
- ARG_MINIPIX=1; shift;
- MIDIPIX_DNAME_ROOT=minipix;
- elif [ "${1#-}" = "${1}" ]; then
- MIDIPIX_PATH="${1}";
- fi;
-done;
-if [ -z "${MIDIPIX_PATH}" ]; then
- MIDIPIX_PATH="$(cygpath -am .)" || exit 1;
-fi;
-UNAME_OS="$(uname -o)" || exit 2;
-if [ "${MIDIPIX_PATH#*[ ]*}" != "${MIDIPIX_PATH}" ]; then
- echo "Error: drive_letter/dirname must not contain SP (\` ') or VT (\`\\\t') characters.";
- exit 3;
-elif [ ! -d ${MIDIPIX_PATH} ]; then
- echo "Error: Midipix path non-existent or invalid (\`${MIDIPIX_PATH}'.)";
- exit 4;
-elif [ -z "${MIDIPIX_DNAME_ROOT}" ]; then
- if [ -e ${MIDIPIX_PATH}/native ]; then
- MIDIPIX_DNAME_ROOT=native;
- elif [ -e ${MIDIPIX_PATH}/minipix ]; then
- MIDIPIX_DNAME_ROOT=minipix;
- else
- echo "Error: neither \`${MIDIPIX_PATH}/native' nor \`${MIDIPIX_PATH}/minipix' exist.";
- exit 5;
- fi;
+set -o noglob;
+if [ -z "${PATH##/bin:*}" \
+-a -z "${PATH##*:/bin:*}" \
+-a -z "${PATH##*:/bin}" ]; then
+ export PATH="/bin${PATH:+:${PATH}}";
fi;
-if [ \( "${ARG_MINIPIX:-0}" -eq 0 \) -a \
- \( -n "${NATIVE_LIB_LINKS:=$(find ${MIDIPIX_PATH}/native/lib -maxdepth 1 -name \*.so -type l -print -quit)}" \) ]; then
- convert_links_ask || exit 7;
+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
- check_prereq_files || exit 8;
- if [ -f ${MIDIPIX_PATH}/libpsxscl.log ]; then
- echo Found libpsxscl.log, copying to ${MIDIPIX_PATH}/libpsxscl.last.
- cp -p -- ${MIDIPIX_PATH}/libpsxscl.log \
- ${MIDIPIX_PATH}/libpsxscl.last || exit 9;
- fi;
- echo "Absolute Midipix pathname: ${MIDIPIX_PATH}";
- if [ "${UNAME_OS}" = "Msys" ]; then
- export MSYS2_ARG_CONV_EXCL="*";
- fi;
- mintty -h always -s 120,80 -e /bin/sh -c "
- set -o errexit; stty raw -echo;
- cd ${MIDIPIX_PATH}; \
- env PATH=${MIDIPIX_PATH}/${MIDIPIX_DNAME_ROOT}/lib \
- ${MIDIPIX_DNAME_ROOT}/bin/ntctty.exe -e \
- chroot ${MIDIPIX_DNAME_ROOT} \
- /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 [ ${ARG_TAILF_LOG:-0} -eq 1 ]; then
- tail -f ${MIDIPIX_PATH}/${MIDIPIX_DNAME_ROOT}/bin/libpsxscl.log;
+ MIDIPIX_PATH:=$(cygpath -am .);
+fi;
+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
+ echo "(cp(1) returned ${?}, ignored.)";
fi;
fi;
+if [ "$(uname -o)" = "Msys" ]; then
+ 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} \
+ /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}')";
+
+# vim:filetype=sh
diff --git a/midipix_check.sh b/midipix_check.sh
new file mode 100755
index 00000000..f669de44
--- /dev/null
+++ b/midipix_check.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+set -o errexit -o noglob;
+if [ "${1}" = "-m" ]; then
+ MIDIPIX_DNAME_DIST=minipix; shift;
+fi;
+if [ -n "${1}" ]; then
+ MIDIPIX_PATH=$(cygpath -am "${1}");
+else
+ MIDIPIX_PATH=$(cygpath -am .);
+fi;
+: ${MIDIPIX_DNAME_DIST:=native};
+echo "Absolute Midipix pathname: ${MIDIPIX_PATH}";
+echo "Distribution name : ${MIDIPIX_DNAME_DIST}";
+printf "%-85s" "Checking if all binaries are present...";
+for __ in chroot env ntctty.exe; do
+ if [ ! -e ${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/bin/${__} ]; then
+ printf "\nerror: missing file ${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/bin/${__}\n";
+ exit 2;
+ fi;
+done;
+printf "\033[97m[ \033[92mOK \033[97m]\033[0m\n";
+printf "%-85s" "Checking ${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/lib for symbolic links...";
+if [ -n "$(find ${MIDIPIX_DNAME_DIST}/lib \
+ -maxdepth 1 -name \*.so -type l -print -quit)" ]; then
+ echo;
+ echo "Warning: ${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/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 3; ;;
+ esac;
+ for LINK_NAME in $(find ${MIDIPIX_PATH}/${MIDIPIX_DNAME_DIST}/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;
+fi;
+printf "\033[97m[ \033[92mOK \033[97m]\033[0m\n";
+
+# vim:filetype=sh