<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch release-2.4
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/ddc80322b67dee34fad825bc585659b7416c9ec2">https://github.com/macports/macports-base/commit/ddc80322b67dee34fad825bc585659b7416c9ec2</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit ddc80322b67dee34fad825bc585659b7416c9ec2
</span>Author: Barry <barry@barrys-emacs.org>
AuthorDate: Wed Feb 1 03:00:50 2017 +0000
<span style='display:block; white-space:pre;color:#404040;'> Fix the detection of /opt/local/bin in user's PATH (#16)
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The postflight script was using the SHELL variable, which is root's shell
</span><span style='display:block; white-space:pre;color:#404040;'> and not USHELL, which is the user's shell. Use full path of the user's
</span><span style='display:block; white-space:pre;color:#404040;'> shell for USHELL.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The test for MacPorts paths in the users PATH can be made more robust.
</span><span style='display:block; white-space:pre;color:#404040;'> The old code will match on /opt/locale for example.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Spit the PATH into one path per line with tr and then grep for an exact match
</span><span style='display:block; white-space:pre;color:#404040;'> with /opt/local/bin.
</span><span style='display:block; white-space:pre;color:#404040;'> (cherry picked from commit dcb07880b7e8a47a62ddd09b29ed00d02a373e82)
</span>---
portmgr/dmg/postflight.in | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/portmgr/dmg/postflight.in b/portmgr/dmg/postflight.in
</span><span style='display:block; white-space:pre;color:#808080;'>index a5b0ac2..a2e23d4 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/portmgr/dmg/postflight.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/portmgr/dmg/postflight.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -209,13 +209,16 @@ delete_old_tcl_packages
</span>
# Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
# Exit nicely if the shell is any other than bash or tcsh, as that's considered non-standard.
<span style='display:block; white-space:pre;background:#ffe0e0;'>-USHELL=$(${DSCL} . -read "/Users/${USER}" shell | awk -F'/' '{print $NF}') || {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+USHELL=$(${DSCL} . -read "/Users/${USER}" shell) || {
</span> echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
update_macports
exit 1
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# leave full path to shell
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+USHELL=${USHELL#*shell: }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> case "${USHELL}" in
<span style='display:block; white-space:pre;background:#ffe0e0;'>- tcsh)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */tcsh)
</span> echo "Detected the tcsh shell."
LOGIN_FLAG=""
ENV_COMMAND="setenv"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -228,7 +231,7 @@ case "${USHELL}" in
</span> CONF_FILE=tcshrc
fi
;;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- bash)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */bash)
</span> echo "Detected the bash shell."
LOGIN_FLAG="-l"
ENV_COMMAND="export"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -250,16 +253,16 @@ esac
</span>
# Adding our setting to the PATH variable if not already there:
<span style='display:block; white-space:pre;background:#ffe0e0;'>-if "${SHELL}" ${LOGIN_FLAG} -c "/usr/bin/printenv PATH" | grep "${PREFIX}" > /dev/null; then
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if "${USHELL}" ${LOGIN_FLAG} -c "/usr/bin/printenv PATH" | tr ":" "\n" | grep "^${BINPATH}$" > /dev/null; then
</span> echo "Your shell already has the right PATH environment variable for use with MacPorts!"
else
write_setting PATH "\"${BINPATH}:${SBINPATH}:\$PATH\""
fi
# We gather the path into a variable of our own for faster operation:
<span style='display:block; white-space:pre;background:#ffe0e0;'>-ORIGINAL_MANPATH="$("${SHELL}" ${LOGIN_FLAG} -c "/usr/bin/printenv MANPATH")"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ORIGINAL_MANPATH="$("${USHELL}" ${LOGIN_FLAG} -c "/usr/bin/printenv MANPATH")"
</span> # Adding our setting to the MANPATH variable only if it exists:
<span style='display:block; white-space:pre;background:#ffe0e0;'>-if ! "${SHELL}" ${LOGIN_FLAG} -c "/usr/bin/env | grep MANPATH" > /dev/null || \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if ! "${USHELL}" ${LOGIN_FLAG} -c "/usr/bin/env | grep MANPATH" > /dev/null || \
</span> # and following that, if it's not empty:
[[ -z "${ORIGINAL_MANPATH}" ]] || \
# or if it doesn't already contain our path:
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -276,7 +279,7 @@ else
</span> fi
# Adding a DISPLAY variable only if we're running on Tiger or less and if it doesn't already exist:
<span style='display:block; white-space:pre;background:#ffe0e0;'>-if (($(sw_vers -productVersion | awk -F . '{print $2}') >= 5)) || "${SHELL}" ${LOGIN_FLAG} -c "/usr/bin/env | grep DISPLAY" > /dev/null; then
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if (($(sw_vers -productVersion | awk -F . '{print $2}') >= 5)) || "${USHELL}" ${LOGIN_FLAG} -c "/usr/bin/env | grep DISPLAY" > /dev/null; then
</span> echo "Your shell already has the right DISPLAY environment variable for use with MacPorts!"
else
write_setting DISPLAY ":0"
</pre><pre style='margin:0'>
</pre>