#!/bin/bash set -e #set -x : ${ARCH=evbearm-el} : ${OBJ=../obj.${ARCH}} : ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin} : ${CROSS_PREFIX=${CROSS_TOOLS}/arm-elf32-minix-} : ${JOBS=-j4} : ${DESTDIR=${OBJ}/destdir.$ARCH} : ${FSTAB=${DESTDIR}/etc/fstab} # # Directory where to store temporary file system images # : ${IMG_DIR=${OBJ}/img} : ${IMG=minix_arm_sd.img} : ${MLO=MLO} : ${UBOOT=u-boot.img} BUILDSH=build.sh 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 for needed in sfdisk mcopy dd wget mkfs.vfat do if ! which $needed 2>&1 > /dev/null then echo "**Skipping image creation: missing tool '$needed'" exit 1 fi done # # Artifacts from this script are stored in the IMG_DIR # mkdir -p $IMG_DIR # # Download the stage 1 bootloader and u-boot # for i in ${MLO} ${UBOOT} do if [ ! -f ${IMG_DIR}/${i} ] then if ! wget -O ${IMG_DIR}/$i http://www.minix3.org/arm/beagleboard-xm/$i then echo "Failed to download $i" rm -f ${IMG_DIR}/$i exit 1 fi fi done # # Call build.sh using a sloppy file list so we don't need to remove the installed /etc/fstag # sh build.sh -V SLOPPY_FLIST=yes ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} -U -u distribution # # 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 # # The size of the extended partition where we store # /root /home and /usr in separate sub partitions is # about 1 gig # IMG_SIZE=$((2**31 / 512)) FAT_SIZE=$((20480)) EXTENDED_SIZE=$((2**30 / 512)) ROOT_SIZE=$((2**26 / 512)) HOME_SIZE=$((2**27 / 512)) USR_SIZE=$((2**28 / 512)) # # create a fstab entry in /etc this is normally done during the # setup phase on x86 # cat >${FSTAB} < ${IMG_DIR}/input # 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.in # # add device nodes somewhere in the middle of the proto file. Better would be to add the entries in the # original METALOG # grab the first part grep -B 10000 "^ dev" ${IMG_DIR}/root.in > ${IMG_DIR}/root.proto # add the device nodes from the ramdisk cat ${OBJ}/drivers/ramdisk/proto.dev >> ${IMG_DIR}/root.proto # and add the rest of the file grep -A 10000 "^ dev" ${IMG_DIR}/root.in | tail -n +2 >> ${IMG_DIR}/root.proto rm ${IMG_DIR}/root.in # # 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 # fill /root /usr and /home the numbers here need to be tweaked to match full partitions # This part needs fixing: no more magic numbers. It should be possible to call mkfs.mfs -b $((SIZE / 8)) # #${CROSS_TOOLS}/nbmkfs.mfs -b $((102400 / 8)) -x 20 ${IMG_DIR}/root.img ${IMG_DIR}/root.proto ${CROSS_TOOLS}/nbmkfs.mfs -x 30 ${IMG_DIR}/root.img ${IMG_DIR}/root.proto ${CROSS_TOOLS}/nbmkfs.mfs -x 30 ${IMG_DIR}/usr.img ${IMG_DIR}/usr.proto ${CROSS_TOOLS}/nbmkfs.mfs -x 30 ${IMG_DIR}/home.img ${IMG_DIR}/home.proto # # Merge the partitions into a single image. # echo "Merging file systems" dd if=${IMG_DIR}/fat.img of=${IMG} seek=$FAT_START conv=notrunc dd if=${IMG_DIR}/root.img of=${IMG} seek=$ROOT_START conv=notrunc dd if=${IMG_DIR}/home.img of=${IMG} seek=$HOME_START conv=notrunc dd if=${IMG_DIR}/usr.img of=${IMG} seek=$USR_START conv=notrunc