2014-08-08 14:05:25 +02:00
|
|
|
#!/usr/bin/env bash
|
2013-09-24 15:15:55 +02:00
|
|
|
set -e
|
|
|
|
|
2014-08-08 14:05:25 +02:00
|
|
|
#
|
|
|
|
# This script creates a bootable image and should at some point in the future
|
2015-09-14 21:46:48 +02:00
|
|
|
# be replaced by the proper NetBSD infrastructure.
|
2014-08-08 14:05:25 +02:00
|
|
|
#
|
2014-08-06 15:11:22 +02:00
|
|
|
# Supported command line switches:
|
|
|
|
# -i build iso image instead of qemu imaeg
|
|
|
|
# -b bitcode build, increase partition sizes as necessary
|
|
|
|
#
|
2014-08-08 14:05:25 +02:00
|
|
|
|
2013-09-24 15:15:55 +02:00
|
|
|
: ${ARCH=i386}
|
|
|
|
: ${OBJ=../obj.${ARCH}}
|
2015-09-14 21:46:48 +02:00
|
|
|
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
2013-09-24 15:15:55 +02:00
|
|
|
: ${BUILDSH=build.sh}
|
2015-09-16 16:00:24 +02:00
|
|
|
|
|
|
|
: ${SETS="minix-base minix-comp minix-games minix-man minix-tests tests"}
|
2013-11-05 15:43:44 +01:00
|
|
|
: ${IMG=minix_x86.img}
|
2014-08-08 14:05:25 +02:00
|
|
|
|
|
|
|
if [ ! -f ${BUILDSH} ]
|
|
|
|
then
|
|
|
|
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# we create a disk image of about 2 gig's
|
|
|
|
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
|
|
|
: ${BOOTXX_SECS=32}
|
|
|
|
: ${ROOT_SIZE=$(( 128*(2**20) - ${BOOTXX_SECS} * 512 ))}
|
|
|
|
: ${HOME_SIZE=$(( 128*(2**20) ))}
|
|
|
|
: ${USR_SIZE=$(( 1792*(2**20) ))}
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# set up disk creation environment
|
|
|
|
. releasetools/image.defaults
|
|
|
|
. releasetools/image.functions
|
2014-06-10 17:05:29 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# all sizes are written in 512 byte blocks
|
|
|
|
ROOTSIZEARG="-b $((${ROOT_SIZE} / 512 / 8))"
|
|
|
|
USRSIZEARG="-b $((${USR_SIZE} / 512 / 8))"
|
|
|
|
HOMESIZEARG="-b $((${HOME_SIZE} / 512 / 8))"
|
2014-06-10 17:05:29 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# where the kernel & boot modules will be
|
|
|
|
MODDIR=${DESTDIR}/boot/minix/.temp
|
2013-11-07 08:33:39 +01:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Building work directory..."
|
|
|
|
build_workdir "$SETS"
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Adding extra files..."
|
|
|
|
|
|
|
|
# create a fstab entry in /etc
|
|
|
|
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
|
|
|
/dev/c0d0p1 /usr mfs rw 0 2
|
|
|
|
/dev/c0d0p2 /home mfs rw 0 2
|
Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.
In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well. Test77 has been extended with new tests, and
no longer needs to run as root.
The new functionality is optional. To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.
Technical nodes:
o The reason for not implementing the NetBSD /dev/ptm approach is that
implementing the corresponding ioctl (TIOCPTMGET) would require
adding a number of extremely hairy exceptions to VFS, including the
PTY driver having to create new file descriptors for its own device
nodes.
o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
driver has to be aware of old-style PTY naming schemes and even has
to call chmod(2) on a disk-backed file system. PTY cannot be its
own PTYFS since a character driver may currently not also be a file
system. However, PTYFS may be subsumed into a DEVFS in the future.
o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
slave nodes are created on ptyfs only upon the first call to
grantpt(3). This approach obviates the need to revoke access as
part of the grantpt(3) call.
o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
restarted, these leftover slave nodes will be removed before they
create a security risk. Unmounting PTYFS will make existing PTY
slaves permanently unavailable, and absence of PTYFS will block
allocation of new Unix98 PTYs until PTYFS is (re)mounted.
Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-22 19:14:34 +02:00
|
|
|
none /sys devman rw,rslabel=devman 0 0
|
|
|
|
none /dev/pts ptyfs rw,rslabel=ptyfs 0 0
|
2013-09-24 15:15:55 +02:00
|
|
|
END_FSTAB
|
2015-09-14 21:46:48 +02:00
|
|
|
add_file_spec "etc/fstab" extra.fstab
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor
|
|
|
|
add_file_spec "boot_monitor" extra.boot
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-16 16:00:24 +02:00
|
|
|
add_link_spec "boot/minix_latest" "minix_default" extra.kernel
|
|
|
|
workdir_add_kernel minix_default
|
|
|
|
workdir_add_kernel minix/$RELEASE_VERSION
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# add boot.cfg
|
|
|
|
cat >${ROOT_DIR}/boot.cfg <<END_BOOT_CFG
|
|
|
|
clear=1
|
|
|
|
timeout=5
|
|
|
|
default=2
|
2015-09-16 16:00:24 +02:00
|
|
|
menu=Start MINIX 3:load_mods /boot/minix_default/mod*; multiboot /boot/minix_default/kernel rootdevname=c0d0p0
|
|
|
|
menu=Start latest MINIX 3:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0
|
|
|
|
menu=Start latest MINIX 3 in single user mode:load_mods /boot/minix_latest/mod*; multiboot /boot/minix_latest/kernel rootdevname=c0d0p0 bootopts=-s
|
2015-10-13 12:00:09 +02:00
|
|
|
menu=Start MINIX 3 ALIX:load_mods /boot/minix_default/mod*;multiboot /boot/minix_default/kernel rootdevname=c0d0p0 console=tty00 consdev=com0 ata_no_dma=1
|
2015-09-16 16:00:24 +02:00
|
|
|
menu=Edit menu option:edit
|
|
|
|
menu=Drop to boot prompt:prompt
|
|
|
|
default=2
|
|
|
|
menu=Start MINIX 3 ($RELEASE_VERSION):load_mods /boot/minix/$RELEASE_VERSION/mod*; multiboot /boot/minix/$RELEASE_VERSION/kernel rootdevname=c0d0p0
|
2015-09-14 21:46:48 +02:00
|
|
|
END_BOOT_CFG
|
|
|
|
add_file_spec "boot.cfg" extra.boot
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Bundling packages..."
|
|
|
|
bundle_packages "$BUNDLE_PACKAGES"
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Creating specification files..."
|
|
|
|
create_input_spec
|
|
|
|
create_protos "usr home"
|
2013-11-05 15:43:44 +01:00
|
|
|
|
2015-09-16 16:00:24 +02:00
|
|
|
# Clean image
|
|
|
|
if [ -f ${IMG} ] # IMG might be a block device
|
|
|
|
then
|
|
|
|
rm -f ${IMG}
|
|
|
|
fi
|
|
|
|
|
2013-10-03 18:26:21 +02:00
|
|
|
#
|
2014-08-08 14:05:25 +02:00
|
|
|
# Generate /root, /usr and /home partition images.
|
2013-10-03 18:26:21 +02:00
|
|
|
#
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Writing disk image..."
|
|
|
|
ROOT_START=${BOOTXX_SECS}
|
|
|
|
echo " * ROOT"
|
|
|
|
_ROOT_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root)
|
|
|
|
_ROOT_SIZE=$(($_ROOT_SIZE / 512))
|
2014-08-08 14:05:25 +02:00
|
|
|
USR_START=$((${ROOT_START} + ${_ROOT_SIZE}))
|
2015-09-14 21:46:48 +02:00
|
|
|
echo " * USR"
|
|
|
|
_USR_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${WORK_DIR}/proto.usr)
|
|
|
|
_USR_SIZE=$(($_USR_SIZE / 512))
|
2014-08-08 14:05:25 +02:00
|
|
|
HOME_START=$((${USR_START} + ${_USR_SIZE}))
|
2015-09-14 21:46:48 +02:00
|
|
|
echo " * HOME"
|
|
|
|
_HOME_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home)
|
|
|
|
_HOME_SIZE=$(($_HOME_SIZE / 512))
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2014-08-08 14:05:25 +02:00
|
|
|
#
|
|
|
|
# Write the partition table using the natively compiled
|
|
|
|
# minix partition utility
|
|
|
|
#
|
2015-09-14 21:46:48 +02:00
|
|
|
${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
|
|
|
${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr/mdec/bootxx_minixfs3
|
|
|
|
|
2013-09-24 15:15:55 +02:00
|
|
|
|
2013-10-03 18:26:21 +02:00
|
|
|
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
2015-09-14 21:46:48 +02:00
|
|
|
echo "Disk image at `pwd`/${IMG}"
|
|
|
|
echo "To boot this image on kvm:"
|
|
|
|
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256 -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|