mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 15:11:19 +02:00
Merge pull request #72 from marineam/vlite
vagrant image with oem partition
This commit is contained in:
commit
382645945a
15
build_image
15
build_image
@ -198,7 +198,16 @@ fi
|
|||||||
|
|
||||||
# Generating AU generator zip file to run outside chroot
|
# Generating AU generator zip file to run outside chroot
|
||||||
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
|
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
|
||||||
upload_image "${BUILD_DIR}/au-generator.zip"
|
|
||||||
|
# Write out a version.txt file, this will be used by image_to_vm.sh
|
||||||
|
tee "${BUILD_DIR}/version.txt" <<EOF
|
||||||
|
COREOS_BUILD=${COREOS_BUILD}
|
||||||
|
COREOS_BRANCH=${COREOS_BRANCH}
|
||||||
|
COREOS_PATCH=${COREOS_PATCH}
|
||||||
|
COREOS_SDK_VERSION=${COREOS_SDK_VERSION}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
upload_image "${BUILD_DIR}/au-generator.zip" "${BUILD_DIR}/version.txt"
|
||||||
|
|
||||||
# Create a named symlink.
|
# Create a named symlink.
|
||||||
LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}"
|
LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}"
|
||||||
@ -213,8 +222,10 @@ print_image_to_vm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
To convert it to a VMWare image, use:
|
To convert it to a virtual machine image, use:
|
||||||
./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD} ${flags}
|
./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD} ${flags}
|
||||||
|
|
||||||
|
The default type is qemu, see ./image_to_vm.sh --help for other options.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
291
build_library/virtualbox_ovf.sh
Executable file
291
build_library/virtualbox_ovf.sh
Executable file
@ -0,0 +1,291 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Mostly this just copies the below XML, but inserting random MAC address
|
||||||
|
# and UUID strings, and other options as appropriate.
|
||||||
|
|
||||||
|
SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..)
|
||||||
|
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||||
|
|
||||||
|
DEFINE_string vm_name "CoreOS" "Name for this VM"
|
||||||
|
DEFINE_string disk_vmdk "" "Disk image to reference, only basename is used."
|
||||||
|
DEFINE_integer memory_size 1024 "Memory size in MB"
|
||||||
|
DEFINE_string output_ovf "" "Path to write ofv file to, required."
|
||||||
|
DEFINE_string output_vagrant "" "Path to write Vagrantfile to, optional."
|
||||||
|
|
||||||
|
# Parse command line
|
||||||
|
FLAGS "$@" || exit 1
|
||||||
|
eval set -- "${FLAGS_ARGV}"
|
||||||
|
|
||||||
|
# Die on any errors.
|
||||||
|
switch_to_strict_mode
|
||||||
|
|
||||||
|
if [[ ! -e "${FLAGS_disk_vmdk}" ]]; then
|
||||||
|
echo "No such disk image '${FLAGS_disk_vmdk}'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${FLAGS_output_ovf}" ]]; then
|
||||||
|
echo "No ovf file path provided." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DISK_NAME=$(basename "${FLAGS_disk_vmdk}")
|
||||||
|
DISK_UUID=$(uuidgen)
|
||||||
|
DISK_SIZE_BYTES=$(qemu-img info -f vmdk "${FLAGS_disk_vmdk}" \
|
||||||
|
| gawk 'match($0, /^virtual size:.*\(([0-9]+) bytes\)/, a) {print a[1]}')
|
||||||
|
|
||||||
|
if [[ -z "${DISK_SIZE_BYTES}" ]]; then
|
||||||
|
echo "Unable to determine virtual size of ${FLAGS_disk_vmdk}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate random MAC addresses just as VirtualBox does, the format is
|
||||||
|
# their assigned prefix for the first 3 bytes followed by 3 random bytes.
|
||||||
|
VBOX_MAC_PREFIX=080027
|
||||||
|
macgen() {
|
||||||
|
hexdump -n3 -e "\"${VBOX_MAC_PREFIX}%X\n\"" /dev/urandom
|
||||||
|
}
|
||||||
|
|
||||||
|
# Used in both the ovf and Vagrantfile
|
||||||
|
PRIMARY_MAC=$(macgen)
|
||||||
|
|
||||||
|
# Date format as used in ovf
|
||||||
|
datez() {
|
||||||
|
date -u "+%Y-%m-%dT%H:%M:%SZ"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "${FLAGS_output_vagrant}" ]]; then
|
||||||
|
cat >"${FLAGS_output_vagrant}" <<EOF
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.base_mac = "${PRIMARY_MAC}"
|
||||||
|
|
||||||
|
# SSH in as the default 'core' user, it has the vagrant ssh key.
|
||||||
|
config.ssh.username = "core"
|
||||||
|
|
||||||
|
# Disable the base shared folder, guest additions are unavailable.
|
||||||
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >"${FLAGS_output_ovf}" <<EOF
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<Envelope ovf:version="1.0" xml:lang="en-US" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vbox="http://www.virtualbox.org/ovf/machine">
|
||||||
|
<References>
|
||||||
|
<File ovf:href="${DISK_NAME}" ovf:id="file1"/>
|
||||||
|
</References>
|
||||||
|
<DiskSection>
|
||||||
|
<Info>List of the virtual disks used in the package</Info>
|
||||||
|
<Disk ovf:capacity="${DISK_SIZE_BYTES}" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" vbox:uuid="${DISK_UUID}"/>
|
||||||
|
</DiskSection>
|
||||||
|
<NetworkSection>
|
||||||
|
<Info>Logical networks used in the package</Info>
|
||||||
|
<Network ovf:name="NAT">
|
||||||
|
<Description>Logical network used by this appliance.</Description>
|
||||||
|
</Network>
|
||||||
|
</NetworkSection>
|
||||||
|
<VirtualSystem ovf:id="${FLAGS_vm_name}">
|
||||||
|
<Info>A virtual machine</Info>
|
||||||
|
<OperatingSystemSection ovf:id="100">
|
||||||
|
<Info>The kind of installed guest operating system</Info>
|
||||||
|
<Description>Linux26_64</Description>
|
||||||
|
<vbox:OSType ovf:required="false">Linux26_64</vbox:OSType>
|
||||||
|
</OperatingSystemSection>
|
||||||
|
<VirtualHardwareSection>
|
||||||
|
<Info>Virtual hardware requirements for a virtual machine</Info>
|
||||||
|
<System>
|
||||||
|
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||||
|
<vssd:InstanceID>0</vssd:InstanceID>
|
||||||
|
<vssd:VirtualSystemIdentifier>${FLAGS_vm_name}</vssd:VirtualSystemIdentifier>
|
||||||
|
<vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>
|
||||||
|
</System>
|
||||||
|
<Item>
|
||||||
|
<rasd:Caption>1 virtual CPU</rasd:Caption>
|
||||||
|
<rasd:Description>Number of virtual CPUs</rasd:Description>
|
||||||
|
<rasd:ElementName>1 virtual CPU</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>1</rasd:InstanceID>
|
||||||
|
<rasd:ResourceType>3</rasd:ResourceType>
|
||||||
|
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
|
||||||
|
<rasd:Caption>${FLAGS_memory_size} MB of memory</rasd:Caption>
|
||||||
|
<rasd:Description>Memory Size</rasd:Description>
|
||||||
|
<rasd:ElementName>${FLAGS_memory_size} MB of memory</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>2</rasd:InstanceID>
|
||||||
|
<rasd:ResourceType>4</rasd:ResourceType>
|
||||||
|
<rasd:VirtualQuantity>${FLAGS_memory_size}</rasd:VirtualQuantity>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<rasd:Address>0</rasd:Address>
|
||||||
|
<rasd:Caption>ideController0</rasd:Caption>
|
||||||
|
<rasd:Description>IDE Controller</rasd:Description>
|
||||||
|
<rasd:ElementName>ideController0</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>3</rasd:InstanceID>
|
||||||
|
<rasd:ResourceSubType>PIIX4</rasd:ResourceSubType>
|
||||||
|
<rasd:ResourceType>5</rasd:ResourceType>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<rasd:Address>1</rasd:Address>
|
||||||
|
<rasd:Caption>ideController1</rasd:Caption>
|
||||||
|
<rasd:Description>IDE Controller</rasd:Description>
|
||||||
|
<rasd:ElementName>ideController1</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>4</rasd:InstanceID>
|
||||||
|
<rasd:ResourceSubType>PIIX4</rasd:ResourceSubType>
|
||||||
|
<rasd:ResourceType>5</rasd:ResourceType>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||||
|
<rasd:Caption>Ethernet adapter on 'NAT'</rasd:Caption>
|
||||||
|
<rasd:Connection>NAT</rasd:Connection>
|
||||||
|
<rasd:ElementName>Ethernet adapter on 'NAT'</rasd:ElementName>
|
||||||
|
<rasd:InstanceID>5</rasd:InstanceID>
|
||||||
|
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
|
||||||
|
<rasd:ResourceType>10</rasd:ResourceType>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||||
|
<rasd:Caption>disk1</rasd:Caption>
|
||||||
|
<rasd:Description>Disk Image</rasd:Description>
|
||||||
|
<rasd:ElementName>disk1</rasd:ElementName>
|
||||||
|
<rasd:HostResource>/disk/vmdisk1</rasd:HostResource>
|
||||||
|
<rasd:InstanceID>6</rasd:InstanceID>
|
||||||
|
<rasd:Parent>3</rasd:Parent>
|
||||||
|
<rasd:ResourceType>17</rasd:ResourceType>
|
||||||
|
</Item>
|
||||||
|
</VirtualHardwareSection>
|
||||||
|
<vbox:Machine ovf:required="false" version="1.12-linux" uuid="{$(uuidgen)}" name="${FLAGS_vm_name}" OSType="Linux26_64" snapshotFolder="Snapshots" lastStateChange="$(datez)">
|
||||||
|
<ovf:Info>Complete VirtualBox machine configuration in VirtualBox format</ovf:Info>
|
||||||
|
<Hardware version="2">
|
||||||
|
<CPU count="1" hotplug="false">
|
||||||
|
<HardwareVirtEx enabled="true" exclusive="true"/>
|
||||||
|
<HardwareVirtExNestedPaging enabled="true"/>
|
||||||
|
<HardwareVirtExVPID enabled="true"/>
|
||||||
|
<PAE enabled="true"/>
|
||||||
|
<HardwareVirtExLargePages enabled="false"/>
|
||||||
|
<HardwareVirtForce enabled="false"/>
|
||||||
|
</CPU>
|
||||||
|
<Memory RAMSize="${FLAGS_memory_size}" PageFusion="false"/>
|
||||||
|
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
|
||||||
|
<HPET enabled="false"/>
|
||||||
|
<Chipset type="PIIX3"/>
|
||||||
|
<Boot>
|
||||||
|
<Order position="1" device="HardDisk"/>
|
||||||
|
<Order position="2" device="DVD"/>
|
||||||
|
<Order position="3" device="None"/>
|
||||||
|
<Order position="4" device="None"/>
|
||||||
|
</Boot>
|
||||||
|
<Display VRAMSize="8" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
|
||||||
|
<VideoRecording enabled="false" file="Test.webm" horzRes="640" vertRes="480"/>
|
||||||
|
<RemoteDisplay enabled="false" authType="Null"/>
|
||||||
|
<BIOS>
|
||||||
|
<ACPI enabled="true"/>
|
||||||
|
<IOAPIC enabled="true"/>
|
||||||
|
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
|
||||||
|
<BootMenu mode="MessageAndMenu"/>
|
||||||
|
<TimeOffset value="0"/>
|
||||||
|
<PXEDebug enabled="false"/>
|
||||||
|
</BIOS>
|
||||||
|
<USBController enabled="false" enabledEhci="false"/>
|
||||||
|
<Network>
|
||||||
|
<Adapter slot="0" enabled="true" MACAddress="${PRIMARY_MAC}" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes/>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="1" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="2" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="3" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="4" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="5" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="6" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
<Adapter slot="7" enabled="false" MACAddress="$(macgen)" cable="true" speed="0" type="82540EM">
|
||||||
|
<DisabledModes>
|
||||||
|
<NAT>
|
||||||
|
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
|
||||||
|
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
|
||||||
|
</NAT>
|
||||||
|
</DisabledModes>
|
||||||
|
</Adapter>
|
||||||
|
</Network>
|
||||||
|
<UART>
|
||||||
|
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
|
||||||
|
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
|
||||||
|
</UART>
|
||||||
|
<LPT>
|
||||||
|
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
|
||||||
|
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
|
||||||
|
</LPT>
|
||||||
|
<AudioAdapter controller="AC97" driver="Pulse" enabled="false"/>
|
||||||
|
<RTC localOrUTC="local"/>
|
||||||
|
<SharedFolders/>
|
||||||
|
<Clipboard mode="Disabled"/>
|
||||||
|
<DragAndDrop mode="Disabled"/>
|
||||||
|
<IO>
|
||||||
|
<IoCache enabled="true" size="5"/>
|
||||||
|
<BandwidthGroups/>
|
||||||
|
</IO>
|
||||||
|
<HostPci>
|
||||||
|
<Devices/>
|
||||||
|
</HostPci>
|
||||||
|
<EmulatedUSB>
|
||||||
|
<CardReader enabled="false"/>
|
||||||
|
</EmulatedUSB>
|
||||||
|
<Guest memoryBalloonSize="0"/>
|
||||||
|
<GuestProperties/>
|
||||||
|
</Hardware>
|
||||||
|
<StorageControllers>
|
||||||
|
<StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
|
||||||
|
<AttachedDevice type="HardDisk" port="0" device="0">
|
||||||
|
<Image uuid="{${DISK_UUID}}"/>
|
||||||
|
</AttachedDevice>
|
||||||
|
</StorageController>
|
||||||
|
</StorageControllers>
|
||||||
|
</vbox:Machine>
|
||||||
|
</VirtualSystem>
|
||||||
|
</Envelope>
|
||||||
|
EOF
|
@ -9,6 +9,7 @@ VALID_IMG_TYPES=(
|
|||||||
ami
|
ami
|
||||||
qemu
|
qemu
|
||||||
rackspace
|
rackspace
|
||||||
|
vagrant
|
||||||
virtualbox
|
virtualbox
|
||||||
vmware
|
vmware
|
||||||
xen
|
xen
|
||||||
@ -37,7 +38,7 @@ IMG_DEFAULT_HYBRID_MBR=0
|
|||||||
IMG_DEFAULT_OEM_PACKAGE=
|
IMG_DEFAULT_OEM_PACKAGE=
|
||||||
|
|
||||||
# Name of the target image format.
|
# Name of the target image format.
|
||||||
# May be raw, vdi (virtualbox), or vmdk (vmware)
|
# May be raw or vmdk (vmware, virtualbox)
|
||||||
IMG_DEFAULT_DISK_FORMAT=raw
|
IMG_DEFAULT_DISK_FORMAT=raw
|
||||||
|
|
||||||
# Name of the target config format, default is no config
|
# Name of the target config format, default is no config
|
||||||
@ -55,7 +56,13 @@ IMG_xen_HYBRID_MBR=1
|
|||||||
IMG_xen_CONF_FORMAT=xl
|
IMG_xen_CONF_FORMAT=xl
|
||||||
|
|
||||||
## virtualbox
|
## virtualbox
|
||||||
IMG_virtualbox_DISK_FORMAT=vdi
|
IMG_virtualbox_DISK_FORMAT=vmdk
|
||||||
|
IMG_virtualbox_CONF_FORMAT=ovf
|
||||||
|
|
||||||
|
## vagrant
|
||||||
|
IMG_vagrant_DISK_FORMAT=vmdk
|
||||||
|
IMG_vagrant_CONF_FORMAT=vagrant
|
||||||
|
IMG_vagrant_OEM_PACKAGE=oem-vagrant
|
||||||
|
|
||||||
## vmware
|
## vmware
|
||||||
IMG_vmware_DISK_FORMAT=vmdk
|
IMG_vmware_DISK_FORMAT=vmdk
|
||||||
@ -99,14 +106,7 @@ set_vm_paths() {
|
|||||||
VM_DST_IMG="${dst_dir}/${dst_name}"
|
VM_DST_IMG="${dst_dir}/${dst_name}"
|
||||||
VM_TMP_DIR="${dst_dir}/${dst_name}.vmtmpdir"
|
VM_TMP_DIR="${dst_dir}/${dst_name}.vmtmpdir"
|
||||||
VM_TMP_IMG="${VM_TMP_DIR}/disk_image.bin"
|
VM_TMP_IMG="${VM_TMP_DIR}/disk_image.bin"
|
||||||
|
VM_NAME="$(_src_to_dst_name "${src_name}" "")-${COREOS_VERSION_STRING}"
|
||||||
# If src_dir happens to be in the build directory figure out the version
|
|
||||||
# from the directory name and use it in the vm name for config files.
|
|
||||||
VM_NAME=$(_src_to_dst_name "${src_name}" "")
|
|
||||||
if [[ "${src_dir}" =~ /build/images/${BOARD}/\d+\.\d+\.[^/]*$ ]]; then
|
|
||||||
VM_NAME+="-$(basename ${src_dir})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
VM_UUID=$(uuidgen)
|
VM_UUID=$(uuidgen)
|
||||||
VM_README="${dst_dir}/$(_src_to_dst_name "${src_name}" ".README")"
|
VM_README="${dst_dir}/$(_src_to_dst_name "${src_name}" ".README")"
|
||||||
}
|
}
|
||||||
@ -256,11 +256,6 @@ _write_raw_disk() {
|
|||||||
mv "$1" "$2"
|
mv "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
_write_vdi_disk() {
|
|
||||||
sudo VBoxManage convertdd "$1" "$2"
|
|
||||||
sudo chown $(id -un) "$2"
|
|
||||||
}
|
|
||||||
|
|
||||||
_write_vmdk_disk() {
|
_write_vmdk_disk() {
|
||||||
qemu-img convert -f raw "$1" -O vmdk "$2"
|
qemu-img convert -f raw "$1" -O vmdk "$2"
|
||||||
}
|
}
|
||||||
@ -403,6 +398,64 @@ EOF
|
|||||||
VM_GENERATED_FILES+=( "${pygrub}" "${pvgrub}" "${VM_README}" )
|
VM_GENERATED_FILES+=( "${pygrub}" "${pvgrub}" "${VM_README}" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_write_ovf_conf() {
|
||||||
|
local vm_mem="${1:-$(_get_vm_opt MEM)}"
|
||||||
|
local src_name=$(basename "$VM_SRC_IMG")
|
||||||
|
local dst_name=$(basename "$VM_DST_IMG")
|
||||||
|
local dst_dir=$(dirname "$VM_DST_IMG")
|
||||||
|
local ovf="${dst_dir}/$(_src_to_dst_name "${src_name}" ".ovf")"
|
||||||
|
|
||||||
|
"${BUILD_LIBRARY_DIR}/virtualbox_ovf.sh" \
|
||||||
|
--vm_name "$VM_NAME" \
|
||||||
|
--disk_vmdk "$VM_DST_IMG" \
|
||||||
|
--memory_size "$vm_mem" \
|
||||||
|
--output_ovf "$ovf"
|
||||||
|
|
||||||
|
local ovf_name=$(basename "${ovf}")
|
||||||
|
cat > "${VM_README}" <<EOF
|
||||||
|
Copy ${dst_name} and ${ovf_name} to a VirtualBox host and run:
|
||||||
|
VBoxManage import ${ovf_name}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
VM_GENERATED_FILES+=( "$ovf" "${VM_README}" )
|
||||||
|
}
|
||||||
|
|
||||||
|
_write_vagrant_conf() {
|
||||||
|
local vm_mem="${1:-$(_get_vm_opt MEM)}"
|
||||||
|
local src_name=$(basename "$VM_SRC_IMG")
|
||||||
|
local dst_name=$(basename "$VM_DST_IMG")
|
||||||
|
local dst_dir=$(dirname "$VM_DST_IMG")
|
||||||
|
local ovf="${VM_TMP_DIR}/box.ovf"
|
||||||
|
local vfile="${VM_TMP_DIR}/Vagrantfile"
|
||||||
|
local box="${dst_dir}/$(_src_to_dst_name "${src_name}" ".box")"
|
||||||
|
|
||||||
|
# Move the disk image to tmp, it won't be a final output file
|
||||||
|
mv "${VM_DST_IMG}" "${VM_TMP_DIR}/${dst_name}"
|
||||||
|
|
||||||
|
"${BUILD_LIBRARY_DIR}/virtualbox_ovf.sh" \
|
||||||
|
--vm_name "$VM_NAME" \
|
||||||
|
--disk_vmdk "${VM_TMP_DIR}/${dst_name}" \
|
||||||
|
--memory_size "$vm_mem" \
|
||||||
|
--output_ovf "$ovf" \
|
||||||
|
--output_vagrant "$vfile"
|
||||||
|
|
||||||
|
tar -cf "${box}" -C "${VM_TMP_DIR}" "box.ovf" "Vagrantfile" "${dst_name}"
|
||||||
|
|
||||||
|
cat > "${VM_README}" <<EOF
|
||||||
|
Vagrant >= 1.2 is required. Use something like the following to get started:
|
||||||
|
vagrant box add coreos path/to/$(basename "${box}")
|
||||||
|
vagrant init coreos
|
||||||
|
vagrant up
|
||||||
|
vagrant ssh
|
||||||
|
|
||||||
|
You will get a warning about "No guest additions were detected...",
|
||||||
|
this is expected and should be ignored. SSH should work just dandy.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Replace list, not append, since we packaged up the disk image.
|
||||||
|
VM_GENERATED_FILES=( "${box}" "${VM_README}" )
|
||||||
|
}
|
||||||
|
|
||||||
vm_cleanup() {
|
vm_cleanup() {
|
||||||
info "Cleaning up temporary files"
|
info "Cleaning up temporary files"
|
||||||
rm -rf "${VM_TMP_DIR}"
|
rm -rf "${VM_TMP_DIR}"
|
||||||
|
@ -29,8 +29,6 @@ DEFINE_string adjust_part "" \
|
|||||||
"Adjustments to apply to the partition table"
|
"Adjustments to apply to the partition table"
|
||||||
DEFINE_string board "${DEFAULT_BOARD}" \
|
DEFINE_string board "${DEFAULT_BOARD}" \
|
||||||
"Board for which the image was built"
|
"Board for which the image was built"
|
||||||
DEFINE_boolean prod $FLAGS_FALSE \
|
|
||||||
"Build prod image"
|
|
||||||
|
|
||||||
# We default to TRUE so the buildbot gets its image. Note this is different
|
# We default to TRUE so the buildbot gets its image. Note this is different
|
||||||
# behavior from image_to_usb.sh
|
# behavior from image_to_usb.sh
|
||||||
@ -88,6 +86,12 @@ fi
|
|||||||
FLAGS_from=`eval readlink -f $FLAGS_from`
|
FLAGS_from=`eval readlink -f $FLAGS_from`
|
||||||
FLAGS_to=`eval readlink -f $FLAGS_to`
|
FLAGS_to=`eval readlink -f $FLAGS_to`
|
||||||
|
|
||||||
|
# If source includes version.txt switch to its version information
|
||||||
|
if [ -f "${FLAGS_from}/version.txt" ]; then
|
||||||
|
source "${FLAGS_from}/version.txt"
|
||||||
|
COREOS_VERSION_STRING="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${FLAGS_prod_image} -eq ${FLAGS_TRUE} ]; then
|
if [ ${FLAGS_prod_image} -eq ${FLAGS_TRUE} ]; then
|
||||||
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${COREOS_PRODUCTION_IMAGE_NAME}"
|
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${COREOS_PRODUCTION_IMAGE_NAME}"
|
||||||
elif [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
|
elif [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user