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/amd64/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 SVCCFG_DTD
=${ROOTDIR}/usr
/share
/lib
/xml
/dtd
/service_bundle.dtd
.1
47 SVCCFG_REPOSITORY
=${ROOTDIR}/etc
/svc
/repository.db
48 if [[ -f ${PREBUILT_ILLUMOS}/usr
/src
/cmd
/svc
/svccfg
/svccfg-native
]]; then
49 SVCCFG
=${PREBUILT_ILLUMOS}/usr
/src
/cmd
/svc
/svccfg
/svccfg-native
51 echo "WARNING -- Not using 'native' svccfg, may hang on build."
52 echo " We recommend a pre-built illumos's svccfg-native."
53 echo " Set PREBUILT_ILLUMOS in your environment to point"
54 echo " to a built illumos-omnios repository."
55 SVCCFG
=/usr
/sbin
/svccfg
57 export WORKDIR ROOTDIR SVCCFG_DTD SVCCFG_REPOSITORY SVCCFG
59 # This was uber-helpful
60 # http://alexeremin.blogspot.com/2008/12/preparing-small-miniroot-with-zfs-and.html
64 UNNEEDED_MANIFESTS
="application/management/net-snmp.xml
65 application/pkg/pkg-server.xml application/pkg/pkg-mdns.xml
66 system/rmtmpfiles.xml system/mdmonitor.xml
67 system/fm/notify-params.xml system/device/allocate.xml
68 system/device/devices-audio.xml system/auditd.xml
69 system/metasync.xml system/pkgserv.xml system/fcoe_initiator.xml
70 system/metainit.xml system/zonestat.xml
71 system/cron.xml system/rbac.xml system/sac.xml
72 system/auditset.xml system/hotplug.xml
73 system/wusb.xml system/zones.xml
74 system/intrd.xml system/coreadm.xml
75 system/extended-accounting.xml
77 system/logadm-upgrade.xml system/resource-mgmt.xml
79 network/ldap/client.xml network/shares/reparsed.xml
80 network/shares/group.xml network/inetd-upgrade.xml
81 network/smb/client.xml network/smb/server.xml
82 network/network-iptun.xml network/ipsec/policy.xml
83 network/ipsec/ipsecalgs.xml network/ipsec/ike.xml
84 network/ipsec/manual-key.xml network/forwarding.xml
85 network/inetd.xml network/npiv_config.xml
86 network/ssl/kssl-proxy.xml network/rpc/metamed.xml
87 network/rpc/mdcomm.xml network/rpc/gss.xml
88 network/rpc/bind.xml network/rpc/keyserv.xml
89 network/rpc/meta.xml network/rpc/metamh.xml
90 network/socket-filter-kssl.xml network/network-netcfg.xml
91 network/nfs/status.xml network/nfs/cbd.xml
92 network/nfs/nlockmgr.xml network/nfs/mapid.xml
93 network/nfs/client.xml network/network-ipqos.xml
94 network/security/ktkt_warn.xml network/security/krb5kdc.xml
95 network/security/kadmin.xml network/network-install.xml
96 network/bridge.xml network/network-initial.xml
97 network/network-ipmgmt.xml network/routing/legacy-routing.xml
98 network/network-service.xml network/network-physical.xml
99 network/network-netmask.xml network/dlmgmt.xml
100 network/network-location.xml network/ibd-post-upgrade.xml
101 network/network-routing-setup.xml network/network-loopback.xml
102 network/dns/client.xml network/dns/install.xml
103 network/dns/multicast.xml platform/i86pc/acpihpd.xml
104 system/hostid.xml system/power.xml system/pfexecd.xml
105 system/consadm.xml system/pools.xml system/console-login.xml
106 system/stmf.xml system/fmd.xml system/utmp.xml
107 system/poold.xml system/dumpadm.xml"
109 SYSTEM
="system/boot/real-mode
110 system/boot/loader system/data/hardware-registry
111 system/extended-system-utilities
112 system/file-system/autofs system/file-system/nfs
113 system/file-system/udfs
116 system/library/policykit
117 system/library/processor
118 system/library/storage/fibre-channel/hbaapi
119 system/library/storage/fibre-channel/libsun_fc
120 system/library/storage/ima/header-ima
121 system/library/storage/ima
122 system/library/storage/libmpapi
123 system/library/storage/libmpscsi_vhci
125 system/storage/luxadm
126 system/storage/fibre-channel/port-utility"
128 DEBUG_PKGS
="developer/debug/mdb system/kernel/dtrace/providers"
130 PARTS
="system/core-os system/kernel
131 shell/pipe-viewer editor/vim web/curl
132 developer/linker openssh
133 diagnostic/diskinfo shell/bash"
135 PKGS
="$PARTS $SYSTEM"
137 if [ -n "$DEBUG" ]; then
138 PKGS
="$PKGS $DEBUG_PKGS"
141 CULL
="python package/pkg snmp"
142 RMRF
="/var/pkg /usr/share/man /usr/lib/python2.7 /usr/lib/iconv"
145 if [[ "$ID" != "0" ]]; then
146 echo "must run as root"
151 SNAP
=`zfs list -H -t snapshot $BASE/root@${1} 2> /dev/null`
152 if [[ "$DIDWORK" -ne "0" ]]; then
153 if [[ -n "$SNAP" ]]; then
154 zfs destroy
$BASE/root@
${1} || \
155 fail
"zfs destroy ${1} failed"
157 zfs snapshot
$BASE/root@
${1} || fail
"zfs snapshot failed"
159 if [[ "${1}" != "begin" ]]; then
160 echo " === Proceeding to phase $1 (zfs @${1}) ==="
161 zfs rollback
-r $BASE/root@
${1} || fail
"zfs rollback failed"
163 echo " === Proceeding to phase $1 ==="
169 if [[ -n "$1" ]]; then
170 echo "Explicit checkpoint requested: '$1'"
174 if [[ -z "$CHKPT" ]]; then
185 if [[ -n "$file" ]]; then
186 keep_list
+=([$file]="x")
189 done < <(cut
-f2- -d/ $datafile)
190 echo " --- keeping $FCNT files from $datafile"
199 zfs destroy
-r $BASE/root
2> /dev
/null
200 zfs create
-o compression
=off
$BASE/root || fail
"zfs create failed"
206 echo "Creating image of $PUBLISHER from $PKGURL1"
207 $PKG image-create
-F -p $PUBLISHER=$PKGURL1 $ROOTDIR || fail
"image-create"
208 $PKG -R $ROOTDIR change-variant arch
=i386
# FIXME hack
209 $PKG -R $ROOTDIR set-publisher
-p $PKGURL2 || fail
'userland'
210 $PKG -R $ROOTDIR install $PKGS || fail
"install"
216 echo "Fixing up install root"
217 (cp $ROOTDIR/etc
/vfstab
$WORKDIR/vfstab
&& \
218 awk '{if($3!="/"){print;}}' $WORKDIR/vfstab
> $ROOTDIR/etc
/vfstab
&& \
219 echo "/devices/ramdisk:a - / ufs - no nologging" >> $ROOTDIR/etc
/vfstab
) || \
220 fail
"vfstab / updated"
222 cp $ROOTDIR/lib
/svc
/seed
/global.db
$ROOTDIR/etc
/svc
/repository.db
224 sed -i '' 's,PASSREQ=YES,PASSREQ=NO,' $ROOTDIR/etc
/default
/login
226 ${SVCCFG} import
${ROOTDIR}/lib
/svc
/manifest
/milestone
/sysconfig.xml
227 for xml
in $UNNEEDED_MANIFESTS; do
228 rm -f ${ROOTDIR}/lib
/svc
/manifest
/$xml && echo " --- tossing $xml"
230 echo " --- initial manifest import"
231 # See if we can transform manifest-import to use the 'native' svccfg.
232 sed 's/\/usr\/sbin\/svccfg/\$SVCCFG/g' \
233 < ${ROOTDIR}/lib
/svc
/method
/manifest-import \
234 > /tmp
/manifest-import.$$
235 chmod 0755 /tmp
/manifest-import.$$
237 /tmp
/manifest-import.$$
-f ${ROOTDIR}/etc
/svc
/repository.db \
238 -d ${ROOTDIR}/lib
/svc
/manifest
239 /bin
/rm -f /tmp
/manifest-import.$$
241 ${SVCCFG} -s 'system/boot-archive' setprop
'start/exec=:true'
242 ${SVCCFG} -s 'system/manifest-import' setprop
'start/exec=:true'
243 ${SVCCFG} -s 'system/console-login' setprop
'start/exec=:true'
245 cat > $ROOTDIR/etc
/inittab
<<EOF
246 ap::sysinit:/sbin/autopush -f /etc/iu.ap
247 sp::sysinit:/sbin/soconfig -d /etc/sock2path.d
248 smf::sysinit:/lib/svc/bin/svc.startd
249 sh::respawn:/bin/sh -l </dev/console >/dev/console 2>/dev/console
252 echo "#!/bin/ksh" > ${ROOTDIR}/lib
/svc
/method
/manifest-import
253 echo "exit 0" >> ${ROOTDIR}/lib
/svc
/method
/manifest-import
254 chmod 555 ${ROOTDIR}/lib
/svc
/method
/manifest-import
259 if [[ -z "$BIGROOT" ]]; then
260 load_keep_list data
/*
263 if [[ -n "$file" && \
264 ${keep_list[$file]} == "" && \
265 -e "$ROOTDIR/$file" && \
266 ! -d $ROOTDIR/$file ]] ; then
269 done < <(cd $ROOTDIR && find .
/ | cut
-c3-)
270 for path
in $RMRF ; do
271 rm -rf ${ROOTDIR}$path && echo " -- tossing $path"
279 size
=`zfs get -o value -Hp logicalreferenced $BASE/root`
280 size
=$
((size
/1024 + 10240))
281 echo " --- making miniroot ufs image of size ${size}k"
282 /usr
/sbin
/mkfile
${size}k
$MKFILEDIR/miniroot || fail
"mkfile"
283 lofidev
=`/usr/sbin/lofiadm -a $MKFILEDIR/miniroot`
284 rlofidev
=`echo $lofidev |sed s/lofi/rlofi/`
285 yes |
/usr
/sbin
/newfs
-m 0 $rlofidev 2> /dev
/null
> /dev
/null || fail
"newfs"
290 mkdir
-p $WORKDIR/mnt
291 /usr
/sbin
/mount
-o nologging
$lofidev $WORKDIR/mnt || fail
"mount"
296 pushd $ROOTDIR >/dev
/null
297 /usr
/bin
/find . |
/usr
/bin
/cpio -pdum $WORKDIR/mnt
>/dev
/null || fail
"populate root"
298 /usr
/sbin
/devfsadm
-r $WORKDIR/mnt
> /dev
/null
301 pushd $SRCDIR >/dev
/null
302 install -m 0755 mount_media
$WORKDIR/mnt
303 install -m 0644 ksh.profile
$WORKDIR/mnt
/.profile
304 install -m 0755 install.sh
$WORKDIR/mnt
/install
307 sed -i '' -e 's%^root:NP:%root::%' $WORKDIR/mnt
/etc
/shadow
309 if [[ -n "$DEBUG" ]]; then
310 cp $SRCDIR/anon.system
$WORKDIR/mnt
/etc
/system
311 cp $SRCDIR/anon.dtrace.conf
$WORKDIR/mnt
/kernel
/drv
/dtrace.conf
317 /usr
/sbin
/umount
$WORKDIR/mnt || fail
"umount"
318 /usr
/sbin
/lofiadm
-d $MKFILEDIR/miniroot || fail
"lofiadm delete"
323 digest
-a sha1
$MKFILEDIR/miniroot
> $WORKDIR/boot_archive.
hash
324 $GZIP_CMD -c -f $MKFILEDIR/miniroot
> $WORKDIR/boot_archive.gz
325 rm -f $MKFILEDIR/miniroot
326 chmod 644 $WORKDIR/boot_archive
*
327 echo " === Finished ==="
328 ls -l $WORKDIR/boot_archive.gz
334 while [[ -n "$CHKPT" ]]; do