add some more missing things to known_extras
[unleashed-kayak.git] / build_iso.sh
blobd9377d4a33bf5db431a943719ea227a6558368a0
1 #!/usr/bin/bash
3 # {{{ CDDL HEADER
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
7 # 1.0 of the CDDL.
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.
12 # }}}
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."
25 exit 1
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
35 exit 1
37 echo "Using version $VERSION..."
39 stage()
41 echo "***"
42 echo "*** $*"
43 echo "***"
46 # Allow temporary directory override
47 : ${TMPDIR:=/tmp}
49 KAYAK_MINIROOT=$BUILDSEND_MP/boot_archive.gz
50 ZFS_IMG=$BUILDSEND_MP/kayak_${VERSION}.zfs
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 MNT=/mnt
58 DST_ISO=$BUILDSEND_MP/${VERSION}.iso
60 #############################################################################
62 # The kayak mini-root is used for both the ISO root filesystem and for the
63 # miniroot that is loaded and mounted on / when booted.
66 set -o errexit
68 mkdir $ISO_ROOT
70 stage "Adding files to ISO root"
71 # our tar(1) doesn't seem to support multiple file args with -C...
72 tar -cf - -C $BUILDSEND_MP/root boot | tar -xf - -C $ISO_ROOT
73 tar -cf - -C $BUILDSEND_MP/root platform | tar -xf - -C $ISO_ROOT
75 # Place the full ZFS image into the ISO root so it does not form part of the
76 # boot archive (otherwise the boot seems to hang for several minutes while
77 # the miniroot is loaded)
79 stage "Adding ZFS image to ISO root"
80 pv $ZFS_IMG > $ISO_ROOT/unleashed.zfs
81 # Create a file to indicate that this is the right volume set on which to
82 # find the image - see src/mount_media.c
83 echo "unleashed-installer" > $ISO_ROOT/.volsetid
85 # Remind people this is the installer.
86 cat <<EOF > $ISO_ROOT/boot/loader.conf.local
87 loader_menu_title="Welcome to the Unleashed installer"
88 autoboot_delay=10
89 ttya-mode="115200,8,n,1,-"
90 console="text,ttya"
91 EOF
94 # Install the miniroot $ISO_ROOT as the boot archive.
96 stage "Installing boot archive"
97 cp $KAYAK_MINIROOT ${KAYAK_MINIROOT%.gz}.hash $ISO_ROOT/platform/
98 stage "ISO root size: `du -sh $ISO_ROOT/.`"
100 # And finally, burn the ISO.
101 LC_ALL=C mkisofs -N -l -R -U -d -D \
102 -o $DST_ISO \
103 -b boot/cdboot \
104 -c .catalog \
105 -no-emul-boot \
106 -boot-load-size 4 \
107 -boot-info-table \
108 -allow-multidot \
109 -no-iso-translate \
110 -cache-inodes \
111 -V "Unleashed $VERSION" \
112 $ISO_ROOT
114 rm -rf $ISO_ROOT
115 stage "$DST_ISO is ready"
116 ls -lh $DST_ISO
118 # Vim hints
119 # vim:fdm=marker