Explorar el Código

add sience modules

LDA010 hace 7 años
padre
commit
8ae7dc1172

+ 3 - 0
science/.gitignore

@@ -0,0 +1,3 @@
+.DS_Store
+app-misc/dummy
+eclass/*.5

+ 38 - 0
science/.travis.yml

@@ -0,0 +1,38 @@
+#
+# Run repoman via travis
+# See https://github.com/mrueg/repoman-travis
+#
+language: python
+cache: pip
+python:
+    - pypy
+env:
+    - PORTAGE_VER="2.3.5"
+before_install:
+    - sudo apt-get -qq update
+    - pip install lxml
+before_script:
+    - sudo chmod a+rwX /etc/passwd /etc/group /etc /usr
+    - mkdir -p travis-overlay /etc/portage /usr/portage/distfiles
+    - mv !(travis-overlay) travis-overlay/
+    - mv .git travis-overlay/
+    - wget "https://raw.githubusercontent.com/mrueg/repoman-travis/master/spinner.sh"
+    - wget -qO - "https://github.com/gentoo/portage/archive/portage-${PORTAGE_VER}.tar.gz" | tar xz
+    - wget -qO - "https://github.com/gentoo-mirror/gentoo/archive/master.tar.gz" | tar xz -C /usr/portage --strip-components=1
+    - chmod a+rwx spinner.sh
+    - echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd
+    - echo "portage::250:portage,travis" >> /etc/group
+    - wget "https://www.gentoo.org/dtd/metadata.dtd" -O /usr/portage/distfiles/metadata.dtd
+    - ln -s portage-portage-${PORTAGE_VER}/cnf/repos.conf /etc/portage/repos.conf
+    - ln -s /usr/portage/profiles/default/linux/amd64/13.0 /etc/portage/make.profile
+    - cd travis-overlay
+script:
+    - ./../spinner.sh "python ../portage-portage-${PORTAGE_VER}/repoman/bin/repoman full -d"
+# You can append own scripts after this line
+
+notifications:
+    irc:
+        channels: "chat.freenode.net#gentoo-science"
+        template:
+            - "%{repository} - %{branch} - %{author}: %{commit_subject} - %{message} - Build details : %{build_url}"
+        use_notice: true

+ 161 - 0
science/CONTRIBUTING.md

@@ -0,0 +1,161 @@
+#Contributions to the Gentoo Science Overlay
+
+This guide summarizes the contribution and merging procedures for the Gentoo Science overlay on Github. For more information please visit the [Science Project page](https://wiki.gentoo.org/wiki/Project:Science/Contributing) in the [Gentoo wiki](https://wiki.gentoo.org/).
+
+----
+##Prerequisite
+For the most convenient way to work with the overlay you should fulfill all prerequisites.
+
+###Required
+
+* **Install git**
+
+The Science overlay is controlled by [git](http://git-scm.com/). You can install it with
+
+    emerge dev-vcs/git
+
+Familiarize yourself with git and visit [http://git-scm.com/documentation](http://git-scm.com/documentation) for documentation.
+
+* **Account at [github](https://github.com/join)**
+
+Everybody who wants to contribute needs to own an account @ [Github](http://github.com/). Please register yourself [there](https://github.com/join).
+
+###Recommended
+* **Define the echangelog user**
+
+Make sure the ECHANGELOG_USER variable is present in your environment.
+
+    echo 'export ECHANGELOG_USER="John Smith <john@smith.com>"' >> ~/.bashrc
+
+###Optional
+* **Setup commit signing**
+
+Create a [gpg key](http://www.gossamer-threads.com/lists/gentoo/dev/268496?do=post_view_threaded) if you don't have one already and make git use it.
+
+    git config --global user.signingkey <gpg-key-id>
+
+Now git will sign your commits to the overlay by using the gpg key.
+
+* **Install [hub](http://hub.github.com/)**, the *command-line wrapper for git that makes you better at GitHub*.
+
+*hub* can be used equivalent to to *git* and upstream even recommends *"alias git='hub'*.
+
+    emerge dev-vcs/hub
+
+* **Install [repo-commit](https://bitbucket.org/gentoo/repo-commit/)**, *A repository commit helper*
+
+*repo-commit* sanitizes your commit in a convenient way.
+
+    emerge app-portage/repo-commit
+
+---
+##Contributing ebuilds
+
+###Clone the overlay
+
+Create a local checkout of the overlay
+
+    hub clone gentoo-science/sci
+
+###Fork the overlay
+In order to send pull request and ask for inclusion of your changes you need to have your own fork of the overlay on github. You can do this by issuing
+
+    cd sci
+    hub fork
+
+###Branch out for contribution
+It is always convenient for development as well as for the review and merging process, if the development is done in branches. Let's branch the overlay into a local branch named PACKAGE_NAME.
+
+    git checkout -b PACKAGE_NAME master
+
+For the fastest process during merging it is best to have a single branch per package.
+
+###Work on the package
+Now you are ready to work on your package of interest. Once you are finished you should _always_ use **[repoman](http://dev.gentoo.org/~zmedico/portage/doc/man/repoman.1.html)** to do a static analysis of your work.
+
+This can be done with
+
+    repoman full
+
+###Commit your work
+Once *all* reported problems are resolved, you can commit it
+
+    repo-commit "Here we write a comprehensible commit message"
+
+###Push to Github and make a pull request
+In order to facilitate potential reverts of mistakes, we prefer to keep the git history as linear as possible. For this, always rebase your changes on the latest remote changes.
+
+    hub pull --rebase=preserve github master
+
+Next we push back the changes in the PACKAGE_NAME branch to our fork and send a pull-request to the overlay maintainers.
+
+    hub push YOUR_GITHUB_USER PACKAGE_NAME
+    hub pull-request
+
+Lastly you need to wait for review comments and the merge of your work. If you feel that they are slacking, don't bother to ping them again. In case you need to include some improvements, just commit your work again using *repo-commit* and push it again to your fork. No need to send another pull-request as your new changes will be added to the original one.
+
+###What's next?
+If you would like to get direct access to the overlay, prove some contribution and ping us via sci@gentoo.org or on irc in #gentoo-science @ freenode. If you would like to become a dev yourself, prove some more contributions and again, contact us. We are always looking for new candidates.
+
+----
+##Ebuild recommendations
+As the Gentoo Science overlay is a constant work-in-progress, we have some recommendations for prospective contributors:
+
+* **Aim for writing EAPI=6 ebuilds.** For certain eclasses, EAPI=6 is not allowed yet. In such cases you may use EAPI=5. We will not accept EAPI<5 ebuilds.
+* **Version bumps should always follow the latest guidelines.** For instance, a version bump of an ebuild that still employs autotools-utils.eclass should be avoided. Instead, drop 'autotools-utils', move to 'autotools' and call `default` followed by `eautoreconf` in src_prepare().
+
+----
+##Merging contributions
+
+**It is important, that if you merge a pull request, you should feel as responsible as if you have written the commits yourself!**
+
+
+
+###Prerequisite
+
+Make sure you have both repos (github & gentoo.org) as remotes defined.
+
+    git remote -v
+
+should give
+
+>github	git@github.com:gentoo-science/sci.git (fetch)
+>
+>github	git@github.com:gentoo-science/sci.git (push)
+>
+>origin	git+ssh://git@git.overlays.gentoo.org/proj/sci.git (fetch)
+>
+>origin	git+ssh://git@git.overlays.gentoo.org/proj/sci.git (push)
+
+
+###Review process
+
+In the beginning you should review the pull request on github directly and recommend as much improvements as possible. By this you train the new contributor towards becoming a new dev, which should be our final goal.
+
+####Checking out the pull-request as local branch
+Once everything is fine or you like to fix the rest yourself, simply use the following command to get the pull-request in a new branch in your repo.
+
+    hub checkout https://github.com/gentoo-science/sci/pull/PULLREQUEST-NUMBER
+
+####Testing and repoman check
+Now check the package by building and installing it, and run *repoman* in the package dir. Remember, when merging a pull request you take the responsibility for the quality of the commit.
+
+####Merge the pull-request branch into master
+If this is also fine, merge the branch into the master
+
+    git checkout master
+    git merge USER-BRANCH
+
+####Merging the two remote HEADs
+Finally use the script **merge-dualHEAD** from the *scripts* directory to merge the github and gentoo.org remote repo.
+
+
+---
+####Contribution to the document
+Sebastien Fabbro <bicatali@gentoo.org>
+
+Justin Lecher <jlec@gentoo.org>
+
+This document is available under [Creative Commons Attribution ShareAlike 4.0](http://creativecommons.org/licenses/by-sa/4.0)
+
+![ccsa-4 icon](http://i.creativecommons.org/l/by-sa/4.0/88x31.png)

+ 15 - 0
science/README.md

@@ -0,0 +1,15 @@
+#Gentoo Science Overlay
+
+An overlay for Gentoo, geared towards scientific packages.
+
+Homepage: [Science Project page](https://wiki.gentoo.org/wiki/Project:Science/Overlay)
+
+
+Please fork! We will merge! See [this](https://github.com/gentoo-science/sci/blob/master/CONTRIBUTING.md) document for more instructions.
+
+Ask for help on irc in #gentoo-science @ freenode.
+
+Report bugs on the [github issues site](https://github.com/gentoo-science/sci/issues)
+
+
+[![Build Status](https://travis-ci.org/gentoo-science/sci.svg?branch=master)](https://travis-ci.org/gentoo-science/sci)

+ 184 - 0
science/skel.ebuild

@@ -0,0 +1,184 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# NOTE: The comments in this file are for instruction and documentation.
+# They're not meant to appear with your final, production ebuild.  Please
+# remember to remove them before submitting or committing your ebuild.  That
+# doesn't mean you can't add your own comments though.
+
+# The 'Header' on the third line should just be left alone.  When your ebuild
+# will be committed to cvs, the details on that line will be automatically
+# generated to contain the correct data.
+
+# The EAPI variable tells the ebuild format in use.
+# Defaults to 0 if not specified.
+# It is suggested that you use the latest EAPI approved by the Council.
+# The PMS contains specifications for all EAPIs. Eclasses will test for this
+# variable if they need to use EAPI > 0 features.
+EAPI=5
+
+# inherit lists eclasses to inherit functions from. Almost all ebuilds should
+# inherit eutils, as a large amount of important functionality has been
+# moved there. For example, the epatch call mentioned below wont work
+# without the following line:
+inherit eutils
+# A well-used example of an eclass function that needs eutils is epatch. If
+# your source needs patches applied, it's suggested to put your patch in the
+# 'files' directory and use:
+#
+#   epatch "${FILESDIR}"/patch-name-here
+#
+# eclasses tend to list descriptions of how to use their functions properly.
+# take a look at /usr/portage/eclass/ for more examples.
+
+# Short one-line description of this package.
+DESCRIPTION="This is a sample skeleton ebuild file"
+
+# Homepage, not used by Portage directly but handy for developer reference
+HOMEPAGE="http://foo.example.org/"
+
+# Point to any required sources; these will be automatically downloaded by
+# Portage.
+SRC_URI="ftp://foo.example.org/${P}.tar.gz"
+
+
+# License of the package.  This must match the name of file(s) in
+# /usr/portage/licenses/.  For complex license combination see the developer
+# docs on gentoo.org for details.
+LICENSE=""
+
+# The SLOT variable is used to tell Portage if it's OK to keep multiple
+# versions of the same package installed at the same time.  For example,
+# if we have a libfoo-1.2.2 and libfoo-1.3.2 (which is not compatible
+# with 1.2.2), it would be optimal to instruct Portage to not remove
+# libfoo-1.2.2 if we decide to upgrade to libfoo-1.3.2.  To do this,
+# we specify SLOT="1.2" in libfoo-1.2.2 and SLOT="1.3" in libfoo-1.3.2.
+# emerge clean understands SLOTs, and will keep the most recent version
+# of each SLOT and remove everything else.
+# Note that normal applications should use SLOT="0" if possible, since
+# there should only be exactly one version installed at a time.
+# DO NOT USE SLOT=""! This tells Portage to disable SLOTs for this package.
+SLOT="0"
+
+# Using KEYWORDS, we can record masking information *inside* an ebuild
+# instead of relying on an external package.mask file.  Right now, you should
+# set the KEYWORDS variable for every ebuild so that it contains the names of
+# all the architectures with which the ebuild works.  All of the official
+# architectures can be found in the arch.list file which is in
+# /usr/portage/profiles/.  Usually you should just set this to "~x86".  The ~
+# in front of the architecture indicates that the package is new and should be
+# considered unstable until testing proves its stability.  So, if you've
+# confirmed that your ebuild works on x86 and ppc, you'd specify:
+# KEYWORDS="~x86 ~ppc"
+# Once packages go stable, the ~ prefix is removed.
+# For binary packages, use -* and then list the archs the bin package
+# exists for.  If the package was for an x86 binary package, then
+# KEYWORDS would be set like this: KEYWORDS="-* x86"
+# DO NOT USE KEYWORDS="*".  This is deprecated and only for backward
+# compatibility reasons.
+KEYWORDS="~x86"
+
+# Comprehensive list of any and all USE flags leveraged in the ebuild,
+# with the exception of any ARCH specific flags, i.e. "ppc", "sparc",
+# "x86" and "alpha".  Not needed if the ebuild doesn't use any USE flags.
+IUSE="gnome X"
+
+# A space delimited list of portage features to restrict. man 5 ebuild
+# for details.  Usually not needed.
+#RESTRICT="strip"
+
+
+# Build-time dependencies, such as
+#    ssl? ( >=dev-libs/openssl-0.9.6b )
+#    >=dev-lang/perl-5.6.1-r1
+# It is advisable to use the >= syntax show above, to reflect what you
+# had installed on your system when you tested the package.  Then
+# other users hopefully won't be caught without the right version of
+# a dependency.
+#DEPEND=""
+
+# Run-time dependencies. Must be defined to whatever this depends on to run.
+# The below is valid if the same run-time depends are required to compile.
+RDEPEND="${DEPEND}"
+
+# Source directory; the dir where the sources can be found (automatically
+# unpacked) inside ${WORKDIR}.  The default value for S is ${WORKDIR}/${P}
+# If you don't need to change it, leave the S= line out of the ebuild
+# to keep it tidy.
+#S=${WORKDIR}/${P}
+
+
+# The following src_configure function is implemented as default by portage, so
+# you only need to call it if you need a different behaviour.
+# This function is available only in EAPI 2 and later.
+#src_configure() {
+	# Most open-source packages use GNU autoconf for configuration.
+	# The default, quickest (and preferred) way of running configure is:
+	#econf
+	#
+	# You could use something similar to the following lines to
+	# configure your package before compilation.  The "|| die" portion
+	# at the end will stop the build process if the command fails.
+	# You should use this at the end of critical commands in the build
+	# process.  (Hint: Most commands are critical, that is, the build
+	# process should abort if they aren't successful.)
+	#./configure \
+	#	--host=${CHOST} \
+	#	--prefix=/usr \
+	#	--infodir=/usr/share/info \
+	#	--mandir=/usr/share/man || die
+	# Note the use of --infodir and --mandir, above. This is to make
+	# this package FHS 2.2-compliant.  For more information, see
+	#   http://www.pathname.com/fhs/
+#}
+
+# The following src_compile function is implemented as default by portage, so
+# you only need to call it, if you need different behaviour.
+# For EAPI < 2 src_compile runs also commands currently present in
+# src_configure. Thus, if you're using an older EAPI, you need to copy them
+# to your src_compile and drop the src_configure function.
+#src_compile() {
+	# emake (previously known as pmake) is a script that calls the
+	# standard GNU make with parallel building options for speedier
+	# builds (especially on SMP systems).  Try emake first.  It might
+	# not work for some packages, because some makefiles have bugs
+	# related to parallelism, in these cases, use emake -j1 to limit
+	# make to a single process.  The -j1 is a visual clue to others
+	# that the makefiles have bugs that have been worked around.
+
+	#emake || die
+#}
+
+# The following src_install function is implemented as default by portage, so
+# you only need to call it, if you need different behaviour.
+# For EAPI < 4 src_install is just returing true, so you need to always specify
+# this function in older EAPIs.
+#src_install() {
+	# You must *personally verify* that this trick doesn't install
+	# anything outside of DESTDIR; do this by reading and
+	# understanding the install part of the Makefiles.
+	# This is the preferred way to install.
+	#emake DESTDIR="${D}" install || die
+
+	# When you hit a failure with emake, do not just use make. It is
+	# better to fix the Makefiles to allow proper parallelization.
+	# If you fail with that, use "emake -j1", it's still better than make.
+
+	# For Makefiles that don't make proper use of DESTDIR, setting
+	# prefix is often an alternative.  However if you do this, then
+	# you also need to specify mandir and infodir, since they were
+	# passed to ./configure as absolute paths (overriding the prefix
+	# setting).
+	#emake \
+	#	prefix="${D}"/usr \
+	#	mandir="${D}"/usr/share/man \
+	#	infodir="${D}"/usr/share/info \
+	#	libdir="${D}"/usr/$(get_libdir) \
+	#	install || die
+	# Again, verify the Makefiles!  We don't want anything falling
+	# outside of ${D}.
+
+	# The portage shortcut to the above command is simply:
+	#
+	#einstall || die
+#}

+ 19 - 0
science/skel.metadata.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>sci-blah</herd>
+<maintainer>
+  <email>my.email@blah.doh</email>
+</maintainer>
+
+<longdescription>
+  Long description of the package. Check the homepage. Make it useful
+  for users.
+</longdescription>
+<use>
+  <flag name="flag">Description of how USE='flag' affects this package</flag>
+</use>
+<upstream>
+  <remote-id type="blah">name-of-package-in-blah</remote-id>
+</upstream>
+</pkgmetadata>

+ 80 - 0
science/sys-cluster/modules/2

@@ -0,0 +1,80 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit autotools
+
+DESCRIPTION="Dynamic modification of a user's environment via modulefiles"
+HOMEPAGE="http://modules.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="test X"
+
+RDEPEND="
+	dev-lang/tcl:0=
+	dev-tcltk/tclx
+	X? ( x11-libs/libX11 )"
+
+DEPEND="${RDEPEND}
+	test? ( dev-util/dejagnu )"
+
+S="${WORKDIR}/${P%[a-z]}"
+
+DOCS=(ChangeLog README NEWS TODO)
+
+PATCHES=(
+	"${FILESDIR}/${P}-errorline.patch"
+	"${FILESDIR}/${P}-bindir.patch"
+	"${FILESDIR}/${P}-versioning.patch"
+	"${FILESDIR}/${P}-clear.patch"
+	"${FILESDIR}/${P}-avail.patch"
+)
+
+src_prepare() {
+	default
+
+	#has_version ">=dev-lang/tcl-8.6.0" && epatch "${FILESDIR}"/${P}-errorline.patch
+
+	sed -e "s:@EPREFIX@:${EPREFIX}:g" \
+		"${FILESDIR}"/modules.sh.in > modules.sh || die
+
+	AT_M4DIR="."
+	eautoreconf
+
+}
+
+src_configure() {
+
+	local myeconfargs=(
+		--disable-versioning
+		--prefix="${EPREFIX}/usr/share"
+		--exec-prefix="${EPREFIX}/usr/share/Modules"
+		--with-module-path="${EPREFIX}/etc/modulefiles"
+		--with-tcl="${EPREFIX}/usr/$(get_libdir)"
+		$(use_with X x)
+	)
+	econf ${myeconfargs}
+
+}
+
+src_install() {
+
+	echo "I am in install"
+	default
+
+	insinto /etc/profile.d
+	doins modules.sh
+	exeinto /usr/share/Modules/bin
+	doexe "${FILESDIR}"/createmodule.{sh,py}
+	dosym /usr/share/Modules/init/csh /etc/profile.d/modules.csh
+	dodir /etc/modulefiles
+}
+
+pkg_postinst() {
+	   elog "Add this line at the end of your bashrc:"
+	   elog "[ -f /opt/Modules/default/init/bash ] && source /opt/Modules/default/init/bash"
+}

+ 2 - 0
science/sys-cluster/modules/Manifest

@@ -0,0 +1,2 @@
+DIST modules-3.2.10.tar.bz2 327611 SHA256 e8403492a8d57ace6485813ad6cdaafe0a735b7d93b9435553a8d11d3fdd29a2 SHA512 97715a691e19e7196f7b79464f758aefb703d8712edd2d571faa1501ed9134b7a0b0e82126de089ddbf406f3ca67837a495a3afdf5fbb49c6231f27dc2654032 WHIRLPOOL dc0ec83aaf0e112c67eb580b001dadb505c9d9311076d6bdf62851e01d2cc05bc30a474a99f1c9037be0f8bbfe87f383c467ea417c708be35ce2a7c77ae59813
+DIST modules-3.2.9c.tar.bz2 340529 SHA256 5b1c99d7a0b617396e7b1ef1ab99609287887ab3fbe556d1bd18b35fa00ff025 SHA512 f65c9b7a56b2836256b9eef337c68272cff6137f2df46dcb75d1f8e0d6b023d908117023ee2e32acceb2b9482d0e2aeae7ab13505902b8a12858cb7307ba0ca0 WHIRLPOOL 5fbff41f5d3eb0c51663bae046731d7f39bb008c3214f2257b8d78423086a4623355f2d3629b2fa2969c023b6b7cd26adde6ff5821bfe1cb528c905043c242b1

+ 186 - 0
science/sys-cluster/modules/files/createmodule.py

@@ -0,0 +1,186 @@
+#!/usr/bin/python
+#
+# createmodule.py - Takes the name of a environment init script and 
+# produces a modulefile that duplicates the changes made by the init script
+#
+# Copyright (C) 2012 by Orion E. Poplawski <orion@cora.nwra.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see <http://www.gnu.org/licenses/>.
+
+from optparse import OptionParser
+import os,sys
+from subprocess import *
+
+# Handle options
+usage = "Usage: %prog [-p prefix] <initscript> [args]"
+parser = OptionParser()
+parser.set_usage(usage)
+parser.add_option('-p', '--prefix', dest='prefix', help='Specify path prefix')
+(options, args) = parser.parse_args()
+
+# Need a script name
+if not args:
+    parser.print_usage()
+    exit(1)
+
+# Return environment after a command
+def getenv(cmd = ':'):
+    env = {}
+    p = Popen(cmd + ";env", shell=True, stdout=PIPE, stderr=PIPE)
+    (stdout, stderr) = p.communicate()
+    if p.returncode != 0:
+        print "EROR: Could not execute initscript:"
+        print "%s returned exit code %d" % (cmd, p.returncode)
+        print stderr
+        exit(1)
+    if stderr != '':
+        print "WARNING: initscript sent the following to stderr:"
+        print stderr
+    # Parse the output key=value pairs
+    for line in stdout.splitlines():
+        try:
+            (var,value) = line.split('=',1)
+        except ValueError:
+            print "ERROR: Could not parse output:"
+            print stdout
+            exit(1)
+        env[var] = value
+    return env
+
+#Record initial environment
+env1=getenv()
+
+#Record environment after sourcing the initscript
+env2=getenv(". " + " ".join(args))
+
+# Initialize our variables for storing modifications
+chdir = None
+appendpath = {}
+prependpath = {}
+setenv = {}
+unsetenv = []
+pathnames = []
+
+# Function to nomalize all paths in a list of paths and remove duplicate items
+def normpaths(paths):
+    newpaths = []
+    for path in paths:
+        normpath = os.path.normpath(path)
+        if normpath not in newpaths:
+             newpaths.append(os.path.normpath(path))
+    return newpaths
+
+# Start with existing keys and look for changes
+for key in env1.keys():
+    # Test for delete
+    if key not in env2:
+        unsetenv.append(key)
+        continue
+    # No change
+    if env1[key] == env2[key]:
+        del env2[key]
+        continue
+    #Working directory change
+    if key == 'PWD':
+	chdir=os.path.normpath(env2[key])
+        pathnames.append(chdir)
+        del env2[key]
+        continue
+    # Determine modifcations to beginning and end of the string
+    (prepend,append) = env2[key].split(env1[key])
+    if prepend:
+        prependpaths = prepend.strip(':').split(':')
+        # LICENSE variables often include paths outside install directory
+        if 'LICENSE' not in key:
+            pathnames += prependpaths
+        prependpath[key] = ':'.join(normpaths(prependpaths))
+    if append:
+        appendpaths = append.strip(':').split(':')
+        # LICENSE variables often include paths outside install directory
+        if 'LICENSE' not in key:
+            pathnames += appendpaths
+        appendpath[key] = ':'.join(normpaths(appendpaths))
+    del env2[key]
+      
+# We're left with new keys in env2
+for key in env2.keys():
+    # Use prepend-path for new paths
+    if ('PATH' in key) or (':' in env2[key]):
+        prependpaths = env2[key].strip(':').split(':')
+        # MANPATH can have system defaults added it it wasn't previously set
+        # LICENSE variables often include paths outside install directory
+        if key != 'MANPATH' and 'LICENSE' not in key:
+            pathnames += prependpaths
+        prependpath[key] = ':'.join(normpaths(prependpaths))
+        continue
+    # Set new variables
+    setenv[key] = os.path.normpath(env2[key])
+    if 'LICENSE' not in key:
+        pathnames.append(setenv[key])
+
+# Determine a prefix
+prefix = None
+if options.prefix:
+    prefix = options.prefix
+else:
+    prefix = os.path.commonprefix(pathnames).rstrip('/')
+    if prefix == '':
+          prefix = None
+
+# Print out the modulefile
+print "#%Module 1.0"
+
+# Prefix
+if prefix is not None:
+    print "\nset prefix " + prefix + "\n"
+
+# Chdir
+if chdir is not None:
+    print "chdir\t" + chdir
+
+# Function to format output line with tabs and substituting prefix
+def formatline(item, key, value=None):
+    print item,
+    print "\t"*(2-(len(item)+1)/8),
+    print key,
+    if value is not None:
+        print "\t"*(3-(len(key)+1)/8),
+        if prefix is not None:
+            print value.replace(prefix,'$prefix')
+        else:
+            print value
+
+# Paths first, grouped by variable name
+pathkeys = appendpath.keys() + prependpath.keys()
+pathkeys.sort()
+for key in pathkeys:
+    if key in prependpath:
+        formatline("prepend-path",key,prependpath[key])
+    if key in appendpath:
+        formatline("append-path",key,appendpath[key])
+
+# Setenv
+setenvkeys = setenv.keys()
+setenvkeys.sort()
+if setenvkeys:
+    print
+for key in setenvkeys:
+    formatline("setenv",key,setenv[key])
+
+# Unsetenv
+unsetenv.sort()
+if unsetenv:
+    print
+for key in unsetenv:
+    formatline("unsetenv",key)

+ 166 - 0
science/sys-cluster/modules/files/createmodule.sh

@@ -0,0 +1,166 @@
+#!/bin/bash
+#
+# createmodule.sh - Takes the name of a environment init script and 
+# produces a modulefile that duplicates the changes made by the init script
+#
+# Copyright (C) 2010-2012 by Orion E. Poplawski <orion@cora.nwra.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# 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, see <http://www.gnu.org/licenses/>.
+
+usage="Usage: $0 [-p prefix] <initscript> [args]"
+
+usage() {
+  echo $usage 1>&2
+  exit 1
+}
+
+while getopts "p:" opt
+do
+  case $opt in
+    p) prefix=$OPTARG; shift 2;;
+    *) usage;;
+  esac
+done
+
+# Need a script name
+[ -z "$1" ] && usage
+
+# Need to be a readable script
+if [ ! -r "$1" ]
+then
+  echo "ERROR: Cannot read $1" 1>&2
+  exit 1 
+fi
+
+#Will print out array assignment list
+printenvarray () {
+  env | while read x
+  do
+    key=${x%%=*}
+    value=${x#*=}
+    echo [$key]="'$value'"
+  done
+}
+
+#Apparently we need to declare the associative arrays
+declare -A env1 env2
+
+#Record starting environment
+eval env1=(`printenvarray`)
+
+#Source the environment script
+. "$@"
+
+#Record ending environment
+eval env2=(`printenvarray`)
+
+#Print out the modulefile
+echo "#%Module 1.0"
+
+#Prefix
+[ -n "$prefix" ] && echo -e "\nset prefix $prefix\n"
+
+#Subshell so we can sort the output
+(
+dedup() {
+  list=`mktemp`
+  echo $1 | sed -r -e 's,[^/]+/\.\./,,g' -e 's,[^/]+/\.\./,,g' -e 's/:/\n/g' |
+    while read x
+    do
+      grep -Fx ${x} $list && continue
+      if [ -n "$prefix" ]
+      then
+        echo $x | sed -e s,$prefix,\$prefix,
+      else
+        echo $x
+      fi
+      echo $x >> $list
+    done | tr '\n' : | sed -e 's/:$//'
+  rm $list
+} 
+    
+#Keys that changed
+for key in "${!env1[@]}"
+do
+  if [ "${env1[$key]}" != "${env2[$key]}" ]
+  then
+    #Working directory change
+    if [ "$key" = PWD ]
+    then
+      if [ -n "$prefix" ]
+      then
+        echo -e "chdir\t\t${env2[PWD]}" | sed -e s,$prefix,\$prefix,g
+      else
+        echo -e "chdir\t\t${env2[PWD]}"
+      fi
+    #Test for delete
+    elif [ -z "${env2[$key]}" ]
+    then
+      echo -e "unsetenv\t${key}\t${env2[$key]}"
+    #Test for prepend
+    elif [ "${env2[$key]%${env1[$key]}}" != "${env2[$key]}" ]
+    then
+      added=$(dedup ${env2[$key]%:${env1[$key]}})
+      echo -e "prepend-path\t$key\t${added}"
+    #Test for prepend plus : added at end (MANPATH)
+    elif [ "${env2[$key]%${env1[$key]}:}" != "${env2[$key]}" ]
+    then
+      added=$(dedup ${env2[$key]%${env1[$key]}:})
+      echo -e "prepend-path\t$key\t${added}"
+    #Test for append
+    elif [ "${env2[$key]#${env1[$key]}}" != "${env2[$key]}" ]
+    then
+      added=$(dedup ${env2[$key]#:${env1[$key]}})
+      echo -e "append-path\t$key\t${added}"
+    #Test for prepend plus append
+    elif [ "${env2[$key]%${env1[$key]}:*}" != "${env2[$key]}" ]
+    then
+      added=$(dedup ${env2[$key]%:${env1[$key]}*})
+      echo -e "prepend-path\t$key\t${added}"
+      added=$(dedup ${env2[$key]#*${env1[$key]}:})
+      echo -e "append-path\t$key\t${added}"
+    else
+      #Unhandled
+      echo "Unhandled change of $key" 1>&2
+      echo "Before <${env1[$key]}>" 1>&2
+      echo "After  <${env2[$key]}>" 1>&2
+    fi
+  fi
+  #Delete keys we've handled
+  unset env1[$key]
+  unset env2[$key]
+done
+
+#New keys
+for key in "${!env2[@]}"
+do
+  if [ "$key" = OLDPWD ]
+  then
+    continue
+  fi
+  #Use prepend-path for new paths
+  if [ "${key/PATH/}" != "$key" ]
+  then
+    # TODO - Need to handle stripping of default MANPATH
+    echo -e "prepend-path\t${key}\t"$(dedup ${env2[$key]})
+  else
+    if [ -n "$prefix" ]
+    then
+      echo -e "setenv\t\t${key}\t${env2[$key]}" | sed -e s,$prefix,\$prefix,g
+    else
+      echo -e "setenv\t\t${key}\t${env2[$key]}"
+    fi
+  fi
+done
+) | sort

+ 12 - 0
science/sys-cluster/modules/files/modules-3.2.10-avail.patch

@@ -0,0 +1,12 @@
+diff -up modules-3.2.10/init/bash_completion.in.avail modules-3.2.10/init/bash_completion.in
+--- modules-3.2.10/init/bash_completion.in.avail	2012-10-25 13:33:34.000000000 -0600
++++ modules-3.2.10/init/bash_completion.in	2013-01-15 12:05:37.247309733 -0700
+@@ -56,7 +56,7 @@ _module() {
+ 	unuse)		COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "$cur") );;
+ 	use|*-a*)	;;			# let readline handle the completion
+ 	-u|--userlvl)	COMPREPLY=( $(compgen -W "novice expert advanced" -- "$cur") );;
+-	display|help|show|whatis)
++	av*|disp*|help|show|whatis)
+ 			COMPREPLY=( $(compgen -W "$(_module_avail)" -- "$cur") );;
+ 	*) if test $COMP_CWORD -gt 2
+ 	   then

+ 11 - 0
science/sys-cluster/modules/files/modules-3.2.10-bindir.patch

@@ -0,0 +1,11 @@
+--- modules-3.2.10.orig/init/Makefile.in	2009-09-22 12:13:52.000000000 -0600
++++ modules-3.2.10/init/Makefile.in	2009-09-23 12:19:50.797470155 -0600
+@@ -404,7 +404,7 @@
+ 	sed -e "/@$(if $(subst 0,,$(WANTS_VERSIONING)),NOT,)VERSIONING\@/d; \
+ 	s,@$(if $(subst 0,,$(WANTS_VERSIONING)),,NOT)VERSIONING\@,,g; \
+ 	s,@prefix\@,${prefix},g; \
+-	s,@bindir\@,${exec_prefix}/bin,g; \
++	s,@bindir\@,${bindir},g; \
+ 	s,@VERSION\@,@VERSION@,g; \
+ 	s,@BASEPREFIX\@,@BASEPREFIX@,g;" < $< > $@
+ 

+ 11 - 0
science/sys-cluster/modules/files/modules-3.2.10-clear.patch

@@ -0,0 +1,11 @@
+--- modules-3.2.9/utility.c	2011-11-28 22:27:13.000000000 +0100
++++ modules-3.2.9-new/utility.c	2012-06-13 15:17:41.570629148 +0200
+@@ -727,7 +727,7 @@ int Output_Modulefile_Changes(	Tcl_Inter
+ 			output_unset_variable( (char*) key);
+ 		} else {
+ 			val = EMGetEnv(interp, key);
+-			if(val && *val)
++			if(val)
+ 				output_set_variable(interp, (char*) key, val);
+ 			null_free((void *)&val);
+ 		}

+ 14 - 0
science/sys-cluster/modules/files/modules-3.2.10-errorline.patch

@@ -0,0 +1,14 @@
+diff -ru modules-3.2.9-old/cmdModule.c modules-3.2.9/cmdModule.c
+--- modules-3.2.9-old/cmdModule.c	2013-06-02 22:46:09.196302980 +0200
++++ modules-3.2.9/cmdModule.c	2013-06-02 22:53:36.706298800 +0200
+@@ -640,8 +640,8 @@
+             case TCL_OK:	gotPartial = 0;
+ 			        continue;	/** while **/
+ 	    
+-            case TCL_ERROR:	interp->errorLine = ((linenum-1)-gotPartial) +
+-				    interp->errorLine;
++		case TCL_ERROR:	Tcl_SetErrorLine(interp, ((linenum-1)-gotPartial) +
++										 Tcl_GetErrorLine(interp));
+ 	    			/* FALLTHROUGH */
+ 
+             case TCL_LEVEL0_RETURN:

