diff options
-rw-r--r-- | tools/builder_common.sh | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/tools/builder_common.sh b/tools/builder_common.sh index 06e112e..cf9f11a 100644 --- a/tools/builder_common.sh +++ b/tools/builder_common.sh @@ -878,7 +878,8 @@ create_ova_image() { [ -d "${OVA_TMP}" ] \ && rm -rf ${OVA_TMP} - mkdir -p ${OVA_TMP} + local _mntdir=${OVA_TMP}/mnt + mkdir -p ${_mntdir} if [ -z "${OVA_SWAP_PART_SIZE_IN_GB}" -o "${OVA_SWAP_PART_SIZE_IN_GB}" = "0" ]; then # first partition size (freebsd-ufs) @@ -913,31 +914,28 @@ create_ova_image() { # Create / partition echo -n ">>> Creating / partition... " | tee -a ${LOGFILE} - makefs \ - -B little \ - -o label=${PRODUCT_NAME},version=2,bsize=32768,fsize=4096,maxbpg=4096,density=8192,minfree=8 \ - -s ${OVA_FIRST_PART_SIZE} \ - ${OVA_TMP}/${OVFUFS} \ - ${FINAL_CHROOT_DIR} 2>&1 >> ${LOGFILE} - - if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFUFS} ]; then - if [ -f ${OVA_TMP}/${OVFUFS} ]; then - rm -f ${OVA_TMP}/${OVFUFS} - fi - echo "Failed!" | tee -a ${LOGFILE} - echo ">>> ERROR: Error creating vmdk / partition. STOPPING!" | tee -a ${LOGFILE} - print_error_pfS - fi - echo "Done!" | tee -a ${LOGFILE} + truncate -s ${OVA_FIRST_PART_SIZE} ${OVA_TMP}/${OVFUFS} + local _md=$(mdconfig -a -f ${OVA_TMP}/${OVAUFS}) + trap "mdconfig -d -u ${_md}; return" 1 2 15 EXIT + + newfs -L ${PRODUCT_NAME} -j /dev/${_md} 2>&1 >>${LOGFILE} - echo -n ">>> Enabling SUJ on recently created disk... " | tee -a ${LOGFILE} - if ! tunefs -j enable ${OVA_TMP}/${OVFUFS} 2>&1 >>${LOGFILE}; then + if ! mount /dev/${_md} ${_mntdir} 2>&1 >>${LOGFILE}; then echo "Failed!" | tee -a ${LOGFILE} - echo ">>> ERROR: Error enabling SUJ on disk. STOPPING!" | tee -a ${LOGFILE} + echo ">>> ERROR: Error mounting temporary vmdk image. STOPPING!" | tee -a ${LOGFILE} print_error_pfS fi + trap "umount ${_mntdir}; mdconfig -d -u ${_md}; return" 1 2 15 EXIT + echo "Done!" | tee -a ${LOGFILE} + clone_directory_contents ${FINAL_CHROOT_DIR} ${_mntdir} + + sync + umount ${_mntdir} 2>&1 >>${LOGFILE} + mdconfig -d -u ${_md} + trap "-" 1 2 15 EXIT + # Create raw disk echo -n ">>> Creating raw disk... " | tee -a ${LOGFILE} mkimg \ |