aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronder <jsbronder@gmail.com>2009-06-26 22:08:26 -0400
committerJustin Bronder <jsbronder@gmail.com>2009-06-26 22:08:26 -0400
commitad4d1df06aa524d4037825513da7adef8eac294f (patch)
tree38ebacafabfe131e72b7cb806b5d395dfbe25cb9 /sys-cluster/empi/files
parentVersion bump (diff)
downloadsci-ad4d1df06aa524d4037825513da7adef8eac294f.tar.gz
sci-ad4d1df06aa524d4037825513da7adef8eac294f.tar.bz2
sci-ad4d1df06aa524d4037825513da7adef8eac294f.zip
Bump empi-0.6, see included changelog for details.
Diffstat (limited to 'sys-cluster/empi/files')
-rw-r--r--sys-cluster/empi/files/ChangeLog-0.686
-rw-r--r--sys-cluster/empi/files/README.txt11
-rwxr-xr-xsys-cluster/empi/files/empi-0.6407
-rw-r--r--sys-cluster/empi/files/eselect.mpi-0.6234
-rw-r--r--sys-cluster/empi/files/mpi.csh3
-rw-r--r--sys-cluster/empi/files/mpi.sh3
6 files changed, 739 insertions, 5 deletions
diff --git a/sys-cluster/empi/files/ChangeLog-0.6 b/sys-cluster/empi/files/ChangeLog-0.6
new file mode 100644
index 000000000..ddc345559
--- /dev/null
+++ b/sys-cluster/empi/files/ChangeLog-0.6
@@ -0,0 +1,86 @@
+commit e2aa61aaac8ca9dd95255f5f5aa84d2bf1a3cde0
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:52:37 2009 -0400
+
+ mpi.eclass: Update changelog
+
+commit 8daf4445fc87ccaeec9dcf5629d5d21990808ed4
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:49:38 2009 -0400
+
+ mpi.eclass: Remove dep on eselect-mpi
+
+ It's moving into the empi ebuild, so there's no way to get
+ a classed build without having it.
+
+commit ce6dad7d94ef47e498a513195e64287b07d5cc0f
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:47:22 2009 -0400
+
+ empi: Handle keywords/use for virtual/${class}
+
+commit 3f208612423f6ed66f6036aee544304f28c39992
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:33:54 2009 -0400
+
+ empi: Trap regexps to beginning of line.
+
+commit 040640d118d4020c6584050208685b8f9c6c55fb
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:32:39 2009 -0400
+
+ mpi.eclass: Fix virtual name when classed.
+
+commit b390a492636e939188a3a8c44fa8ac7b1e3e8579
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:32:05 2009 -0400
+
+ mpi.eclass: Fix syntax errors.
+
+commit 6e9465dfd27434436899d742db6dbcac9e876ca8
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 21:20:52 2009 -0400
+
+ empi.eclass: Fix calculation of invalid implementations in deplist
+
+commit 6acf8c47449f8884f4f93e9229c8a718816772e2
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 20:58:30 2009 -0400
+
+ Revert "empi.eclass: Replace MPI_PKG_NEED_IMPS with MPI_PKG_INVAL_IMPS"
+
+ This reverts commit 7430f4fa81526aa541a215cbbe6334928f8fda7f.
+
+commit 7430f4fa81526aa541a215cbbe6334928f8fda7f
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 20:49:48 2009 -0400
+
+ empi.eclass: Replace MPI_PKG_NEED_IMPS with MPI_PKG_INVAL_IMPS
+
+commit 1cd78c6504a7e082b6993b6d8474b004f6340f57
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 20:43:16 2009 -0400
+
+ mpi.eclass: Depend on the mpi virtual ebuild.
+
+commit 97ae3eb571b64cb2012872f22a11a3433230a0ef
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 20:35:43 2009 -0400
+
+ Update .gitignore
+
+commit e55047d85900ae9077f1f1e209a752d0c45b40e5
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 20:32:56 2009 -0400
+
+ empi: Create a specific virtual/mpi-${class}
+
+ To be used with the eclass so we do not need to specify every
+ implementation when calculating mpi_pkg_deps. Also allows us
+ to use USE deps.
+
+commit 288305180c3a71a8975325241a4c5bb13e07f932
+Author: Justin Bronder <jsbronder@gmail.com>
+Date: Fri Jun 26 19:26:12 2009 -0400
+
+ initial commit
diff --git a/sys-cluster/empi/files/README.txt b/sys-cluster/empi/files/README.txt
index ca195c32a..0148775fd 100644
--- a/sys-cluster/empi/files/README.txt
+++ b/sys-cluster/empi/files/README.txt
@@ -29,7 +29,7 @@ succeeded.
= Definitions =
-Implementation: Fake category name used by empi. Must be
+Class: Fake category name used by empi. Must be
prefixed with mpi-
Base Implementation: Actual mpi-implementation package that will
provide all mpi functionality to the above.
@@ -37,13 +37,13 @@ Base Implementation: Actual mpi-implementation package that will
= Instructions =
-The following creates an implementation called "mpi-openmpi"
+The following creates a class called "mpi-openmpi"
using sys-cluster/openmpi as the base implementation. We also
set some USE flags and make sure to unmask the appropriate
version of sys-cluster/openmpi. Long options and full package
atoms are used, but not required.
-1.) Sync the overlay located at rsync://cold-front.ath.cx/mpi
+1.) Sync the science overlay.
2.) Emerge empi
@@ -52,10 +52,10 @@ atoms are used, but not required.
# echo ">=sys-cluster/openmpi-1.2.5-r1" >> /etc/portage/package.keywords
4.) Create the implementation.
- # empi --create --implementation mpi-openmpi =sys-cluster/openmpi-1.2.5-r1
+ # empi --create --class mpi-openmpi =sys-cluster/openmpi-1.2.5-r1
5.) Add packages.
- # empi --add --implementation mpi-openmpi hpl mpi-examples
+ # empi --add --class mpi-openmpi hpl mpi-examples
6.) Setup your user.
$ eselect mpi set mpi-openmpi
@@ -73,3 +73,4 @@ EOF
= Links =
http://dev.gentoo.org/~vapier/CROSS-COMPILE-HOWTO
http://archives.gentoo.org/gentoo-cluster/msg_f29032b0d85f7f47d9e52940e9322d91.xml
+http://dev.gentoo.org/~jsbronder/empi.xml
diff --git a/sys-cluster/empi/files/empi-0.6 b/sys-cluster/empi/files/empi-0.6
new file mode 100755
index 000000000..b2ff0e7da
--- /dev/null
+++ b/sys-cluster/empi/files/empi-0.6
@@ -0,0 +1,407 @@
+#!/bin/bash
+VERSION=0.6
+
+source /etc/init.d/functions.sh
+
+# class (category) Implementation we're installing for. mpi-*
+# targets Packages to run action on. When creating, the implementation to use.
+# action create, add, update, remove.
+
+die(){
+ if [ -n "${1}" ]; then
+ echo; eerror $1; echo
+ fi
+ exit 1
+}
+
+usage(){
+ local rc=${1:-0}
+ shift
+cat <<-EOF
+empi-${VERSION}
+Usage: ${HILITE}empi${NORMAL} ${GOOD}[actions]${NORMAL} ${BRACKET}[options]${NORMAL}
+
+Actions:
+ ${GOOD}-c, --create${NORMAL} pkgspec (Re)Initialize setup for mpi class.
+ ${GOOD}-a, --add${NORMAL} pkgspec(s) Add packages using specified mpi class.
+ ${GOOD}-d, --delete${NORMAL} class Remove everything related to specified class.
+
+Options:
+ ${GOOD}-C, --class${NORMAL} class MPI class to use.
+ ${GOOD}-t, --tree${NORMAL} path Path to portage tree to use ebuilds from.
+ ${GOOD}-o, --overlaydir${NORMAL} path Directory to use for the empi portage overlay.
+ ${GOOD} --noemerge${NORMAL} Do not call emerge, only preform overlay setup.
+
+Notes:
+ ${HILITE}-${NORMAL} pkgspec is specified by a package string. Without a version, the
+ portageq best_visible is used. For example, all of the following
+ are valid: openmpi, sys-cluster/openmpi, =sys-cluster/openmpi-1.2.5.
+ ${HILITE}-${NORMAL} class (-c) is user defined but must be prefixed with "mpi-"
+
+Examples:
+${BRACKET}Create a new class based on openmpi.${NORMAL}
+ empi --create sys-cluster/openmpi --class mpi-ompi
+${BRACKET}Rebuild the above.${NORMAL}
+ emerge mpi-ompi/openmpi
+${BRACKET}Add hpl to mpi-ompi${NORMAL}
+ empi --class mpi-ompi --add sys-cluster/hpl
+EOF
+ [[ -n $* ]] && echo && eerror "Error: $*"
+ exit ${rc}
+}
+
+class_is_valid() {
+ [[ -z ${class} ]] && usage 1 "No class defined."
+ [[ ${class} != mpi-* ]] && usage 1 "Classes must be prefixed with mpi-"
+ [[ ${class//./} != ${class} ]] && usage 1 "Classes cannot contain . (period)"
+}
+
+is_class_category() {
+ local i
+ for i in $(eselect mpi list -p); do
+ [[ ${1} == ${i} ]] && return 0
+ done
+ return 1
+}
+
+split_atom() {
+ local cpv c pf pn pv
+ cpv=$(portageq best_visible / ${1})
+ if [[ -z ${cpv} || ${rc} -ne 0 ]]; then
+ cpv=$(portageq best_visible / =${1})
+ [[ -z ${cpv} || ${rc} -ne 0 ]] && return 1
+ fi
+ c=${cpv%/*}; pf=${cpv#${c}/}; pn=${pf%%-[0-9]*}; pv=${pf#${pn}-}
+ echo "${c} ${pn} ${pv}"
+}
+
+parse_pkgspecs() {
+ local atom i
+ for ((i=0; i<${#targets[@]}; i++)); do
+ atom=($(split_atom ${targets[i]}))
+ if [[ $? -ne 0 ]]; then
+ eerror "Unable to find a unique package or valid version for ${targets[i]}"
+ eerror "Is the package unmasked and unblocked normally?"
+ die ""
+ fi
+ targets[i]=${atom[0]}/${atom[1]}-${atom[2]}
+ done
+}
+
+# handle_etc_portage package_spec
+# parses /etc/portage/package.{keywords,use}. If ${class}/${pn} is seen, we don't
+# do a thing. Otherwise copy any lines that have ${cat}/${pn} inserting them again
+# with the new category. Also keywords virtual/${class} if necessary.
+handle_etc_portage() {
+ local atom=( $(split_atom ${1}) )
+ local ext line gfiles f
+
+ for ext in "keywords" "use"; do
+ if [ -d /etc/portage/package.${ext} ]; then
+ gfiles="/etc/portage/package.${ext}/*"
+ f=/etc/portage/package.${ext}/${class}
+ else
+ gfiles="/etc/portage/package.${ext}"
+ f=/etc/portage/package.${ext}
+ fi
+
+ if ! grep "^[>=<]*${class}/${atom[1]}" ${gfiles} &>/dev/null; then
+ grep -h "^[>=<]*${atom[0]}/${atom[1]}" ${gfiles} 2>/dev/null \
+ | sed "s,${atom[0]},${class}," \
+ | while read line; do
+ echo "${line}" >> ${f}
+ [[ ${VERBOSE} -ne 0 ]] \
+ && einfo "Addition to ${f}: ${line}"
+ done
+ elif [[ ${VERBOSE} -ne 0 ]]; then
+ ewarn "Keys for ${class}/${atom[1]} already exist in ${f}. Will not replicate them."
+ fi
+
+ if ! grep "^${class}/mpi" ${gfiles} &>/dev/null; then
+ grep -h "^virtual/mpi" ${gfiles} 2>/dev/null \
+ | sed "s,/mpi,/${class}," \
+ | while read line; do
+ echo "${line}" >> ${f}
+ [[ ${VERBOSE} -ne 0 ]] \
+ && einfo "Addition to ${f}: ${line}"
+ done
+ elif [[ ${VERBOSE} -ne 0 ]]; then
+ ewarn "Keys for virtual/${class} already exist. Will not replicate."
+ fi
+ done
+}
+
+
+
+get_ebuild_dir() {
+ local d a
+ local want_uses_mpi=${2:-0}
+ local found=0
+
+ a=($(split_atom ${1}))
+ [[ $? -ne 0 ]] && die "Unable to find a unique package or valid version for ${1}."
+ is_class_category ${a[0]} && die "It makes no sense to build a new mpi-class from a current one."
+
+ if [[ -z ${portage_tree} ]]; then
+ for d in $(portageq portdir_overlay) $(portageq portdir); do
+ if [[ ${want_uses_mpi} -ne 0 ]]; then
+ [[ -f "${d}/${a[0]}/${a[1]}/${a[1]}-${a[2]}.ebuild" ]] \
+ && ebuild_uses_mpi ${d}/${a[0]}/${a[1]} ${a[1]}-${a[2]} \
+ && found=1
+ else
+ [[ -f "${d}/${a[0]}/${a[1]}/${a[1]}-${a[2]}.ebuild" ]] && found=1
+ fi
+ [[ ${found} -ne 0 ]] && break
+ done
+ if [[ ${found} -ne 0 ]]; then
+ portage_tree=${d}
+ else
+ die "Could not find an ebuild for ${a[0]}/${a[1]}-${a[2]}."
+ fi
+ fi
+
+ ebuild_dir="${portage_tree}/${a[0]}/${a[1]}"
+}
+
+ebuild_uses_mpi() {
+ grep 'inherit .*mpi' "${1}/${2##*/}.ebuild" &>/dev/null
+}
+
+link_ebuild_dir() {
+ ln -snf "${ebuild_dir}" "${MPI_PORTDIR}"/${class}/${ebuild_dir##*/} \
+ || die "Failed to link ${ebuild_dir} to ${MPI_PORTDIR}/${class}/${ebuild_dir##*/}"
+}
+
+# TODO: Needs to be called after get_ebuild_dir which sets $portage_tree
+create_virtual_mpi() {
+ local d_dir="${MPI_PORTDIR}"/virtual/${class}
+ local version d_file mpi_ebuild s_dir
+
+ # Try to get virtual/mpi from the same tree as the other ebuilds.
+ # Otherwise we fall back and get it from anywhere.
+ version=$(portageq best_visible / ${_virtual_mpi_version})
+ version=${version#virtual/mpi-}
+
+ for s_dir in ${portage_tree} $(portageq portdir_overlay) $(portageq portdir); do
+ mpi_ebuild="${s_dir}"/virtual/mpi/mpi-${version}.ebuild
+ [ -f "${mpi_ebuild}" ] && break;
+ done
+
+ [[ ! -f "${mpi_ebuild}" ]] \
+ && die "Cannot satisfy ${_virtual_mpi_version}"
+
+ d_file=${class}-${version}.ebuild
+
+ mkdir -p "${d_dir}" || die "Could not create ${d_dir}"
+
+ cp "${mpi_ebuild}" "${d_dir}"/${d_file} \
+ || die "Could not copy ${mpi_ebuild} to ${d_dir}/${d_file}"
+
+ sed -i "s,sys-cluster/,${class}/," ${d_dir}/${d_file}
+ ebuild ${d_dir}/${d_file} digest > /dev/null \
+ || die "Failed to digest ${d_dir}/${d_file}"
+}
+
+
+
+do_emerge() {
+ [[ ${DO_EMERGE} -eq 0 ]] && return 0
+ einfo "Emerging $*"
+ emerge ${emerge_opts} $* || die "emerge failed!"
+}
+
+# We should have only one target here.
+create_class() {
+ local mpi_class_pkg d mpi_class_pn
+
+ [[ ${#targets[@]} -ne 1 ]] && die "Can only create one class at a time."
+
+ for d in $(eselect mpi list -p); do
+ [ "${d}" == "${class}" ] && die "${class} has already been created."
+ done
+
+ # Prevent laziness
+ [[ ${targets[0]} == ${targets[0]##*/} ]] \
+ && targets[0]="sys-cluster/${targets[0]}"
+
+ parse_pkgspecs
+ get_ebuild_dir ${targets[0]} 1
+ create_virtual_mpi
+ mpi_class_pn=${ebuild_dir##*/}
+ mpi_class_pkg=${targets[0]}
+ handle_etc_portage ${targets[0]}
+ targets[0]="=${class}/${targets[0]##*/}"
+
+ # Refuse to break systems. If there is already a class
+ # installed in that directory, we're not going to add another one as
+ # the eclass doesn't fix one problem just to introduce a bigger one.
+ for d in $(find ${MPI_PORTDIR}/${class} -maxdepth 1 -mindepth 1 -type l 2>/dev/null);do
+ d=${d##*/}
+ [[ ${d} == ${mpi_class_pn} ]] && continue
+ for i in ${MPI_ALL_IMPS}; do
+ [[ ${i} == ${d} ]] \
+ && die "${class} already has MPI implementation ${d}, refusing to add ${mpi_class_pn}"
+ done
+ done
+
+ if [[ -d "${MPI_PORTDIR}"/${class} ]]; then
+ [[ ${VERBOSE} -ne 0 ]] && ewarn "Overlay for ${class} has already been created."
+ else
+ mkdir -p ${MPI_PORTDIR}/${class}
+ link_ebuild_dir
+ fi
+ if ! grep "^${class}$" /etc/portage/categories &>/dev/null; then
+ echo "${class}" >> /etc/portage/categories
+ fi
+
+
+cat << EOF
+Creating ${HILITE}${class}${NORMAL}
+ Class: ${GOOD}${class}${NORMAL}
+ MPI Implementation: ${GOOD}${mpi_class_pkg}${NORMAL}
+ Source: ${GOOD}${ebuild_dir}${NORMAL}
+ Destination: ${GOOD}${MPI_PORTDIR}/${class}${NORMAL}
+EOF
+ do_emerge ${targets[0]}
+}
+
+
+add_packages(){
+ local i j deps
+
+ [[ -d "${MPI_PORTDIR}"/${class} ]] || die "Class ${class} has not been created yet."
+ [[ ${#targets[@]} -lt 1 ]] && die "You need to specify at least one package"
+
+ parse_pkgspecs
+ for ((i=0;i<${#targets[@]};i++)); do
+ get_ebuild_dir ${targets[i]}
+ if ebuild_uses_mpi ${ebuild_dir} ${targets[i]}; then
+ link_ebuild_dir
+ handle_etc_portage ${targets[i]}
+ targets[i]="=${class}/${targets[i]##*/}"
+ else
+ targets[i]="=${targets[i]}"
+ fi
+
+ # I don't know about this, but do you have a better idea?
+ deps="$(emerge --color=n --onlydeps -p --quiet ${targets[i]})"
+ if [[ $? -ne 0 ]]; then
+ emerge --onlydeps -p ${targets[i]}
+ die "Unable to calculate deps for ${targets[i]}"
+ fi
+ deps=( $(echo ${deps} | sed -e 's:\[[a-z]* [A-Z] \] :=:g') )
+ for ((j=0;j<${#deps[@]};j++)); do
+ get_ebuild_dir ${deps[j]}
+ if ebuild_uses_mpi ${deps[i]}; then
+ link_ebuild_dir
+ fi
+ done
+ done
+cat << EOF
+Adding packages to ${HILIGHT}${class}${NORMAL}
+ Packages: ${GOOD}${targets[@]}${NORMAL}
+EOF
+ do_emerge ${targets[@]}
+}
+
+
+delete_class() {
+ local pkgs=( $(ls /var/db/pkg/${class}/ 2>/dev/null) )
+ local ext d i rc
+ [[ -d "${MPI_PORTDIR}"/${class} ]] || die "Class ${class} has not been created yet."
+ rc=0
+
+ for (( i=0; i<${#pkgs[@]}; i++)); do
+ pkgs[i]="=${class}/${pkgs[i]}"
+ done
+
+ if [[ ${#pkgs[@]} -gt 0 ]] && ! emerge -C ${emerge_opts/-u/} ${pkgs[@]}; then
+ die "Failed to unmerge ${pkgs[@]}"
+ fi
+
+ for ext in "keywords" "use"; do
+ if [ -d /etc/portage/package.${ext} ]; then
+ rm /etc/portage/package.${ext}/${class} &>/dev/null
+ rc=$((rc+$?))
+ elif [ -f /etc/portage/package.${ext} ]; then
+ sed -i -e "/^${class}\//d" /etc/portage/package.${ext}
+ rc=$((rc+$?))
+ fi
+ done
+
+ [ ! -f /etc/portage/categories ] || sed -i -e "/^${class}$/d" /etc/portage/categories
+ rc=$((rc+$?))
+
+ for d in $(ls "${MPI_PORTDIR}"/${class}/ 2>/dev/null); do
+ rm "${MPI_PORTDIR}"/${class}/${d}
+ rc=$((rc+$?))
+ done
+
+ for d in "${MPI_PORTDIR}/${class}" /var/db/pkg/${class}; do
+ [ ! -d "${d}" ] || rmdir "${d}"
+ rc=$((rc+$?))
+ done
+
+ [[ ${rc} -ne 0 ]] \
+ && ewarn "Errors were encountered during delete_class()"
+ return ${rc}
+}
+
+# Internal variables.
+_virtual_mpi_version=">=virtual/mpi-2.0"
+
+[[ ${UID} -ne 0 ]] && die "You must be root."
+DO_EMERGE=1
+VERBOSE=0
+targets=""
+emerge_opts="-u" # Packages can be recompiled by hand if necessary.
+portage_tree=""
+action=""
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -h|--help)
+ usage;;
+ -c|--create)
+ action="${action}create";;
+ -a|--add)
+ action="${action}add";;
+ -d|--delete)
+ action="${action}delete"
+ shift; class=${1};;
+ -C|--class)
+ shift; class=${1};;
+ -t|--tree)
+ shift; portage_tree=${1};;
+ -o|--overlaydir)
+ shift; MPI_PORTDIR=${1};;
+ -v|--verbose)
+ VERBOSE=1;;
+ --noemerge)
+ DO_EMERGE=0;;
+ -*)
+ emerge_opts="${emerge_opts} ${1}";;
+ *)
+ targets=( $(echo ${targets[@]}) ${1} );;
+ esac
+ shift
+done
+
+if [ -z "${MPI_PORTDIR}" ]; then
+ MPI_PORTDIR="$(portageq portdir_overlay)"
+ MPI_PORTDIR="${MPI_PORTDIR%% *}"
+fi
+
+if [ ! -d "${MPI_PORTDIR}" ]; then
+ mkdir -p "${MPI_PORTDIR}" || die "Failed to mkdir ${MPI_PORTDIR}"
+fi
+
+export PORTDIR_OVERLAY="${MPI_PORTDIR} $(portageq portdir_overlay)"
+export PKGDIR="$(portageq envvar PKGDIR)/mpi/${class}"
+
+[[ -z ${action} ]] && usage 1 "No action defined."
+class_is_valid
+
+[[ ${action} == *create* ]] && create_class
+[[ ${action} == *add* ]] && add_packages
+[[ ${action} == *delete* ]] && delete_class
diff --git a/sys-cluster/empi/files/eselect.mpi-0.6 b/sys-cluster/empi/files/eselect.mpi-0.6
new file mode 100644
index 000000000..e7fafd284
--- /dev/null
+++ b/sys-cluster/empi/files/eselect.mpi-0.6
@@ -0,0 +1,234 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: $
+
+DESCRIPTION="Manage MPI classes"
+MAINTAINER="jsbronder@gentoo.org"
+SVN_DATE='$Date: $'
+VERSION="0.0.2"
+
+inherit path-manipulation config
+
+# The basic idea is we want to allow every use to select their own mpi
+# implementation they want, and a ${HOME}/.env.d/mpi file is created for them.
+# A user then is -required- to source the env file. This sets PATH, MANPATH,
+# and LD_LIBRARY_PATH. I'm sure I'm forgetting something here.
+# Calling unset only wipes out the env file, replacing it with what we
+# previously added stripped out.
+
+# If you can think of a better way to do this, while still allowing user's
+# freedom, please let me know.
+
+# List the valid mpi classes currently installed.
+find_classes() {
+ local classes
+ for f in ${ROOT}/etc/env.d/mpi/*; do
+ [[ -f ${f} ]] || continue
+ f=$(basename ${f})
+ [[ "${f#mpi-}" == "${f}" ]] && continue
+ classes=(${classes[@]} ${f})
+ done
+ echo ${classes[@]}
+}
+
+# User's current environment has the class configured in it.
+is_in_use() { [ "${ESELECT_MPI_IMP}" == "${1}" ]; }
+
+# User's env file is ready for sourcing for this class
+is_enabled() {
+ [ "$(var_from_user_envd ESELECT_MPI_IMP)" == "${1}" ]
+}
+
+var_from_user_envd(){
+ [ ! -f ${user_ev_sh} ] && return 0
+ echo "$(source ${user_ev_sh}; echo ${!1})"
+}
+
+# Is this a valid class?
+is_class() {
+ local classes=$(find_classes)
+ for i in ${classes[@]}; do
+ [[ "${i}" == "${1}" ]] && return 0
+ done
+ return 1
+}
+
+init() {
+ local d
+ [[ ${UID} -eq 0 ]] && HOME="${ROOT}/root"
+ d="$(canonicalise "${ROOT}/${HOME}")"
+ d="${d}/.env.d/"
+ user_ev_sh="${d}mpi.sh";
+ user_ev_csh="${d}mpi.csh";
+
+ if [[ ! -d "${d}" ]]; then
+ mkdir "${d}" || die -q "Failed to create ${d}."
+ elif [[ ! -w "${d}" ]]; then
+ die -q "You do not have permission to mkdir ${d}."
+ fi
+ [[ -f "${user_ev_sh}" && ! -w "${user_ev_sh}" \
+ && -f "${user_ev_csh}" && ! -w "${user_ev_csh}" ]] \
+ && die -q "You do not have permission to write to ${user_ev_sh} or ${user_ev_csh}."
+}
+
+global_env() {
+ local d=$(canonicalise "${ROOT}/etc/env.d/mpi/${1}")
+ [ -z "${d}" ] && die "Cannot find global env file for ${1}"
+ ev=${d}
+}
+
+clean_var() {
+ local class v
+ local value="${!1}"
+ local d="$(canonicalise "${ROOT}/etc/env.d/mpi/${class}")"
+ [ -z "${value}" ] && return 0
+ [ -z "${d}" ] && continue
+
+ for class in $(find_classes); do
+ v=$(load_config ${d}/${class} ${1})
+ [ -z "${v}" ] && continue
+ value="$(echo ${value} | sed -e "s|${v}:||g")"
+ done
+ echo ${value}
+}
+
+
+### list action ###
+
+describe_list() { echo "List available classs"; }
+describe_list_parameters() { echo "[-p]"; }
+
+do_list() {
+ classes=( $(find_classes) )
+ init
+ if [[ ${@} == *-p* ]]; then
+ echo "${classes[@]}"
+ else
+ write_list_start "Available MPI classs:"
+ if [[ -n "${classes[@]}" ]]; then
+ for (( i=0; i<${#classes[@]}; i++ )); do
+ if is_in_use ${classes[$i]} && is_enabled ${classes[$i]}; then
+ write_kv_list_entry "${classes[$i]}" "Enabled, In Use"
+ elif is_in_use ${classes[$i]}; then
+ write_kv_list_entry "${classes[$i]}" "In Use"
+ elif is_enabled ${classes[$i]}; then
+ write_kv_list_entry "${classes[$i]}" "Enabled"
+ else
+ write_kv_list_entry "${classes[$i]}" "--"
+ fi
+ done
+ else
+ write_kv_list_entry "(none found)" ""
+ fi
+ fi
+ return 0
+}
+
+
+### set action ###
+
+describe_set() {
+ echo "Select a MPI class."
+}
+
+describe_set_parameters() {
+ echo "<target>"
+}
+
+do_set() {
+ local binpath lld manpath
+
+ init
+ global_env ${1}
+
+ [[ -z ${1} ]] && die -q "You didnt specifiy any class for use."
+ [[ ${#@} -ne 1 ]] && die -q "You may only select exactly one class."
+ ! is_class ${1} && die -q "${1} is not an class."
+ is_enabled ${1} && return 0
+
+ binpath="$(load_config ${ev} PATH):$(clean_var PATH)"
+ lld="$(load_config ${ev} LD_LIBRARY_PATH):$(clean_var LD_LIBRARY_PATH)"
+ manpath="$(load_config ${ev} MANPATH):$(clean_var MANPATH)"
+
+cat <<-EOF >${user_ev_sh}
+export PATH="${binpath}"
+export MANPATH="${manpath}"
+export LD_LIBRARY_PATH="${lld}"
+export ESELECT_MPI_IMP="${1}"
+EOF
+
+cat <<-EOF >${user_ev_csh}
+setenv PATH "${binpath}"
+setenv MANPATH "${manpath}"
+setenv LD_LIBRARY_PATH "${lld}"
+setenv ESELECT_MPI_IMP "${1}"
+EOF
+
+ echo "Remember to source ${user_ev_sh}, ${user_ev_csh} or /etc/profile"
+}
+
+
+### unset action ###
+describe_unset() {
+ echo "Restore MPI-less environment."
+}
+
+do_unset() {
+ local binpath lld manpath
+
+ init
+ [ -f "${user_ev_sh}" ] && rm -f "${user_ev_sh}"
+ [ -f "${user_ev_csh}" ] && rm -f "${user_ev_csh}"
+
+ echo "Remember to source ${user_ev_sh}, ${user_ev_csh} or /etc/profile"
+}
+
+### add action (from skel pretty much)
+describe_add() {
+ echo "Add a new mpi class"
+}
+
+describe_add_parameters() {
+ echo "<file>"
+}
+
+do_add() {
+ local class
+ [[ ${#@} -ne 1 ]] \
+ && die -q "Bad arguments, use: mpi add /some/full/path/<class>.eselect"
+
+ # If $D is set, we're adding from portage so we want to respect sandbox.
+ # Otherwise, respect the ROOT variable.
+ local PREFIX=${D:-${ROOT}/}
+
+ # Create directory if necessary
+ if [[ ! -e ${PREFIX}/etc/env.d/mpi/ ]]; then
+ mkdir -p ${PREFIX}/etc/env.d/mpi/
+ else
+ if [[ ! -d ${PREFIX}/etc/env.d/mpi/ ]]; then
+ die -q "${PREFIX}/etc/env.d/mpi/ exists but isn't a directory!"
+ fi
+ fi
+
+ class=$(basename ${1}); class=${class%.eselect}
+ if ! cp ${1} ${PREFIX}/etc/env.d/mpi/${class}; then
+ die -q "Installing ${1} as ${PREFIX}/etc/env.d/mpi/${class} failed!"
+ fi
+}
+
+
+### printvar action ###
+describe_printvar() { echo "Print variables stored in global env.d file."; }
+describe_printvar_parameters() { echo "<class> <variable>"; }
+
+do_printvar() {
+ if [[ ${#@} -ne 2 ]] \
+ || ! is_class ${1}; then
+ die -q "Specify exactly 1 class and 1 variable."
+ fi
+ global_env ${1}
+ echo "$(load_config ${ev} ${2})"
+}
+
+# vim: set ft=eselect :
+
diff --git a/sys-cluster/empi/files/mpi.csh b/sys-cluster/empi/files/mpi.csh
new file mode 100644
index 000000000..32506b4cc
--- /dev/null
+++ b/sys-cluster/empi/files/mpi.csh
@@ -0,0 +1,3 @@
+if ( -d "${HOME}"/.env.d && -f "${HOME}"/.env.d/mpi.csh ) then
+ source "${HOME}"/.env.d/mpi.csh
+endif
diff --git a/sys-cluster/empi/files/mpi.sh b/sys-cluster/empi/files/mpi.sh
new file mode 100644
index 000000000..5483247e5
--- /dev/null
+++ b/sys-cluster/empi/files/mpi.sh
@@ -0,0 +1,3 @@
+if [ -d "${HOME}"/.env.d -a -f "${HOME}"/.env.d/mpi.sh ]; then
+ source "${HOME}"/.env.d/mpi.sh
+fi