+ 10 - 0
science/sys-cluster/modules/files/modules-3.2.10-versioning.patch

@@ -0,0 +1,10 @@
+diff -up modules-3.2.10/modulefiles/modules.in.versioning modules-3.2.10/modulefiles/modules.in
+--- modules-3.2.10/modulefiles/modules.in.versioning	2012-10-25 13:33:34.000000000 -0600
++++ modules-3.2.10/modulefiles/modules.in	2013-01-15 11:30:22.046031158 -0700
+@@ -26,5 +26,5 @@ setenv		MODULESHOME	$prefix
+ prepend-path    PATH   		@bindir@
+ prepend-path    MANPATH		@mandir@
+ 
+-module		use		@VERSIONPATH@
++@VERSIONING@module		use		@VERSIONPATH@
+ 

+ 14 - 0
science/sys-cluster/modules/files/modules-3.2.9c-errorline.patch

@@ -0,0 +1,14 @@
+diff -ru modules-3.2.9-old/cmdModule.c modules-3.2.9/cmdModule.c
+--- modules-3.2.9-old/cmdModule.c	2013-06-02 22:46:09.196302980 +0200
++++ modules-3.2.9/cmdModule.c	2013-06-02 22:53:36.706298800 +0200
+@@ -640,8 +640,8 @@
+             case TCL_OK:	gotPartial = 0;
+ 			        continue;	/** while **/
+ 	    
+-            case TCL_ERROR:	interp->errorLine = ((linenum-1)-gotPartial) +
+-				    interp->errorLine;
++		case TCL_ERROR:	Tcl_SetErrorLine(interp, ((linenum-1)-gotPartial) +
++										 Tcl_GetErrorLine(interp));
+ 	    			/* FALLTHROUGH */
+ 
+             case TCL_LEVEL0_RETURN:

+ 8 - 0
science/sys-cluster/modules/files/modules.new.sh.in

@@ -0,0 +1,8 @@
+shell=$(basename $(ps -p $$ -ocomm=))
+if [ -f @EPREFIX@/usr/share/Modules/init/${shell} ]
+then
+  . @EPREFIX@/usr/share/Modules/init/${shell}
+elif [ -f @PREFIX@/usr/share/Modules/init/${shell} ]
+then
+  . @PREFIX@/usr/share/Modules/init/sh
+fi

+ 7 - 0
science/sys-cluster/modules/files/modules.sh.in

@@ -0,0 +1,7 @@
+shell=$(basename $(ps -p $$ -ocomm=))
+if [ -f @EPREFIX@/usr/share/Modules/init/${shell} ]
+then
+  . @EPREFIX@/usr/share/Modules/init/${shell}
+else
+  . @PREFIX@/usr/share/Modules/init/sh
+fi

+ 22 - 0
science/sys-cluster/modules/metadata.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+  <maintainer type="person">
+    <email>nicolasbock@gentoo.org</email>
+    <name>Nicolas Bock</name>
+  </maintainer>
+  <maintainer type="project">
+    <email>cluster@gentoo.org</email>
+    <name>Gentoo Cluster Project</name>
+  </maintainer>
+  <longdescription lang="en">
+  The environment modules package provides for an easy dynamic
+  modification of a user's environment via modulefiles. which
+  typically instruct the module command to alter or set shell
+  environment variables such as PATH, MANPATH, etc. as well as define
+  aliases over a variety of shells.
+  </longdescription>
+  <upstream>
+    <remote-id type="sourceforge">modules</remote-id>
+  </upstream>
+</pkgmetadata>

