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 BUILDDIR=$PROG-$VER
55 CODEMGR_WS=$TMPDIR/$BUILDDIR/caiman
56 ON_CLOSED_BINS="$CODEMGR_WS/closed"
57 export ON_CLOSED_BINS
58
59 CAIMAN_CODEMGR_SEDSTRING="s/CODEMGR_WS=.*/CODEMGR_WS=`echo $CODEMGR_WS | sed 's/\//\\\\\//g'`/g"
60 CAIMAN_PKG_REDIST="PKGPUBLISHER_REDIST=omnios; export PKGPUBLISHER_REDIST;"
61 CAIMAN_PKG_BRANCH="PKGVERS_BRANCH=$PVER; export PKGVERS_BRANCH;"
62
63 sunstudio_location() {
64 logmsg "Ensuring that Sun Studio is where Caiman thinks it is..."
65 if [[ -d /opt/SUNWspro ]]; then
66 logmsg "--- fake SUNWspro directory exists, good"
67 else
68 logmsg "--- making fake SUNWspro directory"
69 logcmd mkdir -p /opt/SUNWspro || \
70 logerr "--- Error: failed to make directory"
71 fi
72 if [[ -L /opt/SUNWspro/sunstudio12.1 ]]; then
73 logmsg "--- sunstudio12.1 link exists, good"
74 else
75 logmsg "--- soft-linking to /opt/sunstudio12.1"
76 logcmd ln -s /opt/sunstudio12.1 /opt/SUNWspro/sunstudio12.1 || \
77 logerr "--- Failed: ln -s /opt/sunstudio12.1/ /opt/SUNWspro"
78 fi
79 }
80
81 #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.
82
83 clone_source(){
84 logmsg "Creating build dir $TMPDIR/$BUILDDIR"
85 logcmd mkdir -p $TMPDIR/$BUILDDIR || logerr "Failed to create build directory"
86 logmsg "Entering $TMPDIR/$BUILDDIR"
87 pushd $TMPDIR/$BUILDDIR > /dev/null
88 if [[ -d caiman ]]; then
89 logmsg "Removing existing cloned repo"
90 logcmd rm -rf caiman
91 fi
92 logmsg "Cloning OMNI caiman Source..."
93 logcmd $GIT clone anon@src.omniti.com:~omnios/core/caiman || \
94 logerr "Failed to $GIT clone repo"
95 logmsg "Leaving $TMPDIR/$BUILDDIR"
96 popd > /dev/null
97 }
98
99 modify_build_script() {
100 logmsg "Entering $CODEMGR_WS"
101 pushd $CODEMGR_WS > /dev/null
102 logmsg "Changing omnios.sh variables to what we want them to be..."
103 logcmd cp usr/src/tools/env/omnios.sh . || \
104 logerr "Could not copy build environment"
105 logcmd /usr/bin/sed -I -e $CAIMAN_CODEMGR_SEDSTRING omnios.sh || \
106 logerr "/usr/bin/sed failed"
107 logcmd `echo $CAIMAN_PKG_REDIST >> omnios.sh`
108 logcmd `echo $CAIMAN_PKG_BRANCH >> omnios.sh`
109 logmsg "Leaving $CODEMGR_WS"
110 popd > /dev/null
111
112 }
113
114 closed_bins() {
115 logmsg "Entering $CODEMGR_WS"
116 pushd $CODEMGR_WS > /dev/null
117 logmsg "Getting Closed Source Bins..."
118 for bin in on-closed-bins.i386.tar.bz2 on-closed-bins-nd.i386.tar.bz2 ; do
119 if [[ ! -f $bin ]]; then
120 logcmd curl -s -O http://mirrors.omniti.com/illumos-gate/$bin
121 fi
122 logcmd tar xpf $bin
123 done
124 logmsg "Leaving $CODEMGR_WS"
125 popd > /dev/null
126 }
127
128 build_pkgs() {
129 logmsg "Entering $CODEMGR_WS"
130 pushd $CODEMGR_WS > /dev/null
131 logmsg "Building caiman pkgs..."
132 logcmd /opt/onbld/bin/nightly omnios.sh || logerr "Nightly failed"
133 logmsg "Leaving $CODEMGR_WS"
134 popd > /dev/null
135 }
136
137 push_pkgs() {
138 logmsg "Entering $CODEMGR_WS"
139 pushd $CODEMGR_WS > /dev/null
140 logmsg "Pushing caiman pkgs to $PKGSERVER..."
141 logcmd pkgrecv -s packages/i386/nightly-nd/repo.redist/ -d $PKGSERVER 'pkg:/*'
142 logmsg "Leaving $CODEMGR_WS"
143 popd > /dev/null
144 }
145
146 init
147 prep_build
148 sunstudio_location
149 clone_source
150 modify_build_script
151 closed_bins
152 build_pkgs
153 push_pkgs
154 clean_up