lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] odd/multiarch f831495 1/2: Add scripts to set enviro


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/multiarch f831495 1/2: Add scripts to set environment consistent with $LMI_HOST
Date: Mon, 8 Apr 2019 18:42:51 -0400 (EDT)

branch: odd/multiarch
commit f831495e4257527a32582bfca4ae095f6aaae488
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Add scripts to set environment consistent with $LMI_HOST
    
    See:
      https://lists.nongnu.org/archive/html/lmi/2019-04/msg00007.html
---
 run.sh      | 26 ++++++++++++++++++
 set_arch.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)

diff --git a/run.sh b/run.sh
new file mode 100755
index 0000000..79490d2
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Run a command in an environment consistent with $LMI_HOST.
+
+# Copyright (C) 2019 Gregory W. Chicares.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+# http://savannah.nongnu.org/projects/lmi
+# email: <address@hidden>
+# snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+set -e
+. ./set_arch.sh
+exec "$@"
diff --git a/set_arch.sh b/set_arch.sh
new file mode 100755
index 0000000..c5c7dd7
--- /dev/null
+++ b/set_arch.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+# Set $PATH, $WINEPATH, and $PERFORM based on $LMI_HOST.
+
+# Copyright (C) 2019 Gregory W. Chicares.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+# http://savannah.nongnu.org/projects/lmi
+# email: <address@hidden>
+# snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+# What about "$mingw_bin_dir"?
+
+# Invoke as ". ./set_paths.sh" without the quotes.
+#
+# $LMI_HOST can be overridden at the command line, e.g.:
+#   LMI_HOST="$LMI_BUILD" . ./set_paths.sh
+# That command doesn't alter the value of $LMI_HOST in the environment
+# because there's an obvious alternative that does so:
+#   LMI_HOST="$LMI_BUILD"; . ./set_paths.sh
+#
+# Perhaps $prefix should be similarly overridable.
+#
+# Implemented as a function that runs and then erases itself, so that
+# sourcing this script changes the environment only as intended. This
+# depends on 'local', which isn't yet POSIX, though there's a proposal
+# to add it:
+#   http://austingroupbugs.net/view.php?id=767
+# 'dash' and 'ash' already have 'local', so, while it's not yet POSIX,
+# it's used here, and its 'shellcheck' warning is disabled:
+# shellcheck disable=SC2039
+
+foo()
+{
+local   LMI_BUILD
+        LMI_BUILD=$(/usr/share/libtool/build-aux/config.guess)
+
+local      prefix="/opt/lmi"
+local exec_prefix="$prefix"/"$LMI_HOST"
+local localbindir="$exec_prefix"/local/bin
+local locallibdir="$exec_prefix"/local/lib
+local extrabindir=/opt/lmi/third_party/bin
+
+# Running a command like this many times:
+#   export PATH="$localbindir":"$locallibdir":"$PATH"
+# would cause $PATH to grow without bound, and the result would be
+# unreliable because setting paths for "i686..." and then, due to
+# mistyping, to "x64_86" would find 32-bit binaries where 64-bit
+# binaries were wanted.
+#
+# Therefore, the technique used to set the $minimal_path variable
+# introduced 20080428T1634Z in commit a762296122e is best for $PATH
+# here as well. Of course, this means that there is no need for a
+# distinct $minimal_path, so it can be removed here and elsewhere.
+#
+# The default non-lmi portion of this $PATH is, as always, debatable;
+# debian's default in '/etc/login.defs' adds silly 'games' directories
+# but omits '/usr/sbin' and '/sbin', for instance. The initial value
+# set in '~/.zshrc' should be made consistent with this.
+
+export PATH="$localbindir":"$locallibdir":/usr/bin:/bin:/usr/sbin:/sbin
+
+unset -v WINEPATH
+
+# double quotes inside double quotes inside $()--wrong? IOW:
+#  " $( "is this string quoted?" ) "
+case "$LMI_BUILD" in
+    (*-*-linux*)
+        w0="$(winepath -w "$localbindir" | sed -e's/\\/\\\\/g')"
+        w1="$(winepath -w "$locallibdir" | sed -e's/\\/\\\\/g')"
+        w2="$(winepath -w "$extrabindir" | sed -e's/\\/\\\\/g')"
+        export WINEPATH="$w0;$w1:$w2"
+        export  PERFORM="wine"
+        ;;
+esac
+}
+
+foo
+unset -f foo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]