diff options
| -rw-r--r-- | scripts/cbc_functions.inc | 92 | ||||
| -rwxr-xr-x | scripts/cbc_monolith | 147 | ||||
| -rwxr-xr-x | scripts/cbc_repo_clean | 27 | ||||
| -rwxr-xr-x | scripts/cbc_repo_copy | 16 | 
4 files changed, 282 insertions, 0 deletions
diff --git a/scripts/cbc_functions.inc b/scripts/cbc_functions.inc new file mode 100644 index 0000000..6713d81 --- /dev/null +++ b/scripts/cbc_functions.inc @@ -0,0 +1,92 @@ +if [[ -n $BASH_VERSION ]] && \ +    [[ "$(basename "$0" 2> /dev/null)" == "cbc_functions.inc" ]]; then +        echo "$(basename "$0") is designed to be sourced not executed." +        exit 1  +fi +function success { +    echo $? +}; export -f success + +function program_exists { +    PROGRAM="$1" +    which $PROGRAM &>/dev/null +    if [ `success` -ne 0 ]; then +        echo 1 +    fi +    echo 0 +} + +function user_choice { +    local yn= +    read yn + +    while true +    do +        case "$yn" in +            Y|y) +                echo 0 +                break +            ;; +            *) +                echo 1 +                break +            ;; +        esac +    done + +} + +function get_conda_build { +    _OK=`program_exists conda` +    if [ ! $_OK ]; then +        echo '' +    fi +    echo $( echo $( readlink -f $(dirname `which conda`)/../conda-bld ) ) +} + +function get_conda_repo { +    _OK=`program_exists conda` +    if [ ! $_OK ]; then +        echo "Cannot locate local conda repository." +        exit 1 +    fi + +    get_os_info +    echo "$(echo $(get_conda_build)/$OS-$ARCH)" +} + +function get_os_info { +    OS= +    ARCH= +    _OS=`uname -s` +    _ARCH=`uname -m` + +    case "$_OS" in +        Darwin) +            OS=osx +        ;; +        Linux) +            OS=linux +        ;; +        *) +            echo "Unsupported operating system" +            exit 1 +        ;; +    esac + +    case "$_ARCH" in +        i3*|i6*|x86) +            ARCH=32 +        ;; +        x86_64) +            ARCH=64 +        ;; +        *) +            echo "Unknown architecture" +            exit 1 +        ;; +    esac + +    export OS +    export ARCH +} diff --git a/scripts/cbc_monolith b/scripts/cbc_monolith new file mode 100755 index 0000000..0d6dcce --- /dev/null +++ b/scripts/cbc_monolith @@ -0,0 +1,147 @@ +#!/bin/bash +EXEC_PATH=$(dirname "${BASH_SOURCE[0]}") +source "$EXEC_PATH/cbc_functions.inc" +LOGFILE="monolith.log" +LOGFILE_PREV="$LOGFILE.prev" +start_pos= + +PYTHON_VERSION="3.4" +NUMPY_VERSION="1.9" + +function usage { +    echo "usage: $(basename $0) {manifest} [-pnco] +    manifest                List of recipes to build (in order) +    --python            -p  Version to pass to conda-build +    --numpy             -n  Version to pass to conda-build +    --cbc-recipes       -c  Path to CBC recipes directory +    --cbc-output-dir    -o  Path to CONDA recipes +    " +} + +function build_restart { +    if [ -f "$LOGFILE" ]; then +        echo "Build restarting..." +        cp -av "$LOGFILE" $LOGFILE.prev +        sync +        export start_pos=$(tail -n 1 "$LOGFILE_PREV" | tr -d ' ') +    fi +} + +function build_prepare { +    echo "Translating CBC recipes..." +    cbc_build --no-build $(echo $CBC_RECIPES/*/*.ini) +    _OK=`success` +    if [ $_OK -ne 0 ]; then +        echo "Something went wrong with cbc_build..." +        exit 1 +    fi +} + +function build() { +    CWD=`pwd` +    while read recipe +    do +        if [ -n "$start_pos" ]; then +            if [[ $recipe != $start_pos ]]; then +                echo "Skipping: $recipe" +                continue  +            else +                # Iterate through remaining recipes +                unset start_pos +            fi +        fi +     +        cd "$CBC_HOME" +     +        conda build \ +            --no-binstar-upload \ +            --python $PYTHON_VERSION \ +            --numpy $NUMPY_VERSION \ +            --override-channels -c defaults "$recipe" +     +        _OK=`success` +        if [ $_OK -ne 0 ]; then +            echo +            echo "Monolithic build failure..." +            echo "Cause:" +            echo "    $recipe" +     +            cd "$CWD" +            exit $_OK +        fi +    done < "$MANIFEST" +    cd "$CWD" +} + +function bad_arg { +    usage +    echo "Bad argument: $@" +    exit 1 +} + +ARGC="${#}" +if [[ ${ARGC} < 1 ]]; then +    usage +    exit 1 +fi + +MANIFEST="$1" +if [ ! -f "$MANIFEST" ]; then +    echo "\"$MANIFEST\" does not exist." +    exit 1 +fi + + +# MAIN +shift +while [ $# -gt 0 ]; +do +    case "$1" in +        '') +            usage +            exit 1 +        ;; +        --python|-p) +            PYTHON_VERSION="$2" +            if [ -z "$PYTHON_VERSION" ]; then +                bad_arg "Missing python version." +            fi +            shift +        ;; +        --numpy|-n) +            NUMPY_VERSION="$2" +            if [ -z "$NUMPY_VERSION" ]; then +                bad_arg "Missing numpy version." +            fi +            shift +        ;; +        --cbc-recipes|-c) +            CBC_RECIPES="$2" +            if [ -z "$CBC_RECIPES" ]; then +                bad_arg "Missing recipe directory." +            fi +            shift +        ;; +        --cbc-output-dir|-o) +            CBC_HOME="$2" +            if [ -z "$CBC_HOME" ]; then +                bad_arg "Missing conda recipe directory." +            fi +            shift +        ;; +        *) +            echo "Unknown option: $1" +            usage +            exit 1 +        ;; +    esac +    shift +done + +# DO NOT LOG THIS... +build_prepare +build_restart + +# LOG THIS +( build ) 2>&1 | tee "$LOGFILE" + diff --git a/scripts/cbc_repo_clean b/scripts/cbc_repo_clean new file mode 100755 index 0000000..d7dbb83 --- /dev/null +++ b/scripts/cbc_repo_clean @@ -0,0 +1,27 @@ +#!/bin/bash +EXEC_PATH=$(dirname "${BASH_SOURCE[0]}") +source "$EXEC_PATH/cbc_functions.inc" + +CONDA_BUILD=$(get_conda_build) +REPO=$(get_conda_repo) + +if [ ! -d "$CONDA_BUILD" ]; then +    echo "Oops... No conda-bld directory" +    exit 1 +fi + +if [ ! -d "$REPO" ]; then +    echo "No local repo found." +    exit 1 +fi + +echo "This operation will destory conda's local package repository." +echo -n "Do you wish to continue? [y/N]: " +if [ `user_choice` -ne 0 ]; then +    echo "Aborting." +    exit 255 +fi + +cd "$REPO" +rm -rf *.bz2 +conda index . diff --git a/scripts/cbc_repo_copy b/scripts/cbc_repo_copy new file mode 100755 index 0000000..ff036ed --- /dev/null +++ b/scripts/cbc_repo_copy @@ -0,0 +1,16 @@ +#!/bin/bash +EXEC_PATH=$(dirname "${BASH_SOURCE[0]}") +source "$EXEC_PATH/cbc_functions.inc" + +get_os_info +REPO="$(get_conda_repo)" +REPO_NEW="$OS-$ARCH" + +if [ -d "$REPO_NEW" ]; then +    rm -rf "$REPO_NEW" +fi + +mkdir -p $REPO_NEW +rsync -aH --progress "$REPO"/ "$REPO_NEW" +cd "$REPO_NEW" +conda index .  | 
