summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-08-28 11:53:03 -0300
committerRenato Botelho <renato@netgate.com>2015-08-28 11:53:03 -0300
commitfc48ef5427ef108a30dca4d42655fe040b0aa5c7 (patch)
tree0d801f6e05f3519cc158e5db548e70c6c2de9c93
parent8950897efdd87deb15f00b46bcbaef7e85cdefe8 (diff)
downloadpfsense-fc48ef5427ef108a30dca4d42655fe040b0aa5c7.zip
pfsense-fc48ef5427ef108a30dca4d42655fe040b0aa5c7.tar.gz
Add macros between %% and %% on pfSense.ovf, then simplify the logic of ova_setup_ovf_template()
-rw-r--r--tools/builder_common.sh66
-rw-r--r--tools/templates/ovf/pfSense.ovf37
2 files changed, 39 insertions, 64 deletions
diff --git a/tools/builder_common.sh b/tools/builder_common.sh
index 1f4fc4d..d4abd2f 100644
--- a/tools/builder_common.sh
+++ b/tools/builder_common.sh
@@ -851,53 +851,47 @@ create_ova_image() {
# called from create_ova_image
ova_setup_ovf_template() {
- if [ -f ${OVFTEMPLATE} ]; then
- cp ${OVFTEMPLATE} ${OVA_TMP}/${PRODUCT_NAME}.ovf
- else
+ if [ ! -f ${OVFTEMPLATE} ]; then
echo ">>> ERROR: OVF template file (${OVFTEMPLATE}) not found."
print_error_pfS
fi
- file_search_replace PRODUCT_VERSION $PRODUCT_VERSION ${OVA_TMP}/${PRODUCT_NAME}.ovf
- file_search_replace PRODUCT_URL $PRODUCT_URL ${OVA_TMP}/${PRODUCT_NAME}.ovf
+ # OperatingSystemSection (${PRODUCT_NAME}.ovf)
+ # 42 FreeBSD 32-Bit
+ # 78 FreeBSD 64-Bit
+ if [ "${TARGET}" = "amd64" ]; then
+ local _os_id="78"
+ local _os_type="FreeBSD 64-Bit"
+ elif [ "${TARGET}" = "i386" ]; then
+ local _os_id="42"
+ local _os_type="FreeBSD"
+ else
+ echo ">>> ERROR: Platform not supported for OVA (${TARGET})"
+ print_error_pfS
+ fi
- local BUILDPLATFORM=$(uname -p)
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}
- file_search_replace REFERENCESSIZE ${REFERENCESSIZE} ${OVA_TMP}/${PRODUCT_NAME}.ovf
echo ">>> Setting POPULATEDSIZEBYTES to ${POPULATEDSIZEBYTES}..." | tee -a ${LOGFILE}
- # OperatingSystemSection (${PRODUCT_NAME}.ovf)
- # 42 FreeBSD 32-Bit
- # 78 FreeBSD 64-Bit
- if [ "$BUILDPLATFORM" = "i386" ]; then
- file_search_replace '"101"' '"42"' ${OVA_TMP}/${PRODUCT_NAME}.ovf
- file_search_replace 'FreeBSD XX-Bit' 'FreeBSD' ${OVA_TMP}/${PRODUCT_NAME}.ovf
- fi
- if [ "$BUILDPLATFORM" = "amd64" ]; then
- file_search_replace '"101"' '"78"' ${OVA_TMP}/${PRODUCT_NAME}.ovf
- file_search_replace 'FreeBSD XX-Bit' 'FreeBSD 64-Bit' ${OVA_TMP}/${PRODUCT_NAME}.ovf
- fi
- file_search_replace DISKSECTIONPOPULATEDSIZE $POPULATEDSIZEBYTES ${OVA_TMP}/${PRODUCT_NAME}.ovf
- # 10737254400 = 10240MB = virtual box vmdk file size XXX grab this value from vbox creation
- # 10737418240 = 10GB
- echo ">>> Setting DISKSECTIONALLOCATIONUNITS to 10737254400..." | tee -a ${LOGFILE}
- file_search_replace DISKSECTIONALLOCATIONUNITS $OVA_DISKSECTIONALLOCATIONUNITS ${OVA_TMP}/${PRODUCT_NAME}.ovf
- echo ">>> Setting DISKSECTIONCAPACITY to 10737418240..." | tee -a ${LOGFILE}
- file_search_replace DISKSECTIONCAPACITY $OVADISKSIZE ${OVA_TMP}/${PRODUCT_NAME}.ovf
-}
-
-# called from create_ova_image
-# This routine will replace a string in a file
-file_search_replace() {
- local SEARCH="$1"
- local REPLACE="$2"
- local FILENAME="$3"
+ echo ">>> Setting DISKSECTIONALLOCATIONUNITS to ${OVA_DISKSECTIONALLOCATIONUNITS}..." | tee -a ${LOGFILE}
+ echo ">>> Setting DISKSECTIONCAPACITY to ${OVADISKSIZE}..." | tee -a ${LOGFILE}
- if [ -f "${FILENAME}" ]; then
- sed -i '' -e "s/${SEARCH}/${REPLACE}/g" ${FILENAME}
- fi
+ sed \
+ -e "s,%%REFERENCESSIZE%%,${REFERENCESSIZE},g" \
+ -e "s,%%DISKSECTIONALLOCATIONUNITS%%,${OVA_DISKSECTIONALLOCATIONUNITS},g" \
+ -e "s,%%DISKSECTIONCAPACITY%%,${OVADISKSIZE},g" \
+ -e "s,%%DISKSECTIONPOPULATEDSIZE%%,${POPULATEDSIZEBYTES},g" \
+ -e "s,%%OS_ID%%,${_os_id},g" \
+ -e "s,%%OS_TYPE%%,${_os_type},g" \
+ -e "s,%%PRODUCT_NAME%%,${PRODUCT_NAME},g" \
+ -e "s,%%PRODUCT_VERSION%%,${PRODUCT_VERSION},g" \
+ -e "s,%%PRODUCT_URL%%,${PRODUCT_URL},g" \
+ -e "/^%%PRODUCT_LICENSE%%/r ${BUILDER_TOOR}/license.txt" \
+ -e "/^%%PRODUCT_LICENSE%%/d" \
+ ${OVFTEMPLATE} > ${OVA_TMP}/${PRODUCT_NAME}.ovf
}
# Cleans up previous builds
diff --git a/tools/templates/ovf/pfSense.ovf b/tools/templates/ovf/pfSense.ovf
index f70b9bd..84ff184 100644
--- a/tools/templates/ovf/pfSense.ovf
+++ b/tools/templates/ovf/pfSense.ovf
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Envelope vmw:buildId="build-171294" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<References>
- <File ovf:href="pfSense-disk1.vmdk" ovf:id="file1" ovf:size="REFERENCESSIZE"/>
+ <File ovf:href="pfSense-disk1.vmdk" ovf:id="file1" ovf:size="%%REFERENCESSIZE%%"/>
</References>
<DiskSection>
<Info>List of the virtual disks used in the package</Info>
- <Disk ovf:capacityAllocationUnits="byte" ovf:allocationUnits="DISKSECTIONALLOCATIONUNITS" ovf:capacity="DISKSECTIONCAPACITY" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" populatedSize="DISKSECTIONPOPULATEDSIZE"/>
+ <Disk ovf:capacityAllocationUnits="byte" ovf:allocationUnits="%%DISKSECTIONALLOCATIONUNITS%%" ovf:capacity="%%DISKSECTIONCAPACITY%%" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" populatedSize="%%DISKSECTIONPOPULATEDSIZE%%"/>
</DiskSection>
<NetworkSection>
<Info>The list of logical networks</Info>
@@ -19,9 +19,9 @@
<VirtualSystem ovf:id="pfSense">
<Info>pfSense virtual machine</Info>
<Name>pfSense</Name>
- <OperatingSystemSection ovf:id="101" vmw:osType="FreeBSD XX-Bit">
- <Info>FreeBSD XX-Bit</Info>
- <Description>FreeBSD XX-Bit (pfSense)</Description>
+ <OperatingSystemSection ovf:id="%%OS_ID%%">
+ <Info>%%OS_TYPE%% (pfSense)</Info>
+ <Description>%%OS_TYPE%%</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
@@ -102,9 +102,9 @@
<Info>Describes product information for the service</Info>
<Product>pfSense</Product>
<Vendor>Electric Sheep Fencing, LLC</Vendor>
- <Version>PRODUCT_VERSION</Version>
- <ProductUrl>PRODUCT_URL</ProductUrl>
- <VendorUrl>PRODUCT_URL</VendorUrl>
+ <Version>%%PRODUCT_VERSION%%</Version>
+ <ProductUrl>%%PRODUCT_URL%%</ProductUrl>
+ <VendorUrl>%%PRODUCT_URL%%</VendorUrl>
</ProductSection>
<AnnotationSection xsi:type="ovf:AnnotationSection_Type">
<Info>An annotation</Info>
@@ -113,26 +113,7 @@
<EulaSection>
<Info>The End User License Agreement</Info>
<License>
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+%%PRODUCT_LICENSE%%
</License>
</EulaSection>
</VirtualSystem>
OpenPOWER on IntegriCloud