+ 65 - 0
science/sys-cluster/modules/modules-3.2.10-r1.ebuild

@@ -0,0 +1,65 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit autotools-utils multilib
+
+DESCRIPTION="Dynamic modification of a user's environment via modulefiles"
+HOMEPAGE="http://modules.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="test X"
+
+RDEPEND="
+	dev-lang/tcl:0=
+	dev-tcltk/tclx
+	X? ( x11-libs/libX11 )"
+DEPEND="${RDEPEND}
+	test? ( dev-util/dejagnu )"
+
+S="${WORKDIR}/${P%[a-z]}"
+
+DOCS=(ChangeLog README NEWS TODO)
+
+src_prepare() {
+		
+if 	has_version ">=dev-lang/tcl-8.6.0"; then
+		echo "has_version!!"
+		epatch "${FILESDIR}"/${P}-errorline.patch
+fi
+
+	epatch \
+		"${FILESDIR}"/${P}-bindir.patch \
+		"${FILESDIR}"/${P}-versioning.patch \
+		"${FILESDIR}"/${P}-clear.patch \
+		"${FILESDIR}"/${P}-avail.patch
+	sed -e "s:@EPREFIX@:${EPREFIX}:g" \
+		"${FILESDIR}"/modules.sh.in > modules.sh
+}
+
+src_configure() {
+	local myeconfargs=(
+		--disable-versioning
+		--prefix="${EPREFIX}/usr/share"
+		--exec-prefix="${EPREFIX}/usr/share/Modules"
+		--with-module-path="${EPREFIX}/etc/modulefiles"
+		--with-tcl="${EPREFIX}/usr/$(get_libdir)"
+		$(use_with X x)
+	)
+	autotools-utils_src_configure
+}
+
+src_install() {
+echo "I am in install"
+	autotools-utils_src_install
+	insinto /etc/profile.d
+	doins modules.sh
+	exeinto /usr/share/Modules/bin
+	doexe "${FILESDIR}"/createmodule.{sh,py}
+	dosym /usr/share/Modules/init/csh /etc/profile.d/modules.csh
+	dodir /etc/modulefiles
+}

