4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
23 # NOTE --> The URL needs to be updated with every release.
24 # Change "bloody" to whatever release the current branch is.
26 : ${PKGURL:=/ws/unleashed/packages/i386/nightly/repo.redist}
27 USERLAND
=/ws
/oi-userland
/i386
/repo
31 BUILDNUM
=${VERSION//r/}
32 if [[ ${SRCDIR:0:1} != "/" ]]; then
35 if [[ -z "${1}" ]]; then
36 echo "$0 <zfs pool> [checkpoint]"
41 BASEDIR
=`zfs get -o value -H mountpoint $BASE`
46 if [[ ! -d $ROOTDIR ]]; then
47 zfs create
-o compression
=off
$BASE/root || fail
"zfs create failed"
49 SVCCFG_DTD
=${ROOTDIR}/usr
/share
/lib
/xml
/dtd
/service_bundle.dtd
.1
50 SVCCFG_REPOSITORY
=${ROOTDIR}/etc
/svc
/repository.db
51 if [[ -f ${PREBUILT_ILLUMOS}/usr
/src
/cmd
/svc
/svccfg
/svccfg-native
]]; then
52 SVCCFG
=${PREBUILT_ILLUMOS}/usr
/src
/cmd
/svc
/svccfg
/svccfg-native
54 echo "WARNING -- Not using 'native' svccfg, may hang on build."
55 echo " We recommend a pre-built illumos's svccfg-native."
56 echo " Set PREBUILT_ILLUMOS in your environment to point"
57 echo " to a built illumos-omnios repository."
58 SVCCFG
=/usr
/sbin
/svccfg
60 export WORKDIR ROOTDIR SVCCFG_DTD SVCCFG_REPOSITORY SVCCFG
62 # This was uber-helpful
63 # http://alexeremin.blogspot.com/2008/12/preparing-small-miniroot-with-zfs-and.html
67 UNNEEDED_MANIFESTS
="application/management/net-snmp.xml
68 application/pkg/pkg-server.xml application/pkg/pkg-mdns.xml
69 system/rmtmpfiles.xml system/mdmonitor.xml
70 system/fm/notify-params.xml system/device/allocate.xml
71 system/device/devices-audio.xml system/auditd.xml
72 system/metasync.xml system/pkgserv.xml system/fcoe_initiator.xml
73 system/metainit.xml system/zonestat.xml
74 system/cron.xml system/rbac.xml system/sac.xml
75 system/auditset.xml system/hotplug.xml
76 system/wusb.xml system/zones.xml
77 system/intrd.xml system/coreadm.xml
78 system/extended-accounting.xml
80 system/logadm-upgrade.xml system/resource-mgmt.xml
82 network/ldap/client.xml network/shares/reparsed.xml
83 network/shares/group.xml network/inetd-upgrade.xml
84 network/smb/client.xml network/smb/server.xml
85 network/network-iptun.xml network/ipsec/policy.xml
86 network/ipsec/ipsecalgs.xml network/ipsec/ike.xml
87 network/ipsec/manual-key.xml network/forwarding.xml
88 network/inetd.xml network/npiv_config.xml
89 network/ssl/kssl-proxy.xml network/rpc/metamed.xml
90 network/rpc/mdcomm.xml network/rpc/gss.xml
91 network/rpc/bind.xml network/rpc/keyserv.xml
92 network/rpc/meta.xml network/rpc/metamh.xml
93 network/socket-filter-kssl.xml network/network-netcfg.xml
94 network/nfs/status.xml network/nfs/cbd.xml
95 network/nfs/nlockmgr.xml network/nfs/mapid.xml
96 network/nfs/client.xml network/network-ipqos.xml
97 network/security/ktkt_warn.xml network/security/krb5kdc.xml
98 network/security/kadmin.xml network/network-install.xml
99 network/bridge.xml network/network-initial.xml
100 network/network-ipmgmt.xml network/routing/legacy-routing.xml
101 network/network-service.xml network/network-physical.xml
102 network/network-netmask.xml network/dlmgmt.xml
103 network/network-location.xml network/ibd-post-upgrade.xml
104 network/network-routing-setup.xml network/network-loopback.xml
105 network/dns/client.xml network/dns/install.xml
106 network/dns/multicast.xml platform/i86pc/acpihpd.xml
107 system/hostid.xml system/power.xml system/pfexecd.xml
108 system/consadm.xml system/pools.xml system/console-login.xml
109 system/stmf.xml system/fmd.xml system/utmp.xml
110 system/poold.xml system/dumpadm.xml"
112 SYSTEM
="system/boot/real-mode system/boot/wanboot/internal
113 system/boot/loader system/boot/wanboot system/data/hardware-registry
114 system/data/keyboard/keytables system/data/terminfo
115 system/data/zoneinfo system/extended-system-utilities
116 system/file-system/autofs system/file-system/nfs
117 system/file-system/smb system/file-system/udfs
118 system/file-system/zfs system/flash/fwflash
119 system/fru-id/platform system/fru-id system/ipc
120 system/kernel/dynamic-reconfiguration/i86pc
121 system/kernel/security/gss system/library/math
122 system/library/platform system/library/policykit
123 system/library/processor
124 system/library/storage/fibre-channel/hbaapi
125 system/library/storage/fibre-channel/libsun_fc
126 system/library/storage/ima/header-ima
127 system/library/storage/ima
128 system/library/storage/libmpapi
129 system/library/storage/libmpscsi_vhci
130 system/library/storage/scsi-plugins
131 system/library system/network
132 system/storage/luxadm
133 system/storage/fibre-channel/port-utility"
135 DEBUG_PKGS
="developer/debug/mdb developer/dtrace system/kernel/dtrace/providers"
137 DRIVERS
="driver/audio driver/crypto/dca driver/crypto/tpm driver/firewire
138 driver/graphics/agpgart driver/graphics/atiatom driver/graphics/drm
139 driver/i86pc/fipe driver/i86pc/ioat driver/i86pc/platform
141 driver/network/afe driver/network/amd8111s driver/network/atge
142 driver/network/bfe driver/network/bge driver/network/bnx
143 driver/network/bnxe driver/network/bpf driver/network/chxge
144 driver/network/dmfe driver/network/e1000g driver/network/elxl
145 driver/network/emlxs driver/network/eoib driver/network/fcip
146 driver/network/fcp driver/network/fcsm driver/network/fp
147 driver/network/hermon driver/network/hme driver/network/hxge
148 driver/network/ib driver/network/ibdma driver/network/ibp
149 driver/network/igb driver/network/iprb driver/network/ixgb
150 driver/network/ixgbe driver/network/mxfe driver/network/myri10ge
151 driver/network/nge driver/network/ntxn driver/network/nxge
152 driver/network/vmxnet3s driver/network/sfxge driver/network/i40e
153 driver/network/ofk driver/network/pcn driver/network/platform
154 driver/network/qlc driver/network/rds driver/network/rdsv3
155 driver/network/rge driver/network/rpcib driver/network/rtls
156 driver/network/sdp driver/network/sdpib driver/network/sfe
157 driver/network/tavor driver/network/usbecm driver/network/vr
158 driver/network/xge driver/network/yge driver/pcmcia
159 driver/serial/usbftdi driver/serial/usbsacm driver/serial/usbser
160 driver/serial/usbser_edge driver/serial/usbsksp
161 driver/serial/usbsksp/usbs49_fw driver/serial/usbsprl
162 driver/storage/aac driver/storage/ahci
163 driver/storage/amr driver/storage/arcmsr driver/storage/ata
164 driver/storage/bcm_sata driver/storage/blkdev driver/storage/cpqary3
165 driver/storage/glm driver/storage/lsimega driver/storage/marvell88sx
166 driver/storage/mega_sas driver/storage/mpt_sas driver/storage/mr_sas
167 driver/storage/nv_sata driver/storage/pmcs
168 driver/storage/sbp2 driver/storage/scsa1394 driver/storage/sdcard
169 driver/storage/ses driver/storage/si3124 driver/storage/smp
170 driver/usb driver/usb/ugen driver/xvm/pv driver/storage/vioblk
171 driver/network/vioif driver/storage/nvme driver/storage/pvscsi"
173 PARTS
="service/picl install/beadm SUNWcs SUNWcsd
174 shell/pipe-viewer text/less editor/vim web/curl
175 developer/linker openssh library/ncurses
176 diagnostic/diskinfo shell/bash"
178 PKGS
="$PARTS $SYSTEM $DRIVERS"
180 if [ -n "$DEBUG" ]; then
181 PKGS
="$PKGS $DEBUG_PKGS"
184 CULL
="python package/pkg snmp"
185 RMRF
="/var/pkg /usr/share/man /usr/lib/python2.7 /usr/lib/iconv"
188 if [[ "$ID" != "0" ]]; then
189 echo "must run as root"
194 SNAP
=`zfs list -H -t snapshot $BASE/root@${1} 2> /dev/null`
195 if [[ "$DIDWORK" -ne "0" ]]; then
196 if [[ -n "$SNAP" ]]; then
197 zfs destroy
$BASE/root@
${1} || \
198 fail
"zfs destroy ${1} failed"
200 zfs snapshot
$BASE/root@
${1} || fail
"zfs snapshot failed"
202 if [[ "${1}" != "begin" ]]; then
203 echo " === Proceeding to phase $1 (zfs @${1}) ==="
204 zfs rollback
-r $BASE/root@
${1} || fail
"zfs rollback failed"
206 echo " === Proceeding to phase $1 ==="
212 if [[ -n "$1" ]]; then
213 echo "Explicit checkpoint requested: '$1'"
217 if [[ -z "$CHKPT" ]]; then
228 if [[ -n "$file" ]]; then
229 keep_list
+=([$file]="x")
232 done < <(cut
-f2- -d/ $datafile)
233 echo " --- keeping $FCNT files from $datafile"
242 zfs destroy
-r $BASE/root
2> /dev
/null
243 zfs create
-o compression
=off
$BASE/root || fail
"zfs create failed"
249 echo "Creating image of $PUBLISHER from $PKGURL"
250 $PKG image-create
-F -p $PUBLISHER=$PKGURL $ROOTDIR || fail
"image-create"
251 $PKG -R $ROOTDIR set-publisher
-p $USERLAND || fail
'userland'
252 $PKG -R $ROOTDIR install $PKGS || fail
"install"
258 echo "Fixing up install root"
259 (cp $ROOTDIR/etc
/vfstab
$WORKDIR/vfstab
&& \
260 awk '{if($3!="/"){print;}}' $WORKDIR/vfstab
> $ROOTDIR/etc
/vfstab
&& \
261 echo "/devices/ramdisk:a - / ufs - no nologging" >> $ROOTDIR/etc
/vfstab
) || \
262 fail
"vfstab / updated"
264 cp $ROOTDIR/lib
/svc
/seed
/global.db
$ROOTDIR/etc
/svc
/repository.db
266 sed -i '' 's,PASSREQ=YES,PASSREQ=NO,' $ROOTDIR/etc
/default
/login
268 ${SVCCFG} import
${ROOTDIR}/lib
/svc
/manifest
/milestone
/sysconfig.xml
269 for xml
in $UNNEEDED_MANIFESTS; do
270 rm -f ${ROOTDIR}/lib
/svc
/manifest
/$xml && echo " --- tossing $xml"
272 echo " --- initial manifest import"
273 # See if we can transform manifest-import to use the 'native' svccfg.
274 sed 's/\/usr\/sbin\/svccfg/\$SVCCFG/g' \
275 < ${ROOTDIR}/lib
/svc
/method
/manifest-import \
276 > /tmp
/manifest-import.$$
277 chmod 0755 /tmp
/manifest-import.$$
279 /tmp
/manifest-import.$$
-f ${ROOTDIR}/etc
/svc
/repository.db \
280 -d ${ROOTDIR}/lib
/svc
/manifest
281 /bin
/rm -f /tmp
/manifest-import.$$
283 ${SVCCFG} -s 'system/boot-archive' setprop
'start/exec=:true'
284 ${SVCCFG} -s 'system/manifest-import' setprop
'start/exec=:true'
285 ${SVCCFG} -s "system/intrd:default" setprop
"general/enabled=false"
286 ${SVCCFG} -s "system/initial-boot" setprop
"start/timeout_seconds=600"
287 echo " --- neutering the manifest import"
288 echo "#!/bin/ksh" > ${ROOTDIR}/lib
/svc
/method
/manifest-import
289 echo "exit 0" >> ${ROOTDIR}/lib
/svc
/method
/manifest-import
290 chmod 555 ${ROOTDIR}/lib
/svc
/method
/manifest-import
295 if [[ -z "$BIGROOT" ]]; then
296 load_keep_list data
/*
299 if [[ -n "$file" && \
300 ${keep_list[$file]} == "" && \
301 -e "$ROOTDIR/$file" && \
302 ! -d $ROOTDIR/$file ]] ; then
305 done < <(cd $ROOTDIR && find .
/ | cut
-c3-)
306 for path
in $RMRF ; do
307 rm -rf ${ROOTDIR}$path && echo " -- tossing $path"
315 size
=`/usr/bin/du -ks ${ROOTDIR}|/usr/bin/nawk '{print $1+10240}'`
316 echo " --- making image of size $size"
317 /usr
/sbin
/mkfile
${size}k
$MKFILEDIR/miniroot || fail
"mkfile"
318 lofidev
=`/usr/sbin/lofiadm -a $MKFILEDIR/miniroot`
319 rlofidev
=`echo $lofidev |sed s/lofi/rlofi/`
320 yes |
/usr
/sbin
/newfs
-m 0 $rlofidev 2> /dev
/null
> /dev
/null || fail
"newfs"
325 mkdir
-p $WORKDIR/mnt
326 /usr
/sbin
/mount
-o nologging
$lofidev $WORKDIR/mnt || fail
"mount"
331 pushd $ROOTDIR >/dev
/null
332 /usr
/bin
/find . |
/usr
/bin
/cpio -pdum $WORKDIR/mnt
2> /dev
/null
> /dev
/null || fail
"populate root"
333 /usr
/sbin
/devfsadm
-r $WORKDIR/mnt
> /dev
/null
335 mkdir
$WORKDIR/mnt
/kayak
336 cp $SRCDIR/*.sh
$WORKDIR/mnt
/kayak
/
337 chmod a
+x
$WORKDIR/mnt
/kayak
/*.sh
339 make_initial_boot
$WORKDIR/mnt
/.initialboot
340 if [[ -n "$DEBUG" ]]; then
341 cp $SRCDIR/anon.system
$WORKDIR/mnt
/etc
/system
342 cp $SRCDIR/anon.dtrace.conf
$WORKDIR/mnt
/kernel
/drv
/dtrace.conf
348 /usr
/sbin
/umount
$WORKDIR/mnt || fail
"umount"
349 /usr
/sbin
/lofiadm
-d $MKFILEDIR/miniroot || fail
"lofiadm delete"
354 $GZIP_CMD -c -f $MKFILEDIR/miniroot
> $WORKDIR/miniroot.gz
355 rm -f $MKFILEDIR/miniroot
356 chmod 644 $WORKDIR/miniroot.gz
357 echo " === Finished ==="
358 ls -l $WORKDIR/miniroot.gz
364 make_initial_boot
() {
367 /kayak/install_image.sh
372 while [[ -n "$CHKPT" ]]; do