1 #!/usr/bin/bash
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
9 #
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
14 #
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 #
21 # CDDL HEADER END
22 #
23 #
24 # Copyright 2011-2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 SHELL=/usr/bin/bash
29 export SHELL
30 SKIP_ROOT_CHECK=1
31 if [[ -n "$SUDO_USER" ]]; then
32 echo "Don't run under sudo, just build as you"
33 exit
34 fi
35
36 # Load support functions
37 . ../../lib/functions.sh
38
39 PROG=caiman
40 VER=$RELVER
41 PKG=caiman
42 SUMMARY="$PROG"
43 DESC="$SUMMARY"
44
45 #all of the ips depends should be available from OmniTI repos
46
47 BUILD_DEPENDS_IPS="developer/sunstudio12.1 system/boot/wanboot system/boot/wanboot/internal developer/build/onbld system/library developer/versioning/git developer/swig"
48
49 GIT=git
50
51 PKGSERVER=$PKGSRVR
52 PKGPREFIX=""
53 PREFIX=""
54 TMPDIR=/code
55 BUILDDIR=$PROG-$VER
56 CODEMGR_WS=$TMPDIR/$BUILDDIR/caiman
57
58 CAIMAN_CODEMGR_WS="CODEMGR\_WS=\/code\/$BUILDDIR\/caiman"
59 CAIMAN_PKG_REDIST="PKGPUBLISHER_REDIST=omnios; export PKGPUBLISHER_REDIST;"
60 CAIMAN_PKG_BRANCH="PKGVERS_BRANCH=$PVER; export PKGVERS_BRANCH;"
61
62 sunstudio_location() {
63 logmsg "Ensuring that Sun Studio is where Caiman thinks it is..."
64 if [[ -d /opt/SUNWspro ]]; then
65 logmsg "--- fake SUNWspro directory exists, good"
66 else
67 logmsg "--- making fake SUNWspro directory"
68 logcmd mkdir -p /opt/SUNWspro || \
69 logerr "--- Error: failed to make directory"
70 fi
71 if [[ -L /opt/SUNWspro/sunstudio12.1 ]]; then
72 logmsg "--- sunstudio12.1 link exists, good"
73 else
74 logmsg "--- soft-linking to /opt/sunstudio12.1"
75 logcmd ln -s /opt/sunstudio12.1 /opt/SUNWspro/sunstudio12.1 || \
76 logerr "--- Failed: ln -s /opt/sunstudio12.1/ /opt/SUNWspro"
77 fi
78 }
79
80 #In order for the clone to work while running as root, you must have ssh'ed into the box with agent forwarding turned on. Also the sudo'er file must either have the default, group, or user set to allow SSL_AUTH_SOCK.
81
82 clone_source(){
83 logmsg "Creating build dir $TMPDIR/$BUILDDIR"
84 logcmd mkdir -p $TMPDIR/$BUILDDIR || logerr "Failed to create build directory"
85 logmsg "Entering $TMPDIR/$BUILDDIR"
86 pushd $TMPDIR/$BUILDDIR > /dev/null
87 if [[ -d caiman ]]; then
88 logmsg "Removing existing cloned repo"
89 logcmd rm -rf caiman
90 fi
91 logmsg "Cloning OMNI caiman Source..."
92 logcmd $GIT clone anon@src.omniti.com:~omnios/core/caiman || \
93 logerr "Failed to $GIT clone repo"
94 logmsg "Leaving $TMPDIR/$BUILDDIR"
95 popd > /dev/null
96 }
97
98 modify_build_script() {
99 logmsg "Entering $CODEMGR_WS"
100 pushd $CODEMGR_WS > /dev/null
101 logmsg "Changing omnios.sh variables to what we want them to be..."
102 logcmd cp usr/src/tools/env/omnios.sh . || \
103 logerr "Could not copy build environment"
104 logcmd /usr/bin/gsed -i -e 's/^.*export CODEMGR_WS=.*/export '$CAIMAN_CODEMGR_WS'/g;' omnios.sh || \
105 logerr "/usr/bin/gsed failed"
106 logcmd `echo $CAIMAN_PKG_REDIST >> omnios.sh`
107 logcmd `echo $CAIMAN_PKG_BRANCH >> omnios.sh`
108 logmsg "Leaving $CODEMGR_WS"
109 popd > /dev/null
110
111 }
112
113 build_pkgs() {
114 logmsg "Entering $CODEMGR_WS"
115 pushd $CODEMGR_WS > /dev/null
116 logmsg "Building caiman pkgs..."
117 logcmd /opt/onbld/bin/nightly omnios.sh || logerr "Nighly failed"
118 logmsg "Leaving $CODEMGR_WS"
119 popd > /dev/null
120 }
121
122 push_pkgs() {
123 logmsg "Entering $CODEMGR_WS"
124 pushd $CODEMGR_WS > /dev/null
125 logmsg "Pushing caiman pkgs to $PKGSERVER..."
126 logcmd pkgrecv -s packages/i386/nightly-nd/repo.redist/ -d $PKGSERVER 'pkg:/*'
127 logmsg "Leaving $CODEMGR_WS"
128 popd > /dev/null
129 }
130
131 init
132 prep_build
133 sunstudio_location
134 clone_source
135 modify_build_script
136 build_pkgs
137 push_pkgs
138 clean_up