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 PKGURL1
=${PKGURL1-/usr/nightly/packages/i386/nightly/repo.redist}
27 PKGURL2
=${PKGURL2-/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
113 system/boot/loader system/data/hardware-registry
114 system/data/keyboard/keytables
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/firewire
138 driver/graphics/agpgart 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
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
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/sfe
157 driver/network/tavor driver/network/usbecm driver/network/vr
158 driver/network/xge driver/network/yge
159 driver/serial/usbftdi driver/serial/usbsacm driver/serial/usbser
160 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/blkdev driver/storage/cpqary3
165 driver/storage/mega_sas driver/storage/mpt_sas driver/storage/mr_sas
166 driver/storage/nv_sata driver/storage/nvme driver/storage/pmcs
167 driver/storage/sbp2 driver/storage/scsa1394 driver/storage/sdcard
168 driver/storage/ses driver/storage/si3124 driver/storage/smp
169 driver/usb driver/usb/ugen driver/storage/vioblk
170 driver/network/vioif driver/storage/nvme driver/storage/pvscsi"
172 PARTS
="service/picl install/beadm SUNWcs SUNWcsd
173 shell/pipe-viewer text/less editor/vim web/curl
174 developer/linker openssh library/ncurses
175 diagnostic/diskinfo shell/bash"
177 PKGS
="$PARTS $SYSTEM $DRIVERS"
179 if [ -n "$DEBUG" ]; then
180 PKGS
="$PKGS $DEBUG_PKGS"
183 CULL
="python package/pkg snmp"
184 RMRF
="/var/pkg /usr/share/man /usr/lib/python2.7 /usr/lib/iconv"
187 if [[ "$ID" != "0" ]]; then
188 echo "must run as root"
193 SNAP
=`zfs list -H -t snapshot $BASE/root@${1} 2> /dev/null`
194 if [[ "$DIDWORK" -ne "0" ]]; then
195 if [[ -n "$SNAP" ]]; then
196 zfs destroy
$BASE/root@
${1} || \
197 fail
"zfs destroy ${1} failed"
199 zfs snapshot
$BASE/root@
${1} || fail
"zfs snapshot failed"
201 if [[ "${1}" != "begin" ]]; then
202 echo " === Proceeding to phase $1 (zfs @${1}) ==="
203 zfs rollback
-r $BASE/root@
${1} || fail
"zfs rollback failed"
205 echo " === Proceeding to phase $1 ==="
211 if [[ -n "$1" ]]; then
212 echo "Explicit checkpoint requested: '$1'"
216 if [[ -z "$CHKPT" ]]; then
227 if [[ -n "$file" ]]; then
228 keep_list
+=([$file]="x")
231 done < <(cut
-f2- -d/ $datafile)
232 echo " --- keeping $FCNT files from $datafile"
241 zfs destroy
-r $BASE/root
2> /dev
/null
242 zfs create
-o compression
=off
$BASE/root || fail
"zfs create failed"
248 echo "Creating image of $PUBLISHER from $PKGURL1"
249 $PKG image-create
-F -p $PUBLISHER=$PKGURL1 $ROOTDIR || fail
"image-create"
250 $PKG -R $ROOTDIR set-publisher
-p $PKGURL2 || fail
'userland'
251 $PKG -R $ROOTDIR install $PKGS || fail
"install"
257 echo "Fixing up install root"
258 (cp $ROOTDIR/etc
/vfstab
$WORKDIR/vfstab
&& \
259 awk '{if($3!="/"){print;}}' $WORKDIR/vfstab
> $ROOTDIR/etc
/vfstab
&& \
260 echo "/devices/ramdisk:a - / ufs - no nologging" >> $ROOTDIR/etc
/vfstab
) || \
261 fail
"vfstab / updated"
263 cp $ROOTDIR/lib
/svc
/seed
/global.db
$ROOTDIR/etc
/svc
/repository.db
265 sed -i '' 's,PASSREQ=YES,PASSREQ=NO,' $ROOTDIR/etc
/default
/login
267 ${SVCCFG} import
${ROOTDIR}/lib
/svc
/manifest
/milestone
/sysconfig.xml
268 for xml
in $UNNEEDED_MANIFESTS; do
269 rm -f ${ROOTDIR}/lib
/svc
/manifest
/$xml && echo " --- tossing $xml"
271 echo " --- initial manifest import"
272 # See if we can transform manifest-import to use the 'native' svccfg.
273 sed 's/\/usr\/sbin\/svccfg/\$SVCCFG/g' \
274 < ${ROOTDIR}/lib
/svc
/method
/manifest-import \
275 > /tmp
/manifest-import.$$
276 chmod 0755 /tmp
/manifest-import.$$
278 /tmp
/manifest-import.$$
-f ${ROOTDIR}/etc
/svc
/repository.db \
279 -d ${ROOTDIR}/lib
/svc
/manifest
280 /bin
/rm -f /tmp
/manifest-import.$$
282 ${SVCCFG} -s 'system/boot-archive' setprop
'start/exec=:true'
283 ${SVCCFG} -s 'system/manifest-import' setprop
'start/exec=:true'
284 ${SVCCFG} -s 'system/console-login' setprop
'startd/need_session=true'
285 ${SVCCFG} -s 'system/console-login' setprop
'start/exec="/kayak/takeover-console /kayak/kayak-menu.sh"'
286 echo " --- neutering the manifest import"
287 echo "#!/bin/ksh" > ${ROOTDIR}/lib
/svc
/method
/manifest-import
288 echo "exit 0" >> ${ROOTDIR}/lib
/svc
/method
/manifest-import
289 chmod 555 ${ROOTDIR}/lib
/svc
/method
/manifest-import
294 if [[ -z "$BIGROOT" ]]; then
295 load_keep_list data
/*
298 if [[ -n "$file" && \
299 ${keep_list[$file]} == "" && \
300 -e "$ROOTDIR/$file" && \
301 ! -d $ROOTDIR/$file ]] ; then
304 done < <(cd $ROOTDIR && find .
/ | cut
-c3-)
305 for path
in $RMRF ; do
306 rm -rf ${ROOTDIR}$path && echo " -- tossing $path"
314 size
=`/usr/bin/du -ks ${ROOTDIR}|/usr/bin/nawk '{print $1+10240}'`
315 echo " --- making image of size $size"
316 /usr
/sbin
/mkfile
${size}k
$MKFILEDIR/miniroot || fail
"mkfile"
317 lofidev
=`/usr/sbin/lofiadm -a $MKFILEDIR/miniroot`
318 rlofidev
=`echo $lofidev |sed s/lofi/rlofi/`
319 yes |
/usr
/sbin
/newfs
-m 0 $rlofidev 2> /dev
/null
> /dev
/null || fail
"newfs"
324 mkdir
-p $WORKDIR/mnt
325 /usr
/sbin
/mount
-o nologging
$lofidev $WORKDIR/mnt || fail
"mount"
330 pushd $ROOTDIR >/dev
/null
331 /usr
/bin
/find . |
/usr
/bin
/cpio -pdum $WORKDIR/mnt
2> /dev
/null
> /dev
/null || fail
"populate root"
332 /usr
/sbin
/devfsadm
-r $WORKDIR/mnt
> /dev
/null
334 mkdir
$WORKDIR/mnt
/kayak
335 cp $SRCDIR/*.sh
$WORKDIR/mnt
/kayak
/
336 chmod a
+x
$WORKDIR/mnt
/kayak
/*.sh
338 if [[ -n "$DEBUG" ]]; then
339 cp $SRCDIR/anon.system
$WORKDIR/mnt
/etc
/system
340 cp $SRCDIR/anon.dtrace.conf
$WORKDIR/mnt
/kernel
/drv
/dtrace.conf
346 /usr
/sbin
/umount
$WORKDIR/mnt || fail
"umount"
347 /usr
/sbin
/lofiadm
-d $MKFILEDIR/miniroot || fail
"lofiadm delete"
352 $GZIP_CMD -c -f $MKFILEDIR/miniroot
> $WORKDIR/miniroot.gz
353 rm -f $MKFILEDIR/miniroot
354 chmod 644 $WORKDIR/miniroot.gz
355 echo " === Finished ==="
356 ls -l $WORKDIR/miniroot.gz
362 while [[ -n "$CHKPT" ]]; do