Mercurial > illumos > illumos-gate
changeset 13160:fe1e90cb470e
99 onu should not hardcode opensolaris.org, shaft the unsuspecting
Reviewed by: alan.coopersmith@gmail.com, mcbofh@gmail.com
Approved by: garrett@nexenta.com
author | Richard Lowe <richlowe@richlowe.net> |
---|---|
date | Sun, 29 Aug 2010 21:12:07 -0400 |
parents | 790ae15f3cb7 |
children | 35133fa0d604 |
files | usr/src/tools/scripts/onu.1 usr/src/tools/scripts/onu.sh |
diffstat | 2 files changed, 49 insertions(+), 140 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/tools/scripts/onu.1 Sat Aug 28 21:08:04 2010 +0200 +++ b/usr/src/tools/scripts/onu.1 Sun Aug 29 21:12:07 2010 -0400 @@ -18,11 +18,12 @@ .\" " CDDL HEADER END .\" " .\" "Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. -.\" -.TH onu 1 "20 July 2010" +.\" "Copyright 2010, Richard Lowe +.\" " +.TH onu 1 "28 August 2010" .SH NAME .I onu -\- Os/Net Update +\- OS/Net Update .SH SYNOPSIS \fBonu [opts] [-s <beName>] -t <beName>\fP .br @@ -37,34 +38,22 @@ used to update a system with the latest set of IPS packages for the ON (OS/Net) consolidation of Solaris, using beadm(1M) to create a new Boot Environment (BE) and pkg(1) to update the image. -.LP -After updating an image, -.I onu -can then be used to start repository depot servers, in preparation for -using -.I pkg -to install additional packages and/or zones. .SH OPTIONS .LP The following global options are supported: .TP 4 -.B \-d <dir> -Specifies that <dir> contains repo.redist and repo.extra sub-directories; -.I onu -will stand up a depot for each and use them for the publisher and extra -packaging repositories. Note that -d ignores -u, -U, -e, and -E, as well -as the environment variables used by those options. +.B \-c <consolidation> +Specifies the consolidation being installed via +.IR onu , +used to locate the publisher from which that consolidation is currently +installed. This is almost always "osnet". .TP 4 -.B \-e <URI> -Specifies that <URI> should be used as the origin URI for the extra repository. -See \fBONEXTRAURI\fP below for default values. -.TP 4 -.B \-E <publisher> -Specifies that <publisher> should be used as the publisher name for -the extra repository. See \fBONEXTRAPUB\fP below for default values. -.TP 4 -.B \-O -Open mode, where the extra repository will not be used. +.B \-d <dir> +Specifies that <dir> contains the repo.redist sub-directory; +.I onu +will run a depot using this packaging repository. +Note that -d ignores -u and -U as well +as the environment variables used by those options. .TP 4 .B \-u <URI> Specifies that <URI> should be used as the origin URI for the publisher @@ -94,10 +83,8 @@ The second form of onu takes the following option: .TP 4 .B \-r -In the current BE, create the repository depot servers and configure -the requested publishers appropriately, without updating. After -\fBonu\fP exits, one or two pkg.depotd servers will be left running, -allowing \fBpkg\fP operations using the related publishers to succeed. +In the current BE configure the requested publisher appropriately, without +updating. .SH EXIT STATUS .LP The following exit values are returned: @@ -197,21 +184,7 @@ used as the publisher name for the packaging repository. If -U is not provided and this variable is not set, on-nightly will be used. .LP -ONEXTRAURI -.IP -If the -e option is not provided, and this variable is set, it will be used -as the origin URI for the extra repository. If -e is not provided and this -variable is not set, http://ipkg.sfbay/on-extra will be used. Note: for -external users where an extra repository does not apply, use the -O option. -.LP -ONEXTRAPUB -.IP -If the -E option is not provided, and this variable is set, it will be -used as the publisher name for the extra repository. If -E is not -provided and this variable is not set, on-extra will be used. -.LP .SH SEE ALSO .BR beadm "(1M), " .BR pkg "(1), " -.BR pkg.depotd "(1M), " .BR pkg "(5) "
--- a/usr/src/tools/scripts/onu.sh Sat Aug 28 21:08:04 2010 +0200 +++ b/usr/src/tools/scripts/onu.sh Sun Aug 29 21:12:07 2010 -0400 @@ -22,26 +22,23 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. -# +# Copyright 2010, Richard Lowe +# PATH=/usr/bin:/usr/sbin export PATH DEFAULTONURI="http://ipkg.sfbay/on-nightly" DEFAULTONPUB="on-nightly" -DEFAULTONEXTRAURI="http://ipkg.sfbay/on-extra" -DEFAULTONEXTRAPUB="on-extra" usage() { echo "usage: $0 [opts] [-s beName] -t beName" echo "usage: $0 [opts] -r" echo + echo "\t-c consolidation : consolidation being upgraded" echo "\t-d repodir : directory for repositories" - echo "\t-e uri : origin URI for extra repository" - echo "\t-E prefix : prefix for extra repository" - echo "\t-O : open mode, no extra repository will be used" - echo "\t-r : start repository servers only" + echo "\t-r : configure publisher only" echo "\t-s : source BE to clone" echo "\t-t : new BE name" echo "\t-u uri : origin URI for redist repository" @@ -55,8 +52,7 @@ echo "Update to the nightly build:" echo "\tonu -t newbe" echo - echo "Re-enable the publishers, and start any pkg.depotd servers" - echo "necessary in the current BE:" + echo "Re-enable the publishers in the current BE:" echo "\tonu -r -d /path/to/my/ws/packages/\`uname -p\`/nightly" exit 1 } @@ -64,18 +60,9 @@ exit_error() { echo $* - cleanup exit 2 } -cleanup() -{ - [ $redistpid -gt 0 ] && kill $redistpid - [ $extrapid -gt 0 ] && kill $extrapid - [ -d /tmp/redist.$$ ] && /bin/rm -rf /tmp/redist.$$ - [ -d /tmp/extra.$$ ] && /bin/rm -rf /tmp/extra.$$ -} - do_cmd() { [ $verbose -gt 0 ] && echo $* @@ -91,31 +78,20 @@ { root=$1 - do_cmd pkg -R $root set-publisher --no-refresh --non-sticky opensolaris.org - do_cmd pkg -R $root set-publisher -e --no-refresh -P -O $uri $redistpub - [ $open -eq 0 ] && { - do_cmd pkg -R $root set-publisher -e \ - --no-refresh -O $extrauri $extrapub - } - do_cmd pkg -R $root refresh --full -} + # + # Get the publisher name from the 'list -v' output. It may seem we + # could do this more tidily using 'info', but that is + # internationalized. + # + typeset on_publisher=$(pkg -R $root list -Hv \ + "${consolidation}-incorporation" | cut -d/ -f3) -# -# If we're working from a repodir, disable the new publishers in the new -# BE; they won't work without further configuration, in which case the -# -r option should be used. -# -unconfigure_publishers() -{ - root=$1 - - if [ -n "$repodir" ]; then - do_cmd pkg -R $root set-publisher -P opensolaris.org - do_cmd pkg -R $root set-publisher -d $redistpub - [ $open -eq 0 ] && { - do_cmd pkg -R $root set-publisher -d $extrapub - } - fi + if [[ "$on_publisher" != "$redistpub" ]]; then + do_cmd pkg -R $root set-publisher --no-refresh \ + --non-sticky $on_publisher + fi + do_cmd pkg -R $root set-publisher -e --no-refresh -P -O $uri $redistpub + do_cmd pkg -R $root refresh --full } update() @@ -128,8 +104,6 @@ configure_publishers $root do_cmd pkg -R $root image-update - - unconfigure_publishers $root } update_zone() @@ -169,33 +143,22 @@ sourcebe="" targetbe="" uri="" -extrauri="" repodir="" +consolidation="osnet" verbose=0 -open=0 -redistpid=0 -extrapid=0 -redistport=13000 -extraport=13001 no_zones=0 zone_warned=0 reposonly=0 -trap cleanup 1 2 3 15 - -while getopts :d:E:e:Ors:t:U:u:vZ i ; do +while getopts :c:d:Ors:t:U:u:vZ i ; do case $i in + c) + consolidation=$OPTARG + ;; d) repodir=$OPTARG ;; - E) - extrapub=$OPTARG - ;; - e) - extrauri=$OPTARG - ;; - O) - open=1 + O) # no-op, compatibility with recommended use ;; r) reposonly=1 @@ -237,53 +200,27 @@ [ -z "$uri" ] && uri=$DEFAULTONURI [ -z "$redistpub" ] && redistpub=$ONPUB [ -z "$redistpub" ] && redistpub=$DEFAULTONPUB -[ -z "$extrauri" ] && extrauri=$ONEXTRAURI -[ -z "$extrauri" ] && extrauri=$DEFAULTONEXTRAURI -[ -z "$extrapub" ] && extrapub=$ONEXTRAPUB -[ -z "$extrapub" ] && extrapub=$DEFAULTONEXTRAPUB if [ -n "$repodir" ]; then redistdir=$repodir/repo.redist [ -d $redistdir ] || exit_error "$redistdir not found" + typeset cfgfile=$redistdir/cfg_cache + [[ ! -e $cfgfile ]] && cfgfile=$redistdir/pkg5.repository + # need an absolute path + [[ $redistdir == /* ]] || redistdir=$PWD/$redistdir redistpub=$(python2.6 <<# EOF import ConfigParser p = ConfigParser.SafeConfigParser() - p.read("$redistdir/cfg_cache") + p.read("$cfgfile") pp = p.get("publisher", "prefix") print "%s" % pp - EOF) - [ $verbose -gt 0 ] && echo "starting pkg.depotd -d $redistdir -p $redistport" - ARGS="--readonly --writable-root" - mkdir /tmp/redist.$$ - /usr/lib/pkg.depotd -d $redistdir -p $redistport $ARGS /tmp/redist.$$ >/dev/null & - redistpid=$! - uri="http://localhost:$redistport/" - if [ $open -eq 0 ]; then - extradir=$repodir/repo.extra - [ -d $extradir ] || exit_error "$extradir not found" - extrapub=$(python2.6 <<# EOF - import ConfigParser - p = ConfigParser.SafeConfigParser() - p.read("$extradir/cfg_cache") - pp = p.get("publisher", "prefix") - print "%s" % pp - EOF) - [ $verbose -gt 0 ] && echo "starting pkg.depotd -d $extradir -p $extraport" - mkdir /tmp/extra.$$ - /usr/lib/pkg.depotd -d $extradir -p $extraport $ARGS /tmp/extra.$$ >/dev/null & - extrapid=$! - extrauri="http://localhost:$extraport/" - fi + EOF) || exit_error "Cannot determine publisher prefix" + [[ -n "$redistpub" ]] || exit_error "Repository has no publisher prefix" + uri="file://$redistdir" fi if [ "$reposonly" -eq 1 ]; then configure_publishers / - if [ "$redistpid" -ne 0 ]; then - echo "$redistpub pkg.depotd running with pid $redistpid" - fi - if [ "$extrapid" -ne 0 ]; then - echo "$extrapub pkg.depotd running with pid $extrapid" - fi exit 0 fi @@ -305,5 +242,4 @@ done fi -cleanup exit 0