From 502db0bde9976bb7c4d950b759e61b8c6eb43582 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 31 Aug 2015 16:31:14 -0300 Subject: Use modern pfSense.ovf template, remove unnecessary variables and use vmdktool to convert disk to a modern version --- tools/builder_common.sh | 53 ++++++++++-------- tools/builder_defaults.sh | 15 +++--- tools/templates/ovf/pfSense.ovf | 117 +++++++++++++++++++++++++++++----------- 3 files changed, 123 insertions(+), 62 deletions(-) (limited to 'tools') diff --git a/tools/builder_common.sh b/tools/builder_common.sh index 31e6baf..8459c87 100644 --- a/tools/builder_common.sh +++ b/tools/builder_common.sh @@ -380,7 +380,7 @@ print_flags() { printf " BUILD_KERNELS: %s\n" $BUILD_KERNELS printf " Git Branch or Tag: %s\n" $GIT_REPO_BRANCH_OR_TAG printf " MODULES_OVERRIDE: %s\n" $MODULES_OVERRIDE - printf " OVADISKSIZE: %s\n" $OVADISKSIZE + printf " VMDK_DISK_CAPACITY_IN_GB: %s\n" $VMDK_DISK_CAPACITY_IN_GB printf " OVA_FIRST_PART_SIZE: %s\n" $OVA_FIRST_PART_SIZE printf " OVA_SWAP_PART_SIZE: %s\n" $OVA_SWAP_PART_SIZE printf " OVFTEMPLATE: %s\n" $OVFTEMPLATE @@ -821,12 +821,29 @@ create_ova_image() { -p freebsd-boot:=/boot/gptboot \ -p freebsd-ufs/${PRODUCT_NAME}:=${OVA_TMP}/${OVFUFS} \ -p freebsd-swap/swap0::${OVA_SWAP_PART_SIZE} \ - -o ${OVA_TMP}/${OVFVMDK} 2>&1 >> ${LOGFILE} + -o ${OVA_TMP}/${OVFVMDK}.tmp 2>&1 >> ${LOGFILE} - if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFVMDK} ]; then + if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFVMDK}.tmp ]; then if [ -f ${OVA_TMP}/${OVFUFS} ]; then rm -f ${OVA_TMP}/${OVFUFS} fi + if [ -f ${OVA_TMP}/${OVFVMDK}.tmp ]; then + rm -f ${OVA_TMP}/${OVFVMDK}.tmp + fi + echo ">>> ERROR: Error creating temporary vmdk image. STOPPING!" | tee -a ${LOGFILE} + print_error_pfS + fi + + # We don't need it anymore + rm -f ${OVA_TMP}/${OVFUFS} >/dev/null 2>&1 + + # Convert vmdk disk to modern version + vmdktool -v ${OVA_TMP}/${OVFVMDK} ${OVA_TMP}/i${OVFVMDK}.tmp + + if [ $? -ne 0 -o ! -f ${OVA_TMP}/${OVFVMDK}.tmp ]; then + if [ -f ${OVA_TMP}/${OVFVMDK}.tmp ]; then + rm -f ${OVA_TMP}/${OVFVMDK}.tmp + fi if [ -f ${OVA_TMP}/${OVFVMDK} ]; then rm -f ${OVA_TMP}/${OVFVMDK} fi @@ -834,8 +851,7 @@ create_ova_image() { print_error_pfS fi - # We don't need it anymore - rm -f ${OVA_TMP}/${OVFUFS} >/dev/null 2>&1 + rm -f ${OVA_TMP}/i${OVFVMDK}.tmp ova_setup_ovf_template @@ -844,8 +860,6 @@ create_ova_image() { gtar -C ${OVA_TMP} -cpf ${OVAPATH} ${PRODUCT_NAME}.ovf ${OVFVMDK} rm -f ${OVA_TMP}/${OVFVMDK} >/dev/null 2>&1 - gzip -qf ${OVAPATH} & - echo ">>> OVA created: $(LC_ALL=C date)" | tee -a ${LOGFILE} } @@ -861,31 +875,28 @@ ova_setup_ovf_template() { # 78 FreeBSD 64-Bit if [ "${TARGET}" = "amd64" ]; then local _os_id="78" - local _os_type="FreeBSD 64-Bit" + local _os_type="freebsd64Guest" + local _os_descr="FreeBSD 64-Bit" elif [ "${TARGET}" = "i386" ]; then local _os_id="42" - local _os_type="FreeBSD" + local _os_type="freebsdGuest" + local _os_descr="FreeBSD" else echo ">>> ERROR: Platform not supported for OVA (${TARGET})" print_error_pfS fi - local POPULATEDSIZE=$(du -d0 -m $FINAL_CHROOT_DIR | cut -f1) - local POPULATEDSIZEBYTES=$((${POPULATEDSIZE}*1024^2)) - local REFERENCESSIZE=$(stat -f "%z" ${OVA_TMP}/${OVFVMDK}) - - echo ">>> Setting REFERENCESSIZE to ${REFERENCESSIZE}..." | tee -a ${LOGFILE} - echo ">>> Setting POPULATEDSIZEBYTES to ${POPULATEDSIZEBYTES}..." | tee -a ${LOGFILE} - echo ">>> Setting DISKSECTIONALLOCATIONUNITS to ${OVA_DISKSECTIONALLOCATIONUNITS}..." | tee -a ${LOGFILE} - echo ">>> Setting DISKSECTIONCAPACITY to ${OVADISKSIZE}..." | tee -a ${LOGFILE} + local POPULATED_SIZE=$(du -d0 -k $FINAL_CHROOT_DIR | cut -f1) + local POPULATED_SIZE_IN_BYTES=$((${POPULATED_SIZE}*1024)) + local VMDK_FILE_SIZE=$(stat -f "%z" ${OVA_TMP}/${OVFVMDK}) sed \ - -e "s,%%REFERENCESSIZE%%,${REFERENCESSIZE},g" \ - -e "s,%%DISKSECTIONALLOCATIONUNITS%%,${OVA_DISKSECTIONALLOCATIONUNITS},g" \ - -e "s,%%DISKSECTIONCAPACITY%%,${OVADISKSIZE},g" \ - -e "s,%%DISKSECTIONPOPULATEDSIZE%%,${POPULATEDSIZEBYTES},g" \ + -e "s,%%VMDK_FILE_SIZE%%,${VMDK_FILE_SIZE},g" \ + -e "s,%%VMDK_DISK_CAPACITY_IN_GB%%,${VMDK_DISK_CAPACITY_IN_GB},g" \ + -e "s,%%POPULATED_SIZE_IN_BYTES%%,${POPULATED_SIZE_IN_BYTES},g" \ -e "s,%%OS_ID%%,${_os_id},g" \ -e "s,%%OS_TYPE%%,${_os_type},g" \ + -e "s,%%OS_DESCR%%,${_os_descr},g" \ -e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" \ -e "s,%%PRODUCT_VERSION%%,${PRODUCT_VERSION},g" \ -e "s,%%PRODUCT_URL%%,${PRODUCT_URL},g" \ diff --git a/tools/builder_defaults.sh b/tools/builder_defaults.sh index ff47cb9..55d2882 100644 --- a/tools/builder_defaults.sh +++ b/tools/builder_defaults.sh @@ -201,15 +201,12 @@ export OVFTEMPLATE=${OVFTEMPLATE:-"${BUILDER_TOOLS}/templates/ovf/${PRODUCT_NAME export OVFUFS=${OVFUFS:-"${PRODUCT_NAME}-disk1.ufs"} # On disk name of VMDK file included in OVA export OVFVMDK=${OVFVMDK:-"${PRODUCT_NAME}-disk1.vmdk"} -# 10 gigabyte on disk VMDK size -export OVADISKSIZE=${OVADISKSIZE:-"10737418240"} -# first partition size (freebsd-ufs) GPT -export OVA_FIRST_PART_SIZE=${OVA_FIRST_PART_SIZE:-"$((8*1024*1024*1024))"} -# swap partition size (freebsd-swap) GPT - -# remaining space of 10G-8G - 128 block beginning/loader -export OVA_SWAP_PART_SIZE=${OVA_SWAP_PART_SIZE:-"4193725"} -# 10737254400 = 10240MB = virtual box vmdk file size XXX grab this value from vbox creation -export OVA_DISKSECTIONALLOCATIONUNITS=${OVA_DISKSECTIONALLOCATIONUNITS:-"10737254400"} +# 8 gigabyte on disk VMDK size +export VMDK_DISK_CAPACITY_IN_GB=${VMDK_DISK_CAPACITY_IN_GB:-"8"} +# first partition size (freebsd-ufs) +export OVA_FIRST_PART_SIZE=${OVA_FIRST_PART_SIZE:-"6g"} +# swap partition size (freebsd-swap) +export OVA_SWAP_PART_SIZE=${OVA_SWAP_PART_SIZE:-"2G"} # Temporary place to save files export OVA_TMP=${OVA_TMP:-"${SCRATCHDIR}/ova_tmp"} # end of OVF diff --git a/tools/templates/ovf/pfSense.ovf b/tools/templates/ovf/pfSense.ovf index 84ff184..1e8b9b7 100644 --- a/tools/templates/ovf/pfSense.ovf +++ b/tools/templates/ovf/pfSense.ovf @@ -1,27 +1,28 @@ - + + - + - List of the virtual disks used in the package - + Virtual disk information + The list of logical networks - - The VM WAN Network network + + The WAN network - - The VM LAN Network network + + The LAN network - pfSense virtual machine + A virtual machine pfSense - - %%OS_TYPE%% (pfSense) - %%OS_TYPE%% + + The kind of installed guest operating system + %%OS_DESCR%% Virtual hardware requirements @@ -29,74 +30,126 @@ Virtual Hardware Family 0 pfSense - vmx-07 + vmx-08 hertz * 10^6 Number of Virtual CPUs - 1 virtual CPU(s) + 2 virtual CPU(s) 1 3 - 1 + 2 byte * 2^20 Memory Size - 1024MB of memory + 512MB of memory 2 4 - 1024 + 512 0 SCSI Controller - scsi0 + SCSI controller 0 3 lsilogic 6 + 1 IDE Controller - VirtualIDEController 1 + IDE 1 4 5 0 IDE Controller - VirtualIDEController 0 + IDE 0 5 5 + + false + Video card + 6 + 24 + + + + + + + false + VMCI device + 7 + vmware.vmci + 1 + + + + + 0 + false + CD/DVD drive 1 + 8 + 4 + vmware.cdrom.remotepassthrough + 15 + + 7 true - VM WAN Network - VmxNet3 ethernet adapter on "VM WAN Network" - ethernet0 - 6 + WAN Network + VmxNet3 ethernet adapter on "WAN Network" + Network adapter 1 + 9 VmxNet3 10 + + 8 true - VM LAN Network - VmxNet3 ethernet adapter on "VM LAN Network" - ethernet0 - 7 + LAN Network + VmxNet3 ethernet adapter on "LAN Network" + Network adapter 2 + 10 VmxNet3 10 + + 0 - scsi0:0 + Hard disk 1 ovf:/disk/vmdisk1 - 8 + 11 3 17 + + + + + + + + + + + + + + + + + + Describes product information for the service @@ -106,8 +159,8 @@ %%PRODUCT_URL%% %%PRODUCT_URL%% - - An annotation + + A human-readable annotation pfSense is a free, open source customized distribution of FreeBSD tailored for use as a firewall and router. In addition to being a powerful, flexible firewalling and routing platform, it includes a long list of related features and a package system allowing further expandability without adding bloat and potential security vulnerabilities to the base distribution. pfSense is a popular project with more than 1 million downloads since its inception, and proven in countless installations ranging from small home networks protecting a PC and an Xbox to large corporations, universities and other organizations protecting thousands of network devices. -- cgit v1.1