aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE.txt28
-rw-r--r--README.md49
-rw-r--r--conda.sh231
3 files changed, 308 insertions, 0 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..e547176
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,28 @@
+Copyright (C) 2016 Association of Universities for Research in Astronomy (AURA)
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ 3. The name of AURA and its representatives may not be used to
+ endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2a30469
--- /dev/null
+++ b/README.md
@@ -0,0 +1,49 @@
+# ssb-utils
+
+A collection of wrappers for use by the Science Software Branch at STScI.
+
+# Installation
+
+```bash
+git clone http://github.com/astroconda/ssb-utils.git
+```
+
+It is recommended you copy the `ssb-utils` directory to a "safe" place (i.e. not your `Downloads` directory)
+
+# Requirements
+
+- BASH >=3.2
+
+## conda.sh
+
+### Activation
+
+```bash
+source /path/to/ssb-utils/conda.sh
+```
+
+### Usage
+
+```bash
+$ ssb --help
+Usage: ssb {-i|-u} {-p|-d} [-an] [[package] ...]
+
+General Arguments:
+ --help -h This usage message
+ --name [env] -n Update existing environment by name
+ --public -p Use astroconda
+ --dev -d Use conda-dev
+ --all -a Update all packages (supersedes [package] requests)
+ --yes -y Do not prompt (use with care)
+
+Mode Arguments:
+ --install -i Perform an installation
+ --update -u Perform an update
+
+Positional Arguments:
+package Name of package(s) to update
+```
+
+# Support
+
+Use at your own risk.
diff --git a/conda.sh b/conda.sh
new file mode 100644
index 0000000..049354b
--- /dev/null
+++ b/conda.sh
@@ -0,0 +1,231 @@
+#!/bin/bash
+
+export SSB_CHANNEL_PUBLIC=http://ssb.stsci.edu/astroconda
+export SSB_CHANNEL_DEV=http://ssb.stsci.edu/conda-dev
+
+
+function ssb_emesg
+{
+ echo "ERROR: $@"
+}
+
+
+function ssb_entry_checkpoint
+{
+ if ! hash conda 2>/dev/null; then
+ ssb_emesg "'conda' was not found in your PATH"
+ return 1
+ fi
+
+ return 0
+}
+
+ssb_entry_checkpoint
+retval=$?
+if [[ $retval != 0 ]]; then
+ return $retval
+fi
+unset -f ssb_entry_checkpoint
+
+
+function ssb_usage
+{
+ echo "Usage: ssb {-i|-u} {-p|-d} [-an] [[package] ...]
+
+General Arguments:
+ --help -h This usage message
+ --name [env] -n Update existing environment by name
+ --public -p Use astroconda
+ --dev -d Use conda-dev
+ --all -a Update all packages (supersedes [package] requests)
+ --yes -y Do not prompt (use with care)
+
+Mode Arguments:
+ --install -i Perform an installation
+ --update -u Perform an update
+
+Positional Arguments:
+package Name of package(s) to update
+
+"
+ return 0
+}
+
+
+function ssb
+{
+ local cmd="conda "
+ local opts=""
+ local is_public=0
+ local is_dev=0
+ local is_all=0
+ local is_named=0
+ local is_create=0
+ local is_update=0
+ local is_install=0
+
+ if [[ $# < 1 ]]; then
+ ssb_emesg "Not enough arguments"
+ ssb_usage
+ return 1
+ fi
+
+ while [[ $# > 0 ]]
+ do
+ key=$1
+
+ case $key in
+ --help|-h)
+ ssb_usage
+ return 0
+ ;;
+
+ --create|-c)
+ is_create=1
+ ;;
+
+ --install|-i)
+ is_install=1
+ ;;
+
+ --update|-u)
+ is_update=1
+ ;;
+
+ --name|-n)
+ opts+="--name $2 "
+ is_named=1
+ shift
+ ;;
+
+ --dev|-d)
+ opts+="--override-channels -c $SSB_CHANNEL_DEV -c defaults "
+ is_public=1
+ ;;
+
+ --public|-p)
+ opts+="--override-channels -c $SSB_CHANNEL_PUBLIC -c defaults "
+ is_dev=1
+ ;;
+
+ --all|-a)
+ opts+="--all "
+ is_all=1
+ ;;
+
+ --yes|-y)
+ opts+="--yes "
+ ;;
+ *)
+ opts+="$key "
+ ;;
+ esac
+
+ shift
+ done
+
+
+ if [[ $is_public != 0 ]] && [[ $is_dev != 0 ]]; then
+ ssb_emesg "--public and --dev are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_public == 0 ]] && [[ $is_dev == 0 ]]; then
+ ssb_emesg "--public or --dev must be specified"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_install == 0 ]] && [[ $is_update == 0 ]] && [[ $is_create == 0 ]]; then
+ ssb_emesg "--install, --update, or --create is required"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_all != 0 ]]; then
+ if [[ $is_public == 0 ]] && [[ $is_dev == 0 ]]; then
+ ssb_emesg "--all cannot be used without --public or --dev"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_install != 0 ]]; then
+ ssb_emesg "--all cannot be used with --install"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_create != 0 ]]; then
+ ssb_emesg "--all cannot be used with --create"
+ ssb_usage
+ return 1
+ fi
+ fi
+
+ if [[ $is_install != 0 ]]; then
+ if [[ $is_update != 0 ]]; then
+ ssb_emesg "--install and --update are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_create != 0 ]]; then
+ ssb_emesg "--install and --create are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+ fi
+
+ if [[ $is_update != 0 ]]; then
+ if [[ $is_install != 0 ]]; then
+ ssb_emesg "--update and --install are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_create != 0 ]]; then
+ ssb_emesg "--update and --create are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+ fi
+
+ if [[ $is_create != 0 ]]; then
+ if [[ $is_install != 0 ]]; then
+ ssb_emesg "--create and --install are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+
+ if [[ $is_update != 0 ]]; then
+ ssb_emesg "--create and --update are mutually exclusive options"
+ ssb_usage
+ return 1
+ fi
+ fi
+
+ if [[ $is_install != 0 ]]; then
+ opts="install $opts"
+ fi
+
+ if [[ $is_update != 0 ]]; then
+ opts="update $opts"
+ fi
+
+ if [[ $is_create != 0 ]]; then
+ opts="create $opts"
+ fi
+
+ if [[ -z $CONDA_PREFIX ]] && [[ $is_named == 0 ]]; then
+ ssb_emesg "Refusing to corrupt base installation!"
+ ssb_emesg "You are not in an active conda environment!"
+ ssb_emesg "Use --name to update a specific environment!"
+ ssb_usage
+ return 1
+ fi
+
+ $cmd $opts
+}
+
+export -f ssb