5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright 2010, Richard Lowe
28 PATH
=/usr
/bin
:/usr
/sbin
31 DEFAULTONURI
="http://ipkg.sfbay/on-nightly"
32 DEFAULTONPUB
="on-nightly"
36 echo "usage: $0 [opts] [-s beName] -t beName"
37 echo "usage: $0 [opts] -r"
39 echo "\t-c consolidation : consolidation being upgraded"
40 echo "\t-d repodir : directory for repositories"
41 echo "\t-r : configure publisher only"
42 echo "\t-s : source BE to clone"
43 echo "\t-t : new BE name"
44 echo "\t-u uri : origin URI for redist repository"
45 echo "\t-U prefix: prefix for redist repository"
47 echo "\t-Z : skip updating zones"
49 echo "Update to an ON build:"
50 echo "\tonu -t newbe -d /path/to/my/ws/packages/\`uname -p\`/nightly"
52 echo "Update to the nightly build:"
55 echo "Re-enable the publishers in the current BE:"
56 echo "\tonu -r -d /path/to/my/ws/packages/\`uname -p\`/nightly"
68 [ $verbose -gt 0 ] && echo $
*
71 [ $exit_code -eq 0 ] && return
72 # pkg(1) returns 4 if "nothing to do", which is safe to ignore
73 [ $1 = "pkg" -a $exit_code -eq 4 ] && return
74 exit_error
"$*" failed
: exit code
$exit_code
77 configure_publishers
()
82 # Get the publisher name from the 'list -v' output. It may seem we
83 # could do this more tidily using 'info', but that is
86 typeset on_publisher
=$
(pkg
-R $root list
-Hv \
87 "${consolidation}-incorporation" | cut
-d/ -f3)
89 if [[ "$on_publisher" != "$redistpub" ]]; then
90 do_cmd pkg
-R $root set-publisher
--no-refresh \
91 --non-sticky $on_publisher
93 do_cmd pkg
-R $root set-publisher
-e --no-refresh -P -O $uri $redistpub
94 do_cmd pkg
-R $root refresh
--full
101 pkg
-R $root list entire
> /dev
/null
2>&1
102 [ $?
-eq 0 ] && do_cmd pkg
-R $root uninstall entire
104 configure_publishers
$root
106 do_cmd pkg
-R $root image-update
113 name
=`echo $zone | cut -d: -f 2`
114 if [ $name = "global" ]; then
118 brand
=`echo $zone | cut -d: -f 6`
119 if [ $brand != "ipkg" ]; then
123 if [ "$zone_warned" = 0 ]; then
124 echo "WARNING: Use of onu(1) will prevent use of zone attach in the new BE" >&2
125 echo "See onu(1)" >&2
129 state
=`echo $zone | cut -d: -f 3`
132 configured|incomplete
)
137 zoneroot
=`echo $zone | cut -d: -f 4`
139 echo "Updating zone $name"
140 update
$zoneroot/root
147 consolidation
="osnet"
153 while getopts :c
:d
:Ors
:t
:U
:u
:vZ i
; do
156 consolidation
=$OPTARG
161 O
) # no-op, compatibility with recommended use
188 shift `expr $OPTIND - 1`
192 if [ "$reposonly" -eq 1 ]; then
193 [ -n "$sourcebe" ] && usage
194 [ -n "$targetbe" ] && usage
195 [ "$no_zones" -eq 1 ] && usage
197 [ -z "$targetbe" ] && usage
199 [ -z "$uri" ] && uri
=$ONURI
200 [ -z "$uri" ] && uri
=$DEFAULTONURI
201 [ -z "$redistpub" ] && redistpub
=$ONPUB
202 [ -z "$redistpub" ] && redistpub
=$DEFAULTONPUB
204 if [ -n "$repodir" ]; then
205 redistdir
=$repodir/repo.redist
206 [ -d $redistdir ] || exit_error
"$redistdir not found"
207 typeset cfgfile
=$redistdir/cfg_cache
208 [[ ! -e $cfgfile ]] && cfgfile
=$redistdir/pkg5.repository
209 # need an absolute path
210 [[ $redistdir == /* ]] || redistdir
=$PWD/$redistdir
211 redistpub
=$
(python@PYTHON_VERSION@
<<# EOF
213 p
= ConfigParser.SafeConfigParser
()
215 pp
= p.get
("publisher", "prefix")
217 EOF
) || exit_error
"Cannot determine publisher prefix"
218 [[ -n "$redistpub" ]] || exit_error
"Repository has no publisher prefix"
219 uri
="file://$redistdir"
222 if [ "$reposonly" -eq 1 ]; then
223 configure_publishers
/
228 [ -n "$sourcebe" ] && createargs
="-e $sourcebe"
230 # ksh seems to have its own mktemp with slightly different semantics
231 tmpdir
=`/usr/bin/mktemp -d /tmp/onu.XXXXXX`
232 [ -z "$tmpdir" ] && exit_error
"mktemp failed"
234 do_cmd beadm create
$createargs $targetbe
235 do_cmd beadm mount
$targetbe $tmpdir
237 do_cmd beadm activate
$targetbe
239 if [ "$no_zones" != 1 ]; then
240 for zone
in `do_cmd zoneadm -R $tmpdir list -cip`; do