install gawk by default (required for gcc49 build)
[unleashed-kayak.git] / build_zfs_send.sh
blobe6c3abf0e24a08ed17e32db434e259ed321dc9eb
1 #!/bin/bash
3 # CDDL HEADER START
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.
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.
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]
21 # CDDL HEADER END
24 # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 # Use is subject to license terms.
27 fail() {
28 echo $*
29 exit 1
32 PUBLISHER=unleashed
33 PKGURL=${PKGURL-/usr/nightly/packages/i386/nightly/repo.redist}
34 PKGUSERLAND=${PKGURL-/ws/oi-userland/i386/repo}
35 : ${BZIP2:=bzip2}
36 ZROOT=rpool
37 OUT=
38 CLEANUP=0
39 set -- `getopt cd:o:p: $*`
40 for i in $*
42 case $i in
43 -c) CLEANUP=1; shift ;;
44 -d) ZROOT=$2; shift 2;;
45 -o) OUT=$2; shift 2;;
46 -p) PROFILE=$2; shift 2;;
47 -P) PUBLISHER_OVERRIDE=1; shift ;;
48 --) shift; break ;;
49 esac
50 done
52 USERLAND_PACKAGES='gnu-tar bzip2 gzip xz autoconf automake automake-111 automake-115 gnu-make libtool makedepend pkgconf gawk gdb gcc-49 flex swig git vim gnu-findutils libevent2 libidn nghttp2 pcre pkg openssh ntp bash pipe-viewer zsh system/mozilla-nss screen tmux gnu-grep gnu-patch less curl wget xproto setuptools'
54 name=$1
55 if [[ -z "$name" ]]; then
56 echo "$0 [-cP] [-d zfsparent] [-p profile] [-o outputfile] <release_name>"
57 exit
60 MPR=`zfs get -H mountpoint $ZROOT | awk '{print $3}'`
61 if [[ -z "$OUT" ]]; then
62 OUT=$MPR/kayak_$name.zfs.bz2
65 if zfs list $ZROOT/$name@entire > /dev/null 2>&1; then
66 zfs rollback -r $ZROOT/$name@entire
67 MP=`zfs get -H mountpoint $ZROOT/$name | awk '{print $3}'`
68 else
69 zfs create $ZROOT/$name || fail "zfs create"
70 MP=`zfs get -H mountpoint $ZROOT/$name | awk '{print $3}'`
71 pkg image-create -F -p $PUBLISHER=$PKGURL $MP || fail "image-create"
72 pkg -R $MP set-publisher --non-sticky -p $PKGUSERLAND
73 pkg -R $MP install osnet-redistributable developer/opensolaris/osnet $USERLAND_PACKAGES || fail 'install'
74 zfs snapshot $ZROOT/$name@entire
77 zfs snapshot $ZROOT/$name@kayak || fail "snap"
78 zfs send $ZROOT/$name@kayak | $BZIP2 -9 > $OUT || fail "send/compress"
79 if [[ "$CLEANUP" -eq "1" ]]; then
80 zfs destroy $ZROOT/$name@kayak || fail "could not remove snapshot"
81 zfs destroy $ZROOT/$name || fail "could not remove zfs filesystem"