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.
16 # Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
20 # Build an ISO installer using the Kayak tools.
23 if [ `id -u` != "0" ]; then
24 echo "You must be root to run this script."
28 if [ -z "$BUILDSEND_MP" ]; then
29 echo "Using /rpool/kayak_image for BUILDSEND_MP"
30 BUILDSEND_MP
=/rpool
/kayak_image
33 if [ -z "$VERSION" ]; then
34 echo "VERSION not set." >&2
37 echo "Using version $VERSION..."
46 # Allow temporary directory override
49 KAYAK_MINIROOT
=$BUILDSEND_MP/miniroot.gz
50 ZFS_IMG
=$BUILDSEND_MP/kayak_
${VERSION}.zfs.bz2
52 [ ! -f $KAYAK_MINIROOT -o ! -f $ZFS_IMG ] && echo "Missing files." && exit 1
54 ISO_ROOT
=$TMPDIR/iso_root
55 BA_ROOT
=$TMPDIR/boot_archive
57 KAYAK_ROOT
=$TMPDIR/miniroot.$$
61 DST_ISO
=$BUILDSEND_MP/${VERSION}.iso
63 #############################################################################
65 # The kayak mini-root is used for both the ISO root filesystem and for the
66 # miniroot that is loaded and mounted on / when booted.
74 # Create a UFS lofi file and mount the UFS filesystem in $MNT. This will
75 # form the boot_archive for the ISO.
77 stage
"Mounting source miniroot"
78 # Uncompress and mount the miniroot
79 gunzip
-c $KAYAK_MINIROOT > $KR_FILE
80 LOFI_RPATH
=`lofiadm -a $KR_FILE`
81 mount
$LOFI_RPATH $KAYAK_ROOT
83 stage
"Creating UFS image for new miniroot"
84 mkfile
$BA_SIZE $BA_ROOT
85 LOFI_PATH
=`lofiadm -a $BA_ROOT`
86 echo 'y' | newfs
$LOFI_PATH
89 # Copy the files from the miniroot to the new miniroot...
90 sz
=`du -sh $KAYAK_ROOT | awk '{print $1}'`
91 stage
"Adding files to new miniroot"
92 tar -cf - -C $KAYAK_ROOT . | pv
-s $sz |
tar -xf - -C $MNT
93 # ...and to the ISO root
94 stage
"Adding files to ISO root"
95 tar -cf - -C $KAYAK_ROOT . | pv
-s $sz |
tar -xf - -C $ISO_ROOT
98 stage
"Unmounting source miniroot"
101 lofiadm
-d $LOFI_RPATH
104 # Place the full ZFS image into the ISO root so it does not form part of the
105 # boot archive (otherwise the boot seems to hang for several minutes while
106 # the miniroot is loaded)
108 stage
"Adding ZFS image to ISO root"
109 mkdir
-p $ISO_ROOT/image
110 pv
$ZFS_IMG > $ISO_ROOT/image
/`basename $ZFS_IMG`
111 # Create a file to indicate that this is the right volume set on which to
112 # find the image - see src/mount_media.c
113 echo $VERSION > $ISO_ROOT/.volsetid
115 # Put additional files into the boot-archive on $MNT, which is
116 # what will be / (via ramdisk) once the ISO is booted.
118 stage
"Adding extra files to miniroot"
126 if [ -n "$REFRESH_KAYAK" ]; then
127 # For testing, make sure files in miniroot are current
128 for f
in $MNT/kayak
/*; do
129 [ -f "$f" ] ||
continue
131 cp `basename $f` $MNT/kayak
135 cat <<EOF > $MNT/root/.bashrc
136 export PATH=/usr/bin:/usr/sbin:/sbin
140 # Refresh the devices on the miniroot.
144 # The ISO's miniroot is going to be larger than the PXE miniroot. To that
145 # end, some files not listed in the exception list do need to show up on
146 # the miniroot. Use PREBUILT_ILLUMOS if available, or the current system
149 from_one_to_other
() {
153 [ -n "$PREBUILT_ILLUMOS" -a -d $PREBUILT_ILLUMOS/proto
/root_i386
/$dir ] \
154 && FROMDIR
=$PREBUILT_ILLUMOS/proto
/root_i386
157 tar -cf - -C $FROMDIR/$dir ${@:-.} |
tar -xf - -C $MNT/$dir
160 # Add from_one_to_other for any directory {file|subdir file|subdir ...} you need
161 from_one_to_other usr
/share
/lib
/zoneinfo
162 from_one_to_other usr
/share
/lib
/keytables
163 from_one_to_other usr
/share
/terminfo
164 from_one_to_other usr
/sbin
ping
165 from_one_to_other usr
/bin netstat
167 # Remind people this is the installer.
168 cat <<EOF > $ISO_ROOT/boot/loader.conf.local
169 loader_menu_title="Welcome to the Unleashed installer"
174 # Okay, we've populated the new miniroot. Close it up and install it
175 # on $ISO_ROOT as the boot archive.
177 stage
"Miniroot size"
179 stage
"Unmounting boot archive image"
181 lofiadm
-d $LOFI_PATH
182 stage
"Installing boot archive"
183 pv
$BA_ROOT |
gzip -9c > $ISO_ROOT/platform
/i86pc
/boot_archive.gz
184 ls -lh $ISO_ROOT/platform
/i86pc
/boot_archive.gz |
awk '{print $5}'
185 digest
-a sha1
$BA_ROOT \
186 > $ISO_ROOT/platform
/i86pc
/boot_archive.
hash
188 stage
"Removing unecessary files from ISO root"
189 rm -rf $ISO_ROOT/{usr
,bin
,sbin
,lib
,kernel
}
190 stage
"ISO root size: `du -sh $ISO_ROOT/.`"
192 # And finally, burn the ISO.
193 LC_ALL
=C mkisofs
-N -l -R -U -d -D \
203 -V "Unleashed $VERSION" \
207 stage
"$DST_ISO is ready"