+ 48 - 0
science/sys-cluster/modules/modules-3.2.10.ebuild

@@ -0,0 +1,48 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit autotools-utils
+
+DESCRIPTION="Dynamic modification of a user's environment via modulefiles"
+HOMEPAGE="http://modules.sourceforge.net/"
+SRC_URI="http://sourceforge.net/projects/modules/files/Modules/${P%[a-z]}/${P}.tar.bz2/download -> ${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~x86 ~amd64"
+IUSE="X"
+
+DEPEND="
+	dev-lang/tcl:0=
+	dev-tcltk/tclx
+	X? ( x11-libs/libX11 )
+	"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${P%[a-z]}"
+
+DOCS=(ChangeLog README NEWS TODO)
+
+src_prepare() {
+	has_version ">=dev-lang/tcl-8.6.0" && epatch "${FILESDIR}/${P}-errorline.patch"
+}
+
+src_configure() {
+	local myeconfargs=(
+		$(use_with X x)
+		--prefix=/opt
+	)
+	autotools-utils_src_configure
+}
+
+src_install() {
+	autotools-utils_src_install
+	dosym ${PV%[a-z]} /opt/Modules/default
+}
+
+pkg_postinst() {
+	elog "Add this line at the end of your bashrc:"
+	elog "[ -f /opt/Modules/default/init/bash ] && source /opt/Modules/default/init/bash"
+}

