#!/bin/bash

VERSION="$1"
if [ "x$VERSION" = "x" ]; then
    echo "Please specify a git tree to checkout. Examples:"
    echo "  ./submit-build master"
    echo "  ./submit-build 4.2"
    exit 1
fi

EMAIL="$2"
if [ "x$EMAIL" = "x" ]; then
    echo "Please specify a notification email address as second arguent."
    echo "Example:"
    echo "  ./submit-build master rynge@isi.edu"
    exit 1
fi

# nmi env
export _NMI_HOME=$HOME
export _NMI_HOSTNAME=$HOSTNAME
export _NMI_SUBMITDIR=$PWD

cat >cmdfile <<EOF
# DO NOT EDIT - this file is automatically generated

project = Pegasus
project_release = $VERSION
component = $VERSION - Full build
component_version = $VERSION
description = Pegasus Build and Test
run_type = build

platform_type = nmi

inputs = remote-declare.scp, remote-post.scp, build-pegasus.scp, platform-post.scp, ant.url, github-source.url

remote_declare = remote-declare
remote_task = build-pegasus
remote_post = remote-post
platform_post = platform-post

remote_default_timeout=2h

platforms = x86_64_Debian5, x86_64_Debian6, x86_64_MacOSX7, x86_64_RedHat5, x86_64_RedHat6, x86_RedHat5, x86_RedHat6

#prereqs =  apache-ant-1.7.0
#prereqs =  wget-1.9.1, apache-ant-1.7.0

#prereqs_x86_64_rhap_6.2 = ant-1.7.1-13.el6.x86_64 

notify=$EMAIL
EOF

cat >github-source.url <<EOF
# DO NOT EDIT - this file is automatically generated
method = url
url = https://github.com/pegasus-isi/pegasus/archive/$VERSION.tar.gz
untar = false
EOF

nmi_submit --must-match --notify-fail-only  cmdfile


