summaryrefslogtreecommitdiff
path: root/dist/nsb-package
blob: f51c150ccdf6c90ac47f6dce928cc9943f7dedb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
#
# $Id$
# Author: Robert Story <rstory@freesnmp.com>
#
########################################################################
########################################################################

usage()
{
   echo "Usage: $0  [params] VERSION"
   echo ""
   echo "  params: [-c] [-d] [-P] [-s NSB_SRC_DIR] [-b BUILDD] [-i NSB_INSTALL_DIR]"
   echo "          [-h host] [-p path]"
   echo ""
   echo " VERSION    : release number (eg 5.2.2)"
   echo " -s NSB_SRC_DIR  : source directory [$HOME/src/net-snmp-VERSION]"
   echo " -b BUILDD  : build directory [$HOME/build/]"
   echo "              NOTE-platform will be appended to build directory"
   echo " -i NSB_INSTALL_DIR: install directory [$HOME/build/\$PLATFORM/usr]"
   echo ""
   echo " -x : configure extra features for pre-release testing"
   echo " -c : skip configure"
   echo " -d : dirty build (don't make distclean)"
   echo " -m : skip 'make all'"
   echo " -P : pause at prompts in between stages"
   echo " -r : remove build dir (rm -fR) before build"
   echo " -R : remove build dir (rm -fR) after successful build"
   echo " -t : skip 'make test'"
   echo " -C : don't source $HOME/.snmp/nsb-package"
   echo ""
   echo " -h : host to upload results to"
   echo " -p : path to upload results to"
   exit 1
}

#trap exit SIGINT

#set -x

# make getopts work on Tru64 by respawning in Posix mode
if [ "`uname`" = "OSF1" -a "$BIN_SH" != "xpg4" ]; then
    BIN_SH=xpg4
    export BIN_SH
    exec $0 $*
fi

#
# find nsb-platform based on the path to this script
#
EXE_PATH=`dirname $0`
if [ ! -f $EXE_PATH/nsb-functions ];then
   if [ -f $HOME/bin/nsb-functions ]; then
      EXE_PATH=$HOME/bin
   elif [ -f nsb-functions ];then
      EXE_PATH=$PWD
   else
      echo "Cannot find nsb-functions in $EXE_PATH, $HOME/bin or $PWD"
      exit 1
   fi
fi

if [ "x$1" = "x-C" ]; then
    shift
else
    if [ -f $HOME/.snmp/nsb-package ];then
        . $HOME/.snmp/nsb-package
    fi
fi

########################################################################
########################################################################

REMOVE_SUCCESS=0

#      x)  x=$OPTARG ;;
while getopts b:cdh:i:mPp:rRs:tx opt
do
    case "$opt" in
      b)  NSB_BUILD_DIR=$OPTARG ;;
      c)  NSB_SKIP_CONFIG=1 ;;
      d)  NSB_CLEAN=0 ;;
      h)  NSB_SCP_HOST=$OPTARG ;;
      i)  NSB_INSTALL_DIR=$OPTARG ;;
      m)  NSB_SKIP_BUILD=1 ;;
      P)  NSB_PROMPT=1 ;;
      p)  NSB_SCP_DEST=$OPTARG ;;
      r)  NSB_CLEAN=2 ;;
      R)  REMOVE_SUCCESS=1 ;;
      s)  NSB_SRC_DIR=$OPTARG ;;
      t)  NSB_SKIP_TEST=1 ;;
      x)  NSB_CONFIG_ALL=1;;
      \?)# unknown flag
        usage;;
    esac
done
shift `expr $OPTIND - 1`

if [ $# -ne 1 ]; then
   echo "expecting 1 argument, got $# ($@)"
   usage
fi

NSB_VERSION=$1

. $EXE_PATH/nsb-functions

nsb_default_paths

if [ $NSB_CLEAN -eq 1 ]; then
   if [ $NSB_SKIP_CONFIG -eq 1 ]; then
      echo "A clean build also requires configuration (-d and -c"
      echo "cannot both be specified)."
      usage
   fi
fi


########################################################################
########################################################################
nsb_prompt "press enter to build $NSB_SRC_DIR in $NSB_BUILD_DIR, and install in $NSB_INSTALL_DIR"
nsb_build $NSB_VERSION $NSB_SRC_DIR $NSB_BUILD_DIR $NSB_INSTALL_DIR $NSB_CONFIG_ALL
rc=$?
if [ "x$NSB_SCP_HOST" != "x" ]; then
   nsb_upload $NSB_BUILD_DIR $NSB_SCP_HOST:$NSB_SCP_DEST/$NSB_VERSION/$NSB_HOST/
fi
if [ $rc -eq 0 ] && [ $REMOVE_SUCCESS -eq 1 ];then
    nsb_prompt "press enter to remove $NSB_BUILD_DIR"
    if [ "x$NSB_BUILD_DIR" = "/" ]; then
       nsb_abort "Not running rm -fR from /"
    else
       /bin/rm -fR $NSB_BUILD_DIR > /dev/null 2>&1
    fi
fi

nsb_prompt "press enter to exit with rc $RC"
exit $rc