Print this page
Fix kayak to be mindful of publishers
| Split |
Close |
| Expand all |
| Collapse all |
--- old/./build_image.sh
+++ new/./build_image.sh
1 1 #!/bin/bash
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License, Version 1.0 only
7 7 # (the "License"). You may not use this file except in compliance
8 8 # with the License.
9 9 #
10 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 # or http://www.opensolaris.org/os/licensing.
12 12 # See the License for the specific language governing permissions
13 13 # and limitations under the License.
14 14 #
15 15 # When distributing Covered Code, include this CDDL HEADER in each
16 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 # If applicable, add the following below this CDDL HEADER, with the
18 18 # fields enclosed by brackets "[]" replaced with your own identifying
19 19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 20 #
21 21 # CDDL HEADER END
|
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
22 22 #
23 23 #
24 24 # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27 fail() {
28 28 echo "ERROR: $*"
29 29 exit 1
30 30 }
31 31
32 +# NOTE --> The URL needs to be updated with every release.
33 +# Change "bloody" to whatever release the current branch is.
32 34 PUBLISHER=omnios
33 -: ${PKGURL:=http://pkg.omniti.com/omnios/release}
35 +: ${PKGURL:=http://pkg.omniti.com/omnios/bloody}
34 36 : ${GZIP_CMD:=gzip}
35 37 SRCDIR=$(dirname $0)
36 38 DIDWORK=0
37 39 BUILDNUM=${VERSION//r/}
38 40 if [[ ${SRCDIR:0:1} != "/" ]]; then
39 41 SRCDIR=`pwd`/$SRCDIR
40 42 fi
41 43 if [[ -z "${1}" ]]; then
42 44 echo "$0 <zfs pool> [checkpoint]"
43 45 exit 1
44 46 else
45 47 BASE=${1}
46 48 shift
47 49 BASEDIR=`zfs get -o value -H mountpoint $BASE`
48 50 fi
49 51 MKFILEDIR=/tmp
50 52 WORKDIR=$BASEDIR
51 53 ROOTDIR=$WORKDIR/root
52 54 if [[ ! -d $ROOTDIR ]]; then
53 55 zfs create -o compression=off $BASE/root || fail "zfs create failed"
54 56 fi
55 57 SVCCFG_DTD=${ROOTDIR}/usr/share/lib/xml/dtd/service_bundle.dtd.1
56 58 SVCCFG_REPOSITORY=${ROOTDIR}/etc/svc/repository.db
57 59 SVCCFG=/usr/sbin/svccfg
58 60 export WORKDIR ROOTDIR SVCCFG_DTD SVCCFG_REPOSITORY SVCCFG
59 61
60 62 # This was uber-helpful
61 63 # http://alexeremin.blogspot.com/2008/12/preparing-small-miniroot-with-zfs-and.html
62 64
63 65 PKG=/bin/pkg
64 66
65 67 UNNEEDED_MANIFESTS="application/management/net-snmp.xml
66 68 application/pkg/pkg-server.xml application/pkg/pkg-mdns.xml
67 69 system/rmtmpfiles.xml system/mdmonitor.xml
68 70 system/fm/notify-params.xml system/device/allocate.xml
69 71 system/device/devices-audio.xml system/auditd.xml
70 72 system/metasync.xml system/pkgserv.xml system/fcoe_initiator.xml
71 73 system/metainit.xml system/zonestat.xml
72 74 system/cron.xml system/rbac.xml system/sac.xml
73 75 system/auditset.xml system/hotplug.xml
74 76 system/wusb.xml system/zones.xml
75 77 system/intrd.xml system/coreadm.xml
76 78 system/extended-accounting.xml
77 79 system/scheduler.xml
78 80 system/logadm-upgrade.xml system/resource-mgmt.xml
79 81 system/idmap.xml
80 82 network/ldap/client.xml network/shares/reparsed.xml
81 83 network/shares/group.xml network/inetd-upgrade.xml
82 84 network/smb/client.xml network/smb/server.xml
83 85 network/network-iptun.xml network/ipsec/policy.xml
84 86 network/ipsec/ipsecalgs.xml network/ipsec/ike.xml
85 87 network/ipsec/manual-key.xml network/forwarding.xml
86 88 network/inetd.xml network/npiv_config.xml
87 89 network/ssl/kssl-proxy.xml network/rpc/metamed.xml
88 90 network/rpc/mdcomm.xml network/rpc/gss.xml
89 91 network/rpc/bind.xml network/rpc/keyserv.xml
90 92 network/rpc/meta.xml network/rpc/metamh.xml
91 93 network/socket-filter-kssl.xml network/network-netcfg.xml
92 94 network/nfs/status.xml network/nfs/cbd.xml
93 95 network/nfs/nlockmgr.xml network/nfs/mapid.xml
94 96 network/nfs/client.xml network/network-ipqos.xml
95 97 network/security/ktkt_warn.xml network/security/krb5kdc.xml
96 98 network/security/kadmin.xml network/network-install.xml
97 99 network/bridge.xml network/network-initial.xml
98 100 network/network-ipmgmt.xml network/routing/legacy-routing.xml
99 101 network/network-service.xml network/network-physical.xml
100 102 network/network-netmask.xml network/dlmgmt.xml
101 103 network/network-location.xml network/ibd-post-upgrade.xml
102 104 network/network-routing-setup.xml network/network-loopback.xml
103 105 network/dns/client.xml network/dns/install.xml
104 106 network/dns/multicast.xml platform/i86pc/acpihpd.xml
105 107 system/hostid.xml system/power.xml system/pfexecd.xml
106 108 system/consadm.xml system/pools.xml system/console-login.xml
107 109 system/stmf.xml system/fmd.xml system/utmp.xml
108 110 system/poold.xml system/dumpadm.xml"
109 111
110 112 SYSTEM="system/boot/grub system/boot/real-mode system/boot/wanboot/internal
111 113 system/boot/wanboot system/data/hardware-registry
112 114 system/data/keyboard/keytables system/data/terminfo
113 115 system/data/zoneinfo system/extended-system-utilities
114 116 system/file-system/autofs system/file-system/nfs
115 117 system/file-system/smb system/file-system/udfs
116 118 system/file-system/zfs system/flash/fwflash
117 119 system/fru-id/platform system/fru-id system/ipc
118 120 system/kernel/dynamic-reconfiguration/i86pc
119 121 system/kernel/security/gss system/library/math
120 122 system/library/platform system/library/policykit
121 123 system/library/processor
122 124 system/library/storage/fibre-channel/hbaapi
123 125 system/library/storage/fibre-channel/libsun_fc
124 126 system/library/storage/ima/header-ima
125 127 system/library/storage/ima
126 128 system/library/storage/libmpapi
127 129 system/library/storage/libmpscsi_vhci
128 130 system/library/storage/scsi-plugins
129 131 system/library system/network
130 132 system/prerequisite/gnu system/storage/luxadm
131 133 system/storage/fibre-channel/port-utility"
132 134
133 135 #DEBUG="developer/debug/mdb system/dtrace developer/dtrace"
134 136
135 137 DRIVERS="driver/audio driver/crypto/dca driver/crypto/tpm driver/firewire
136 138 driver/graphics/agpgart driver/graphics/atiatom driver/graphics/drm
137 139 driver/i86pc/fipe driver/i86pc/ioat driver/i86pc/platform
138 140 driver/network/afe driver/network/amd8111s driver/network/atge
139 141 driver/network/bfe driver/network/bge driver/network/bnx
140 142 driver/network/bnxe driver/network/bpf driver/network/chxge
141 143 driver/network/dmfe driver/network/e1000g driver/network/elxl
142 144 driver/network/emlxs driver/network/eoib driver/network/fcip
143 145 driver/network/fcp driver/network/fcsm driver/network/fp
144 146 driver/network/hermon driver/network/hme driver/network/hxge
145 147 driver/network/ib driver/network/ibdma driver/network/ibp
146 148 driver/network/igb driver/network/iprb driver/network/ixgb
147 149 driver/network/ixgbe driver/network/mxfe driver/network/myri10ge
148 150 driver/network/nge driver/network/ntxn driver/network/nxge
149 151 driver/network/ofk driver/network/pcn driver/network/platform
150 152 driver/network/qlc driver/network/rds driver/network/rdsv3
151 153 driver/network/rge driver/network/rpcib driver/network/rtls
152 154 driver/network/sdp driver/network/sdpib driver/network/sfe
153 155 driver/network/tavor driver/network/usbecm driver/network/vr
154 156 driver/network/xge driver/network/yge driver/pcmcia driver/serial/pcser
155 157 driver/serial/usbftdi driver/serial/usbsacm driver/serial/usbser
156 158 driver/serial/usbser_edge driver/serial/usbsksp
157 159 driver/serial/usbsksp/usbs49_fw driver/serial/usbsprl
158 160 driver/storage/aac driver/storage/adpu320 driver/storage/ahci
159 161 driver/storage/amr driver/storage/arcmsr driver/storage/ata
160 162 driver/storage/bcm_sata driver/storage/blkdev driver/storage/cpqary3
161 163 driver/storage/glm driver/storage/lsimega driver/storage/marvell88sx
162 164 driver/storage/mega_sas driver/storage/mpt_sas driver/storage/mr_sas
163 165 driver/storage/nv_sata driver/storage/pcata driver/storage/pmcs
164 166 driver/storage/sbp2 driver/storage/scsa1394 driver/storage/sdcard
165 167 driver/storage/ses driver/storage/si3124 driver/storage/smp
166 168 driver/usb driver/usb/ugen driver/xvm/pv"
167 169
168 170 PARTS="release/name release/notices service/picl install/beadm SUNWcs SUNWcsd
169 171 library/libidn shell/pipe-viewer text/less /network/ssh editor/vim
170 172 developer/linker file/gnu-coreutils"
171 173
172 174 PKGS="$PARTS $SYSTEM $DRIVERS $DEBUG"
173 175
174 176 BIGROOT=
175 177 CULL="perl python package/pkg snmp"
176 178 RMRF="/var/pkg /usr/share/man /usr/lib/python2.6 /usr/lib/iconv"
177 179
178 180 ID=`id -u`
179 181 if [[ "$ID" != "0" ]]; then
180 182 echo "must run as root"
181 183 exit 1
182 184 fi
183 185
184 186 chkpt() {
185 187 SNAP=`zfs list -H -t snapshot $BASE/root@${1} 2> /dev/null`
186 188 if [[ "$DIDWORK" -ne "0" ]]; then
187 189 if [[ -n "$SNAP" ]]; then
188 190 zfs destroy $BASE/root@${1} || \
189 191 fail "zfs destroy ${1} failed"
190 192 fi
191 193 zfs snapshot $BASE/root@${1} || fail "zfs snapshot failed"
192 194 fi
193 195 if [[ "${1}" != "begin" ]]; then
194 196 echo " === Proceeding to phase $1 (zfs @${1}) ==="
195 197 zfs rollback -r $BASE/root@${1} || fail "zfs rollback failed"
196 198 else
197 199 echo " === Proceeding to phase $1 ==="
198 200 fi
199 201 CHKPT=$1
200 202 DIDWORK=1
201 203 }
202 204
203 205 if [[ -n "$1" ]]; then
204 206 echo "Explicit checkpoint requested: '$1'"
205 207 CHKPT=$1
206 208 chkpt $CHKPT
207 209 fi
208 210 if [[ -z "$CHKPT" ]]; then
209 211 CHKPT="begin"
210 212 fi
211 213
212 214 declare -A keep_list
213 215 load_keep_list() {
214 216 for datafile in $*
215 217 do
216 218 FCNT=0
217 219 while read file
218 220 do
219 221 if [[ -n "$file" ]]; then
220 222 keep_list+=([$file]="x")
221 223 FCNT=$(($FCNT + 1))
222 224 fi
223 225 done < <(cut -f2- -d/ $datafile)
224 226 echo " --- keeping $FCNT files from $datafile"
225 227 done
226 228 }
227 229
228 230 step() {
229 231 CHKPT=""
230 232 case "$1" in
231 233
232 234 "begin")
233 235 zfs destroy -r $BASE/root 2> /dev/null
234 236 zfs create -o compression=off $BASE/root || fail "zfs create failed"
235 237 chkpt pkg
236 238 ;;
237 239
238 240 "pkg")
239 241
240 242 echo "Creating image of $PUBLISHER from $PKGURL"
241 243 $PKG image-create -F -a $PUBLISHER=$PKGURL $ROOTDIR || fail "image-create"
242 244 # If a version was requested, respect it
243 245 if [[ -n $BUILDNUM ]]; then
244 246 $PKG -R $ROOTDIR install illumos-gate@11-0.$BUILDNUM omnios-userland@11-0.$BUILDNUM || fail "version constraint prep"
245 247 fi
246 248 $PKG -R $ROOTDIR install $PKGS || fail "install"
247 249 if [[ -n $BUILDNUM ]]; then
248 250 $PKG -R $ROOTDIR uninstall illumos-gate omnios-userland || fail "version constraint cleanup"
249 251 fi
250 252 chkpt fixup
251 253 ;;
252 254
253 255 "fixup")
254 256
255 257 echo "Fixing up install root"
256 258 (cp $ROOTDIR/etc/vfstab $WORKDIR/vfstab && \
257 259 awk '{if($3!="/"){print;}}' $WORKDIR/vfstab > $ROOTDIR/etc/vfstab && \
258 260 echo "/devices/ramdisk:a - / ufs - no nologging" >> $ROOTDIR/etc/vfstab) || \
259 261 fail "vfstab / updated"
260 262 rm $WORKDIR/vfstab
261 263 cp $ROOTDIR/lib/svc/seed/global.db $ROOTDIR/etc/svc/repository.db
262 264
263 265 ${SVCCFG} import ${ROOTDIR}/lib/svc/manifest/milestone/sysconfig.xml
264 266 for xml in $UNNEEDED_MANIFESTS; do
265 267 rm -f ${ROOTDIR}/lib/svc/manifest/$xml && echo " --- tossing $xml"
266 268 done
267 269 echo " --- initial manifest import"
268 270 ${ROOTDIR}/lib/svc/method/manifest-import -f ${ROOTDIR}/etc/svc/repository.db \
269 271 -d ${ROOTDIR}/lib/svc/manifest
270 272
271 273 ${SVCCFG} -s 'system/boot-archive' setprop 'start/exec=:true'
272 274 ${SVCCFG} -s 'system/manifest-import' setprop 'start/exec=:true'
273 275 ${SVCCFG} -s "system/intrd:default" setprop "general/enabled=false"
274 276 ${SVCCFG} -s "system/initial-boot" setprop "start/timeout_seconds=600"
275 277 echo " --- nuetering the manifest import"
276 278 echo "#!/bin/ksh" > ${ROOTDIR}/lib/svc/method/manifest-import
277 279 echo "exit 0" >> ${ROOTDIR}/lib/svc/method/manifest-import
278 280 chmod 555 ${ROOTDIR}/lib/svc/method/manifest-import
279 281 chkpt cull
280 282 ;;
281 283
282 284 "cull")
283 285 if [[ -z "$BIGROOT" ]]; then
284 286 load_keep_list data/*
285 287 while read file
286 288 do
287 289 if [[ -n "$file" && \
288 290 ${keep_list[$file]} == "" && \
289 291 -e "$ROOTDIR/$file" && \
290 292 ! -d $ROOTDIR/$file ]] ; then
291 293 rm -f $ROOTDIR/$file
292 294 fi
293 295 done < <(cd $ROOTDIR && find ./ | cut -c3-)
294 296 for path in $RMRF ; do
295 297 rm -rf ${ROOTDIR}$path && echo " -- tossing $path"
296 298 done
297 299 fi
298 300
299 301 chkpt mkfs
300 302 ;;
301 303
302 304 "mkfs")
303 305 size=`/usr/bin/du -ks ${ROOTDIR}|/usr/bin/nawk '{print $1+10240}'`
304 306 echo " --- making image of size $size"
305 307 /usr/sbin/mkfile ${size}k $MKFILEDIR/miniroot || fail "mkfile"
306 308 lofidev=`/usr/sbin/lofiadm -a $MKFILEDIR/miniroot`
307 309 rlofidev=`echo $lofidev |sed s/lofi/rlofi/`
308 310 yes | /usr/sbin/newfs -m 0 $rlofidev 2> /dev/null > /dev/null || fail "newfs"
309 311 chkpt mount
310 312 ;;
311 313
312 314 "mount")
313 315 mkdir -p $WORKDIR/mnt
314 316 /usr/sbin/mount -o nologging $lofidev $WORKDIR/mnt || fail "mount"
315 317 chkpt copy
316 318 ;;
317 319
318 320 "copy")
319 321 pushd $ROOTDIR >/dev/null
320 322 /usr/bin/find . | /usr/bin/cpio -pdum $WORKDIR/mnt 2> /dev/null > /dev/null || fail "populate root"
321 323 /usr/sbin/devfsadm -r $WORKDIR/mnt > /dev/null
322 324 popd >/dev/null
323 325 mkdir $WORKDIR/mnt/kayak
324 326 cp $SRCDIR/*.sh $WORKDIR/mnt/kayak/
325 327 chmod a+x $WORKDIR/mnt/kayak/*.sh
326 328 make_initial_boot $WORKDIR/mnt/.initialboot
327 329 if [[ -n "$DEBUG" ]]; then
328 330 cp $SRCDIR/anon.system $WORKDIR/mnt/etc/system
329 331 cp $SRCDIR/anon.dtrace.conf $WORKDIR/mnt/kernel/drv/dtrace.conf
330 332 fi
331 333 chkpt umount
332 334 ;;
333 335
334 336 "umount")
335 337 /usr/sbin/umount $WORKDIR/mnt || fail "umount"
336 338 /usr/sbin/lofiadm -d $MKFILEDIR/miniroot || fail "lofiadm delete"
337 339 chkpt compress
338 340 ;;
339 341
340 342 "compress")
341 343 $GZIP_CMD -c -f $MKFILEDIR/miniroot > $WORKDIR/miniroot.gz
342 344 rm -f $MKFILEDIR/miniroot
343 345 chmod 644 $WORKDIR/miniroot.gz
344 346 echo " === Finished ==="
345 347 ls -l $WORKDIR/miniroot.gz
346 348 ;;
347 349
348 350 esac
349 351 }
350 352
351 353 make_initial_boot() {
352 354 FILE=$1
353 355 cat > $FILE <<EOF
354 356 /kayak/install_image.sh
355 357 exit \$?
356 358 EOF
357 359 }
358 360
359 361 while [[ -n "$CHKPT" ]]; do
360 362 step $CHKPT
361 363 done
|
↓ open down ↓ |
318 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX