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