From 21016bb512f4ce6b134b0f11c01583da04d2fc11 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 18 May 2016 08:55:17 -0300 Subject: Do not use makefs to create / partition since it fails badly sometimes --- tools/builder_common.sh | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'tools') diff --git a/tools/builder_common.sh b/tools/builder_common.sh index 70bb590..8043e23 100644 --- a/tools/builder_common.sh +++ b/tools/builder_common.sh @@ -879,7 +879,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) @@ -914,31 +915,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 \ -- cgit v1.1