+ 48 - 0
science/sys-cluster/modules/modules-3.2.9c-r1.ebuild

@@ -0,0 +1,48 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit autotools-utils
+
+DESCRIPTION="Dynamic modification of a user's environment via modulefiles"
+HOMEPAGE="http://modules.sourceforge.net/"
+SRC_URI="http://sourceforge.net/projects/modules/files/Modules/${P%[a-z]}/${P}.tar.bz2/download -> ${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~x86 ~amd64"
+IUSE="X"
+
+DEPEND="
+	dev-lang/tcl:0=
+	dev-tcltk/tclx
+	X? ( x11-libs/libX11 )
+	"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${P%[a-z]}"
+
+DOCS=(ChangeLog README NEWS TODO)
+
+src_prepare() {
+	has_version ">=dev-lang/tcl-8.6.0" && epatch "${FILESDIR}/${P}-errorline.patch"
+}
+
+src_configure() {
+	local myeconfargs=(
+		$(use_with X x)
+		--prefix=/opt
+	)
+	autotools-utils_src_configure
+}
+
+src_install() {
+	autotools-utils_src_install
+	dosym ${PV%[a-z]} /opt/Modules/default
+}
+
+pkg_postinst() {
+	elog "Add this line at the end of your bashrc:"
+	elog "[ -f /opt/Modules/default/init/bash ] && source /opt/Modules/default/init/bash"
+}

+ 33 - 0
science/sys-cluster/modules/modules-3.2.9c.ebuild

@@ -0,0 +1,33 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit autotools-utils
+
+DESCRIPTION="Dynamic modification of a user's environment via modulefiles"
+HOMEPAGE="http://modules.sourceforge.net/"
+SRC_URI="http://sourceforge.net/projects/modules/files/Modules/${P%[a-z]}/${P}.tar.bz2/download -> ${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="X"
+
+DEPEND="
+	dev-lang/tcl:0=
+	dev-tcltk/tclx
+	X? ( x11-libs/libX11 )
+	"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${P%[a-z]}"
+
+DOCS=(ChangeLog README NEWS TODO)
+
+src_configure() {
+	local myeconfargs=(
+		$(use_with X x)
+	)
+	autotools-utils_src_configure
+}