releasetools/*image.sh
- Removed an "export CPPFLAGS=${FLAG}" which prevented proper settings from the environment to be passed to the build step. - Re-arranged variable settings at the top, so that we don't need to evaluate the argument to vfat mkfs command anymore in arm_sdimage.sh - "Merged" both script for easier comparison in the future. Change-Id: Id59f902e4eaeb7f268d5051789462f14421a114a
This commit is contained in:
parent
b06a8f390e
commit
17eed55f28
|
@ -1,6 +1,11 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script creates a bootable image and should at some point in the future
|
||||||
|
# be replaced by makefs.
|
||||||
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Source settings if present
|
# Source settings if present
|
||||||
#
|
#
|
||||||
|
@ -24,32 +29,53 @@ fi
|
||||||
: ${FSTAB=${DESTDIR}/etc/fstab}
|
: ${FSTAB=${DESTDIR}/etc/fstab}
|
||||||
: ${BUILDVARS=-V MKGCCCMDS=yes -V MKLLVM=no}
|
: ${BUILDVARS=-V MKGCCCMDS=yes -V MKLLVM=no}
|
||||||
: ${BUILDSH=build.sh}
|
: ${BUILDSH=build.sh}
|
||||||
|
: ${CREATE_IMAGE_ONLY=0}
|
||||||
|
: ${RC=minix_x86.rc}
|
||||||
|
|
||||||
|
# Where the kernel & boot modules will be
|
||||||
|
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory where to store temporary file system images
|
# Directory where to store temporary file system images
|
||||||
#
|
#
|
||||||
: ${IMG_DIR=${OBJ}/img}
|
: ${IMG_DIR=${OBJ}/img}
|
||||||
: ${IMG=minix_arm_sd.img}
|
|
||||||
: ${MLO=MLO}
|
: ${MLO=MLO}
|
||||||
: ${UBOOT=u-boot.img}
|
: ${UBOOT=u-boot.img}
|
||||||
|
|
||||||
|
|
||||||
# Beagleboard-xm
|
# Beagleboard-xm
|
||||||
: ${U_BOOT_BIN_DIR=build/omap3_beagle/}
|
: ${U_BOOT_BIN_DIR=build/omap3_beagle/}
|
||||||
: ${CONSOLE=tty02}
|
: ${CONSOLE=tty02}
|
||||||
|
|
||||||
|
|
||||||
# BeagleBone (and black)
|
# BeagleBone (and black)
|
||||||
#: ${U_BOOT_BIN_DIR=build/am335x_evm/}
|
#: ${U_BOOT_BIN_DIR=build/am335x_evm/}
|
||||||
#: ${CONSOLE=tty00}
|
#: ${CONSOLE=tty00}
|
||||||
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# We host u-boot binaries.
|
# We host u-boot binaries.
|
||||||
|
#
|
||||||
U_BOOT_GIT_VERSION=cb5178f12787c690cb1c888d88733137e5a47b15
|
U_BOOT_GIT_VERSION=cb5178f12787c690cb1c888d88733137e5a47b15
|
||||||
|
|
||||||
# Set the vfat mkfs command. We need to re-evaluate MKFS_VFAT_OPTS after
|
#
|
||||||
# FAT_SIZE is set :-(
|
# All sized are written in 512 byte blocks
|
||||||
|
#
|
||||||
|
# we create a disk image of about 2 gig's
|
||||||
|
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
||||||
|
#
|
||||||
|
: ${IMG_SIZE=$(( 2*(2**30) / 512))}
|
||||||
|
: ${FAT_SIZE=$(( 10*(2**20) / 512))}
|
||||||
|
: ${ROOT_SIZE=$(( 64*(2**20) / 512))}
|
||||||
|
: ${HOME_SIZE=$(( 128*(2**20) / 512))}
|
||||||
|
: ${USR_SIZE=$(( 1792*(2**20) / 512))}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Do some math to determine the start addresses of the partitions.
|
||||||
|
# Don't leave holes so the 'partition' invocation later is easy.
|
||||||
|
#
|
||||||
|
FAT_START=2048
|
||||||
|
ROOT_START=$(($FAT_START + $FAT_SIZE))
|
||||||
|
USR_START=$(($ROOT_START + $ROOT_SIZE))
|
||||||
|
HOME_START=$(($USR_START + $USR_SIZE))
|
||||||
|
|
||||||
case $(uname -s) in
|
case $(uname -s) in
|
||||||
Darwin)
|
Darwin)
|
||||||
MKFS_VFAT_CMD=newfs_msdos
|
MKFS_VFAT_CMD=newfs_msdos
|
||||||
|
@ -65,14 +91,13 @@ FreeBSD)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$BASE_URL" ]
|
if [ -n "$BASE_URL" ]
|
||||||
then
|
then
|
||||||
#we no longer download u-boot but do a checkout
|
#we no longer download u-boot but do a checkout
|
||||||
#BASE_URL used to be the base url for u-boot
|
#BASE_URL used to be the base url for u-boot
|
||||||
#Downloads
|
#Downloads
|
||||||
echo "Warning:** Setting BASE_URL (u-boot) is no longer possible use U_BOOT_BIN_DIR"
|
echo "Warning:** Setting BASE_URL (u-boot) is no longer possible use U_BOOT_BIN_DIR"
|
||||||
echo "Look in ./releasetools/arm_sdimage.sh for suggested values"
|
echo "Look in ${RELEASETOOLSDIR}/arm_sdimage.sh for suggested values"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -82,7 +107,7 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}
|
||||||
|
|
||||||
for needed in mcopy dd ${MKFS_VFAT_CMD} git
|
for needed in mcopy dd ${MKFS_VFAT_CMD} git
|
||||||
do
|
do
|
||||||
|
@ -93,52 +118,58 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
: ${IMG=minix_arm_sd.img}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Are we going to build the minix sources?
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ ${CREATE_IMAGE_ONLY} -eq 1 ]
|
||||||
|
then
|
||||||
|
if [ ! -d ${DESTDIR} ]
|
||||||
|
then
|
||||||
|
echo "Minix source code does'nt appear to have been built."
|
||||||
|
echo "Please try with \$CREATE_IMAGE_ONLY set to 0."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Artifacts from this script are stored in the IMG_DIR
|
# Artifacts from this script are stored in the IMG_DIR
|
||||||
#
|
#
|
||||||
mkdir -p $IMG_DIR
|
rm -rf ${IMG_DIR} ${IMG}
|
||||||
|
mkdir -p ${IMG_DIR}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Download the stage 1 bootloader and u-boot
|
# Download the stage 1 bootloader and u-boot
|
||||||
#
|
#
|
||||||
./releasetools/fetch_u-boot.sh -o ${RELEASETOOLSDIR}/u-boot -n $U_BOOT_GIT_VERSION
|
${RELEASETOOLSDIR}/fetch_u-boot.sh -o ${RELEASETOOLSDIR}/u-boot -n $U_BOOT_GIT_VERSION
|
||||||
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/u-boot.img ${IMG_DIR}/
|
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/u-boot.img ${IMG_DIR}/
|
||||||
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/MLO ${IMG_DIR}/
|
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/MLO ${IMG_DIR}/
|
||||||
|
|
||||||
#
|
if [ ${CREATE_IMAGE_ONLY} -eq 0 ]
|
||||||
# Remove the generated files to allow us call build.sh without '-V SLOPPY_FLIST=yes'.
|
then
|
||||||
#
|
echo "Going to build Minix source code..."
|
||||||
rm -f ${FSTAB}
|
#
|
||||||
|
# Remove the generated files to allow us call build.sh without '-V SLOPPY_FLIST=yes'.
|
||||||
|
#
|
||||||
|
rm -f ${FSTAB}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Now start the build
|
# Now start the build.
|
||||||
#
|
#
|
||||||
export CPPFLAGS=${FLAG}
|
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u distribution
|
||||||
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u distribution
|
|
||||||
|
|
||||||
#
|
fi
|
||||||
# This script creates a bootable image and should at some point in the future
|
|
||||||
# be replaced by makefs.
|
|
||||||
#
|
|
||||||
# All sized are written in 512 byte blocks
|
|
||||||
#
|
|
||||||
# we create a disk image of about 2 gig's
|
|
||||||
: ${IMG_SIZE=$(( 2*(2**30) / 512))}
|
|
||||||
: ${FAT_SIZE=$(( 10*(2**20) / 512))}
|
|
||||||
: ${ROOT_SIZE=$(( 64*(2**20) / 512))}
|
|
||||||
: ${HOME_SIZE=$(( 128*(2**20) / 512))}
|
|
||||||
: ${USR_SIZE=$(( 1536*(2**20) / 512))}
|
|
||||||
|
|
||||||
eval MKFS_VFAT_OPTS="\"$MKFS_VFAT_OPTS\""
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# create a fstab entry in /etc this is normally done during the
|
# create a fstab entry in /etc this is normally done during the
|
||||||
# setup phase on x86
|
# setup phase on x86
|
||||||
#
|
#
|
||||||
cat >${FSTAB} <<END_FSTAB
|
cat >${FSTAB} <<END_FSTAB
|
||||||
/dev/c0d0p2 /home mfs rw 0 2
|
/dev/c0d0p2 /usr mfs rw 0 2
|
||||||
/dev/c0d0p3 /usr mfs rw 0 2
|
/dev/c0d0p3 /home mfs rw 0 2
|
||||||
none /sys devman rw,rslabel=devman 0 0
|
none /sys devman rw,rslabel=devman 0 0
|
||||||
END_FSTAB
|
END_FSTAB
|
||||||
|
|
||||||
rm -f ${DESTDIR}/SETS.*
|
rm -f ${DESTDIR}/SETS.*
|
||||||
|
@ -146,32 +177,43 @@ rm -f ${DESTDIR}/SETS.*
|
||||||
${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${DESTDIR} ${DESTDIR}/etc/master.passwd
|
${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${DESTDIR} ${DESTDIR}/etc/master.passwd
|
||||||
|
|
||||||
#
|
#
|
||||||
# Now given the sizes above use DD to create separate files representing
|
# make the different file system. this part is *also* hacky. We first convert
|
||||||
# the partitions we are going to use.
|
# the METALOG.sanitised using mtree into a input METALOG containing uids and
|
||||||
|
# gids.
|
||||||
|
# After that we do some magic processing to add device nodes (also missing from METALOG)
|
||||||
|
# and convert the METALOG into a proto file that can be used by mkfs.mfs
|
||||||
|
#
|
||||||
|
echo "Creating the file systems"
|
||||||
|
|
||||||
|
#
|
||||||
|
# read METALOG and use mtree to convert the user and group names into uid and gids
|
||||||
|
# FIX put "input somewhere clean"
|
||||||
|
#
|
||||||
|
cat ${DESTDIR}/METALOG.sanitised | ${CROSS_TOOLS}/nbmtree -N ${DESTDIR}/etc -C -K device > ${IMG_DIR}/input
|
||||||
|
|
||||||
|
# add rc (if any)
|
||||||
|
if [ -f ${RC} ]; then
|
||||||
|
cp ${RC} ${DESTDIR}/usr/etc/rc.local
|
||||||
|
echo "./usr/etc/rc.local type=file uid=0 gid=0 mode=0644" >> ${IMG_DIR}/input
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add fstab
|
||||||
|
echo "./etc/fstab type=file uid=0 gid=0 mode=0755 size=747 time=1365060731.000000000" >> ${IMG_DIR}/input
|
||||||
|
|
||||||
|
# fill root.img (skipping /usr entries while keeping the /usr directory)
|
||||||
|
cat ${IMG_DIR}/input | grep -v "^./usr/" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR} -o ${IMG_DIR}/root.proto
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create proto files for /usr and /home using toproto.
|
||||||
|
#
|
||||||
|
cat ${IMG_DIR}/input | grep "^\./usr/\|^. " | sed "s,\./usr,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/usr -o ${IMG_DIR}/usr.proto
|
||||||
|
cat ${IMG_DIR}/input | grep "^\./home/\|^. " | sed "s,\./home,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/home -o ${IMG_DIR}/home.proto
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create the FAT partition, which contains the bootloader files, kernel and modules
|
||||||
#
|
#
|
||||||
dd if=/dev/zero of=${IMG_DIR}/fat.img bs=512 count=1 seek=$(($FAT_SIZE -1)) 2>/dev/null
|
dd if=/dev/zero of=${IMG_DIR}/fat.img bs=512 count=1 seek=$(($FAT_SIZE -1)) 2>/dev/null
|
||||||
|
|
||||||
#
|
|
||||||
# Create the empty image where we later will put the partitions in.
|
|
||||||
#
|
|
||||||
rm -f ${IMG}
|
|
||||||
dd if=/dev/zero of=${IMG} bs=512 count=1 seek=$(($IMG_SIZE -1))
|
|
||||||
|
|
||||||
#
|
|
||||||
# Do some math to determine the start addresses of the partitions.
|
|
||||||
# Don't leave holes so the 'partition' invocation later is easy.
|
|
||||||
#
|
|
||||||
FAT_START=2048
|
|
||||||
ROOT_START=$(($FAT_START + $FAT_SIZE))
|
|
||||||
HOME_START=$(($ROOT_START + $ROOT_SIZE))
|
|
||||||
USR_START=$(($HOME_START + $HOME_SIZE))
|
|
||||||
|
|
||||||
#
|
|
||||||
# Write the partition table using the natively compiled
|
|
||||||
# minix partition utility
|
|
||||||
#
|
|
||||||
${CROSS_TOOLS}/nbpartition -m ${IMG} ${FAT_START} "c:${FAT_SIZE}*" 81:${ROOT_SIZE} 81:${HOME_SIZE} 81:${USR_SIZE}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Format the fat partition and put the bootloaders
|
# Format the fat partition and put the bootloaders
|
||||||
# uEnv and the kernel command line in the FAT partition
|
# uEnv and the kernel command line in the FAT partition
|
||||||
|
@ -184,8 +226,8 @@ ${MKFS_VFAT_CMD} ${MKFS_VFAT_OPTS} ${IMG_DIR}/fat.img
|
||||||
# -p add a prefix to the network booted files (e.g. xm/"
|
# -p add a prefix to the network booted files (e.g. xm/"
|
||||||
# -c set console e.g. tty02 or tty00
|
# -c set console e.g. tty02 or tty00
|
||||||
# -v set verbosity e.g. 0 to 3
|
# -v set verbosity e.g. 0 to 3
|
||||||
#./releasetools/gen_uEnv.txt.sh -c ${CONSOLE} -n -p bb/ > ${IMG_DIR}/uEnv.txt
|
#${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} -n -p bb/ > ${IMG_DIR}/uEnv.txt
|
||||||
./releasetools/gen_uEnv.txt.sh -c ${CONSOLE} > ${IMG_DIR}/uEnv.txt
|
${RELEASETOOLSDIR}/gen_uEnv.txt.sh -c ${CONSOLE} > ${IMG_DIR}/uEnv.txt
|
||||||
|
|
||||||
echo "Copying configuration kernel and boot modules"
|
echo "Copying configuration kernel and boot modules"
|
||||||
mcopy -bsp -i ${IMG_DIR}/fat.img ${IMG_DIR}/$MLO ::MLO
|
mcopy -bsp -i ${IMG_DIR}/fat.img ${IMG_DIR}/$MLO ::MLO
|
||||||
|
@ -193,13 +235,8 @@ mcopy -bsp -i ${IMG_DIR}/fat.img ${IMG_DIR}/$UBOOT ::u-boot.img
|
||||||
mcopy -bsp -i ${IMG_DIR}/fat.img ${IMG_DIR}/uEnv.txt ::uEnv.txt
|
mcopy -bsp -i ${IMG_DIR}/fat.img ${IMG_DIR}/uEnv.txt ::uEnv.txt
|
||||||
|
|
||||||
#
|
#
|
||||||
# For tftp booting
|
# Do some last processing of the kernel and servers and then put them on the FAT
|
||||||
#
|
# partition.
|
||||||
cp ${IMG_DIR}/uEnv.txt ${OBJ}/
|
|
||||||
|
|
||||||
#
|
|
||||||
# Do some last processing of the kernel and servers before also putting
|
|
||||||
# them on the FAT
|
|
||||||
#
|
#
|
||||||
${CROSS_PREFIX}objcopy ${OBJ}/minix/kernel/kernel -O binary ${OBJ}/kernel.bin
|
${CROSS_PREFIX}objcopy ${OBJ}/minix/kernel/kernel -O binary ${OBJ}/kernel.bin
|
||||||
|
|
||||||
|
@ -224,42 +261,35 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
# make the different file system. this part is *also* hacky. We first convert
|
# For tftp booting
|
||||||
# the METALOG.sanitised using mtree into a input METALOG containing uids and
|
|
||||||
# gids.
|
|
||||||
# Afther that we do some processing to convert the METALOG into a proto file
|
|
||||||
# that can be used by mkfs.mfs
|
|
||||||
#
|
#
|
||||||
echo "creating the file systems"
|
cp ${IMG_DIR}/uEnv.txt ${OBJ}/
|
||||||
|
|
||||||
#
|
#
|
||||||
# read METALOG and use mtree to conver the user and group names into uid and gids
|
# Create the empty image where we later will put the partitions in.
|
||||||
# FIX put "input somwhere clean"
|
# Make sure it is at least 2GB, otherwise the SD card will not be detected
|
||||||
|
# correctly in qemu / HW.
|
||||||
#
|
#
|
||||||
cat ${DESTDIR}/METALOG.sanitised | ${CROSS_TOOLS}/nbmtree -N ${DESTDIR}/etc -C -K device > ${IMG_DIR}/input
|
dd if=/dev/zero of=${IMG} bs=512 count=1 seek=$(($IMG_SIZE -1))
|
||||||
|
|
||||||
# add fstab
|
|
||||||
echo "./etc/fstab type=file uid=0 gid=0 mode=0755 size=747 time=1365060731.000000000" >> ${IMG_DIR}/input
|
|
||||||
|
|
||||||
# fill root.img (skipping /usr entries while keeping the /usr directory)
|
|
||||||
cat ${IMG_DIR}/input | grep -v "^./usr/" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR} -o ${IMG_DIR}/root.proto
|
|
||||||
|
|
||||||
#
|
|
||||||
# Create proto files for /usr and /home using toproto.
|
|
||||||
#
|
|
||||||
cat ${IMG_DIR}/input | grep "^\./usr/\|^. " | sed "s,\./usr,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/usr -o ${IMG_DIR}/usr.proto
|
|
||||||
cat ${IMG_DIR}/input | grep "^\./home/\|^. " | sed "s,\./home,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/home -o ${IMG_DIR}/home.proto
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate /root, /usr and /home partition images.
|
# Generate /root, /usr and /home partition images.
|
||||||
#
|
#
|
||||||
echo "Writing Minix filesystem images"
|
echo "Writing Minix filesystem images"
|
||||||
echo " - ROOT"
|
echo " - ROOT"
|
||||||
${CROSS_TOOLS}/nbmkfs.mfs -I $((${ROOT_START} * 512)) -b $((${ROOT_SIZE} / 8)) ${IMG} ${IMG_DIR}/root.proto
|
_ROOT_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -I $((${ROOT_START} * 512)) -b $((${ROOT_SIZE} / 8)) ${IMG} ${IMG_DIR}/root.proto`/512))
|
||||||
echo " - USR"
|
echo " - USR"
|
||||||
${CROSS_TOOLS}/nbmkfs.mfs -I $((${USR_START} * 512)) -b $((${USR_SIZE} / 8)) ${IMG} ${IMG_DIR}/usr.proto
|
_USR_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -I $((${USR_START} * 512)) -b $((${USR_SIZE} / 8)) ${IMG} ${IMG_DIR}/usr.proto`/512))
|
||||||
echo " - HOME"
|
echo " - HOME"
|
||||||
${CROSS_TOOLS}/nbmkfs.mfs -I $((${HOME_START} * 512)) -b $((${HOME_SIZE} / 8)) ${IMG} ${IMG_DIR}/home.proto
|
_HOME_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -I $((${HOME_START} * 512)) -b $((${HOME_SIZE} / 8)) ${IMG} ${IMG_DIR}/home.proto`/512))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Write the partition table using the natively compiled
|
||||||
|
# minix partition utility
|
||||||
|
#
|
||||||
|
${CROSS_TOOLS}/nbpartition -m ${IMG} ${FAT_START} "c:${FAT_SIZE}*" \
|
||||||
|
81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Merge the partitions into a single image.
|
# Merge the partitions into a single image.
|
||||||
|
|
|
@ -1,34 +1,47 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script creates a bootable image and should at some point in the future
|
||||||
|
# be replaced by makefs.
|
||||||
|
#
|
||||||
|
|
||||||
: ${ARCH=i386}
|
: ${ARCH=i386}
|
||||||
: ${OBJ=../obj.${ARCH}}
|
: ${OBJ=../obj.${ARCH}}
|
||||||
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
||||||
: ${CROSS_PREFIX=${CROSS_TOOLS}/i586-elf32-minix-}
|
: ${CROSS_PREFIX=${CROSS_TOOLS}/i586-elf32-minix-}
|
||||||
: ${JOBS=1}
|
: ${JOBS=1}
|
||||||
: ${DESTDIR=${OBJ}/destdir.$ARCH}
|
: ${DESTDIR=${OBJ}/destdir.$ARCH}
|
||||||
|
: ${RELEASETOOLSDIR=./releasetools/}
|
||||||
: ${FSTAB=${DESTDIR}/etc/fstab}
|
: ${FSTAB=${DESTDIR}/etc/fstab}
|
||||||
: ${BUILDVARS=}
|
: ${BUILDVARS=}
|
||||||
: ${BUILDSH=build.sh}
|
: ${BUILDSH=build.sh}
|
||||||
: ${CREATE_IMAGE_ONLY=0}
|
: ${CREATE_IMAGE_ONLY=0}
|
||||||
|
: ${RC=minix_x86.rc}
|
||||||
# Where the kernel & boot modules will be
|
|
||||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory where to store temporary file system images
|
# Directory where to store temporary file system images
|
||||||
#
|
#
|
||||||
: ${IMG_DIR=${OBJ}/img}
|
: ${IMG_DIR=${OBJ}/img}
|
||||||
|
: ${CDFILES=${IMG_DIR}/cd}
|
||||||
|
|
||||||
CDFILES=${IMG_DIR}/cd
|
# All sized are written in 512 byte blocks
|
||||||
|
#
|
||||||
|
# we create a disk image of about 2 gig's
|
||||||
|
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
||||||
|
#
|
||||||
|
: ${ROOT_SIZE=$(( 64*(2**20) / 512))}
|
||||||
|
: ${HOME_SIZE=$(( 128*(2**20) / 512))}
|
||||||
|
: ${USR_SIZE=$(( 1792*(2**20) / 512))}
|
||||||
|
|
||||||
if [ ! -f ${BUILDSH} ]
|
#
|
||||||
then
|
# Do some math to determine the start addresses of the partitions.
|
||||||
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
# Don't leave holes so the 'partition' invocation later is easy.
|
||||||
exit 1
|
#
|
||||||
fi
|
|
||||||
|
|
||||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}
|
|
||||||
|
# Where the kernel & boot modules will be
|
||||||
|
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||||
|
|
||||||
while getopts "i" c
|
while getopts "i" c
|
||||||
do
|
do
|
||||||
|
@ -40,7 +53,26 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
: ${IMG=minix_x86.img}
|
: ${IMG=minix_x86.img}
|
||||||
: ${RC=minix_x86.rc}
|
|
||||||
|
if [ "x${ISOMODE}" = "x1" ]
|
||||||
|
then
|
||||||
|
# In iso mode, make all FSes fit (i.e. as small as possible), but
|
||||||
|
# leave some space on /
|
||||||
|
ROOTSIZEARG="-x 5"
|
||||||
|
else
|
||||||
|
# In hd image mode, FSes have fixed sizes
|
||||||
|
ROOTSIZEARG="-b $((${ROOT_SIZE} / 8))"
|
||||||
|
USRSIZEARG="-b $((${USR_SIZE} / 8))"
|
||||||
|
HOMESIZEARG="-b $((${HOME_SIZE} / 8))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f ${BUILDSH} ]
|
||||||
|
then
|
||||||
|
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Are we going to build the minix sources?
|
# Are we going to build the minix sources?
|
||||||
|
@ -73,33 +105,18 @@ then
|
||||||
#
|
#
|
||||||
# Now start the build.
|
# Now start the build.
|
||||||
#
|
#
|
||||||
export CPPFLAGS=${FLAG}
|
|
||||||
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u distribution
|
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u distribution
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x${ISOMODE}" = "x1" ]
|
|
||||||
then
|
|
||||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${CDFILES}/boot
|
|
||||||
cp ${MODDIR}/* ${CDFILES}/
|
|
||||||
. ./releasetools/release.functions
|
|
||||||
cd_root_changes # uses $CDFILES and writes $CDFILES/boot.cfg
|
|
||||||
# start the image off with the iso image; reduce root size to reserve
|
|
||||||
${CROSS_TOOLS}/nbwriteisofs -s0x0 -l MINIX -B ${DESTDIR}/usr/mdec/bootxx_cd9660 -n ${CDFILES} ${IMG}
|
|
||||||
ISO_SIZE=$((`${CROSS_TOOLS}/nbstat -f %z ${IMG}` / 512))
|
|
||||||
else
|
|
||||||
# just make an empty iso partition
|
|
||||||
ISO_SIZE=8
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# create a fstab entry in /etc this is normally done during the
|
# create a fstab entry in /etc this is normally done during the
|
||||||
# setup phase on x86
|
# setup phase on x86
|
||||||
#
|
#
|
||||||
cat >${FSTAB} <<END_FSTAB
|
cat >${FSTAB} <<END_FSTAB
|
||||||
/dev/c0d0p2 /usr mfs rw 0 2
|
/dev/c0d0p2 /usr mfs rw 0 2
|
||||||
/dev/c0d0p3 /home mfs rw 0 2
|
/dev/c0d0p3 /home mfs rw 0 2
|
||||||
none /sys devman rw,rslabel=devman 0 0
|
none /sys devman rw,rslabel=devman 0 0
|
||||||
END_FSTAB
|
END_FSTAB
|
||||||
|
|
||||||
rm -f ${DESTDIR}/SETS.*
|
rm -f ${DESTDIR}/SETS.*
|
||||||
|
@ -113,7 +130,7 @@ ${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${DESTDIR} ${DESTDIR}/etc/master.passwd
|
||||||
# After that we do some magic processing to add device nodes (also missing from METALOG)
|
# After that we do some magic processing to add device nodes (also missing from METALOG)
|
||||||
# and convert the METALOG into a proto file that can be used by mkfs.mfs
|
# and convert the METALOG into a proto file that can be used by mkfs.mfs
|
||||||
#
|
#
|
||||||
echo "creating the file systems"
|
echo "Creating the file systems"
|
||||||
|
|
||||||
#
|
#
|
||||||
# read METALOG and use mtree to convert the user and group names into uid and gids
|
# read METALOG and use mtree to convert the user and group names into uid and gids
|
||||||
|
@ -139,51 +156,40 @@ cat ${IMG_DIR}/input | grep -v "^./usr/" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDI
|
||||||
cat ${IMG_DIR}/input | grep "^\./usr/\|^. " | sed "s,\./usr,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/usr -o ${IMG_DIR}/usr.proto
|
cat ${IMG_DIR}/input | grep "^\./usr/\|^. " | sed "s,\./usr,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/usr -o ${IMG_DIR}/usr.proto
|
||||||
cat ${IMG_DIR}/input | grep "^\./home/\|^. " | sed "s,\./home,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/home -o ${IMG_DIR}/home.proto
|
cat ${IMG_DIR}/input | grep "^\./home/\|^. " | sed "s,\./home,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/home -o ${IMG_DIR}/home.proto
|
||||||
|
|
||||||
#
|
|
||||||
# This script creates a bootable image and should at some point in the future
|
|
||||||
# be replaced by makefs.
|
|
||||||
#
|
|
||||||
# All sized are written in 512 byte blocks
|
|
||||||
#
|
|
||||||
# we create a disk image of about 2 gig's
|
|
||||||
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
|
||||||
#
|
|
||||||
: ${ROOT_SIZE=$(( 64*(2**20) / 512))}
|
|
||||||
: ${HOME_SIZE=$(( 128*(2**20) / 512))}
|
|
||||||
: ${USR_SIZE=$(( 1536*(2**20) / 512))}
|
|
||||||
|
|
||||||
if [ "x${ISOMODE}" = "x1" ]
|
if [ "x${ISOMODE}" = "x1" ]
|
||||||
then
|
then
|
||||||
# In iso mode, make all FSes fit (i.e. as small as possible), but
|
cp ${DESTDIR}/usr/mdec/boot_monitor ${CDFILES}/boot
|
||||||
# leave some space on /
|
cp ${MODDIR}/* ${CDFILES}/
|
||||||
ROOTSIZEARG="-x 5"
|
. ${RELEASETOOLSDIR}/release.functions
|
||||||
else
|
cd_root_changes # uses $CDFILES and writes $CDFILES/boot.cfg
|
||||||
# In hd image mode, FSes have fixed sizes
|
# start the image off with the iso image; reduce root size to reserve
|
||||||
ROOTSIZEARG="-b $((${ROOT_SIZE} / 8))"
|
${CROSS_TOOLS}/nbwriteisofs -s0x0 -l MINIX -B ${DESTDIR}/usr/mdec/bootxx_cd9660 -n ${CDFILES} ${IMG}
|
||||||
USRSIZEARG="-b $((${USR_SIZE} / 8))"
|
ISO_SIZE=$((`${CROSS_TOOLS}/nbstat -f %z ${IMG}` / 512))
|
||||||
HOMESIZEARG="-b $((${HOME_SIZE} / 8))"
|
else
|
||||||
|
# just make an empty iso partition
|
||||||
|
ISO_SIZE=8
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate /root, /usr and /home partition images.
|
||||||
|
#
|
||||||
echo "Writing Minix filesystem images"
|
echo "Writing Minix filesystem images"
|
||||||
|
|
||||||
#
|
|
||||||
# Do some math to determine the start addresses of the partitions.
|
|
||||||
# Ensure the start of the partitions are always aligned, the end will
|
|
||||||
# always be as we assume the sizes are multiples of 4096 bytes, which
|
|
||||||
# is always true as soon as you have an integer multiple of 1MB.
|
|
||||||
#
|
|
||||||
ROOT_START=${ISO_SIZE}
|
ROOT_START=${ISO_SIZE}
|
||||||
|
|
||||||
echo " - ROOT"
|
echo " - ROOT"
|
||||||
ROOT_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d $ROOTSIZEARG -I $(($ROOT_START*512)) ${IMG} ${IMG_DIR}/root.proto`/512))
|
_ROOT_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${IMG_DIR}/root.proto`/512))
|
||||||
USR_START=$((${ROOT_START} + ${ROOT_SIZE}))
|
USR_START=$((${ROOT_START} + ${_ROOT_SIZE}))
|
||||||
echo " - USR"
|
echo " - USR"
|
||||||
USR_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d $USRSIZEARG -I $(($USR_START*512)) ${IMG} ${IMG_DIR}/usr.proto`/512))
|
_USR_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${IMG_DIR}/usr.proto`/512))
|
||||||
HOME_START=$((${USR_START} + $USR_SIZE))
|
HOME_START=$((${USR_START} + ${_USR_SIZE}))
|
||||||
echo " - HOME"
|
echo " - HOME"
|
||||||
HOME_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d $HOMESIZEARG -I $(($HOME_START*512)) ${IMG} ${IMG_DIR}/home.proto`/512))
|
_HOME_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${IMG_DIR}/home.proto`/512))
|
||||||
|
|
||||||
${CROSS_TOOLS}/nbpartition -m ${IMG} 0 81:${ISO_SIZE} 81:${ROOT_SIZE} 81:${USR_SIZE} 81:${HOME_SIZE}
|
#
|
||||||
|
# Write the partition table using the natively compiled
|
||||||
|
# minix partition utility
|
||||||
|
#
|
||||||
|
${CROSS_TOOLS}/nbpartition -m ${IMG} 0 81:${ISO_SIZE} \
|
||||||
|
81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
||||||
|
|
||||||
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
||||||
if [ "x${ISOMODE}" = "x1" ]
|
if [ "x${ISOMODE}" = "x1" ]
|
||||||
|
@ -191,5 +197,5 @@ then
|
||||||
echo "CD image at `pwd`/${IMG}"
|
echo "CD image at `pwd`/${IMG}"
|
||||||
else
|
else
|
||||||
echo "To boot this image on kvm:"
|
echo "To boot this image on kvm:"
|
||||||
echo "cd ${MODDIR} && kvm -display none -serial stdio -kernel kernel -append \"console=tty00 rootdevname=c0d0p1\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|
echo "cd ${MODDIR} && qemu-system-i386 -display none -serial stdio -kernel kernel -append \"console=tty00 rootdevname=c0d0p1\" -initrd \"${mods}\" -hda `pwd`/${IMG} --enable-kvm"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue