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 2017 OmniTI Computer Consulting, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 # Load support functions
28 . ../../lib/functions.sh
29
30 # This are used so people can see what packages get built.. pkg actually publishes
31 PKG=package/pkg
32 PKG=system/zones/brand/ipkg
33 PKG=system/zones/brand/lipkg
34 SUMMARY="This isn't used, it's in the makefiles for pkg"
35 DESC="This isn't used, it's in the makefiles for pkg"
36
37 PROG=pkg
38 VER=omni
39 BUILDNUM=$RELVER
40 if [[ -z "$PKGPUBLISHER" ]]; then
41 logerr "No PKGPUBLISHER specified. Check lib/site.sh?"
42 exit # Force it, we're fucked here.
43 fi
44
45 GIT=/usr/bin/git
46 # On a running system, these are in /usr/include/.
47 HEADERS="libbrand.h libuutil.h libzonecfg.h"
48 BRAND_CFLAGS="-I./gate-include"
49
50 BUILD_DEPENDS_IPS="developer/versioning/git developer/versioning/mercurial system/zones/internal"
51 DEPENDS_IPS="runtime/python-27"
52
53 crib_headers(){
54 # Use PREBUILT_ILLUMOS if available, otherwise, just pull off the
55 # running system.
56 mkdir -p $TMPDIR/$BUILDDIR/pkg/src/brand/gate-include ||
57 logerr "Cannot create include stub directory"
58 for hdr in $HEADERS; do
59 # first just copy from the running system
60 cp /usr/include/$hdr $TMPDIR/$BUILDDIR/pkg/src/brand/gate-include/. ||
61 logerr "Copy $hdr from /usr/include failed"
62 # then see if we can get the more recent PREBUILT_ILLUMOS version...
63 cp $PREBUILT_ILLUMOS/proto/root_`uname -p`/usr/include/$hdr \
64 $TMPDIR/$BUILDDIR/pkg/src/brand/gate-include/. ||
65 logmsg "Copy $hdr from PREBUILT_ILLUMOS ($PREBUILT_ILLUMOS) failed. Using /usr/include version."
66 done
67 }
68
69 # Respect an environmental override on this, for development's sake.
70 PKG_SOURCE_REPO=${PKG_SOURCE_REPO:-https://github.com/omniti-labs/pkg5}
71
72 clone_source(){
73 logmsg "pkg -> $TMPDIR/$BUILDDIR/pkg"
74 logcmd mkdir -p $TMPDIR/$BUILDDIR
75 pushd $TMPDIR/$BUILDDIR > /dev/null
76 # Even though our default is "pkg5" now, still call the directory
77 # "pkg" for now due to the hideous number of places "pkg" occurs here.
78 if [[ ! -d pkg ]]; then
79 logcmd $GIT clone $PKG_SOURCE_REPO pkg
80 fi
81 pushd pkg > /dev/null || logerr "no source"
82 logcmd $GIT pull || logerr "failed to pull"
83 logcmd $GIT checkout r$RELVER || logmsg "No r$RELVER branch, using master."
84 popd > /dev/null
85 popd > /dev/null
86 }
87
88 build(){
89 pushd $TMPDIR/$BUILDDIR/pkg/src > /dev/null || logerr "Cannot change to src dir"
90 find . -depth -name \*.mo -exec touch {} \;
91 touch `find gui/help -depth -name \*.in | sed -e 's/\.in$//'`
92 pushd $TMPDIR/$BUILDDIR/pkg/src/brand > /dev/null
93 logmsg "--- brand subbuild"
94 logcmd make clean
95 ISALIST=i386 CC=gcc CFLAGS="$BRAND_CFLAGS" logcmd make \
96 CODE_WS=$TMPDIR/$BUILDDIR/pkg || logerr "brand make failed"
97 popd
98 logmsg "--- toplevel build"
99 logcmd make clean
100 ISALIST=i386 CC=gcc logcmd make \
101 CODE_WS=$TMPDIR/$BUILDDIR/pkg || logerr "toplevel make failed"
102 logmsg "--- proto install"
103 ISALIST=i386 CC=gcc logcmd make install \
104 CODE_WS=$TMPDIR/$BUILDDIR/pkg || logerr "proto install failed"
105 popd > /dev/null
106 }
107 package(){
108 pushd $TMPDIR/$BUILDDIR/pkg/src/pkg > /dev/null
109 logmsg "--- packaging"
110 logcmd make clean
111 ISALIST=i386 CC=gcc logcmd make \
112 CODE_WS=$TMPDIR/$BUILDDIR/pkg \
113 BUILDNUM=$BUILDNUM || logerr "pkg make failed"
114 ISALIST=i386 CC=gcc logcmd make publish-pkgs \
115 CODE_WS=$TMPDIR/$BUILDDIR/pkg \
116 BUILDNUM=$BUILDNUM \
117 PKGSEND_OPTS="" \
118 PKGPUBLISHER=$PKGPUBLISHER \
119 PKGREPOTGT="" \
120 PKGREPOLOC="$PKGSRVR" \
121 || logerr "publish failed"
122 popd > /dev/null
123 }
124
125 init
126 clone_source
127 # This is hugely expensive
128 # We've committed these files to pkg, but they need to be kept up to date
129 #crib_headers
130 build
131 package