Commit cfa3f143 authored by Sven-Hendrik Haase's avatar Sven-Hendrik Haase
Browse files

Merge branch 'qemu-virtualbox' into 'master'

Build the VirtualBox image with the qemu builder and convert it

Closes #108 and #106

See merge request !114
parents e455f1b1 ae03f87e
Pipeline #1383 failed with stages
in 37 minutes and 8 seconds
......@@ -47,6 +47,15 @@ build:cloud-qemu:
- "Arch-Linux-x86_64-cloudimg-*.*"
expire_in: 2d
build:vagrant-virtualbox:
stage: build
tags:
- ipv6
before_script:
- pacman -Syu --needed --noconfirm packer qemu-headless
script:
- packer build -only=virtualbox -except publish vagrant.json
build:vagrant-qemu:
stage: build
tags:
......@@ -54,7 +63,7 @@ build:vagrant-qemu:
before_script:
- pacman -Syu --needed --noconfirm packer qemu-headless
script:
- packer build -only=qemu -except publish vagrant.json
- packer build -only=libvirt -except publish vagrant.json
publish:
stage: publish
......@@ -62,7 +71,7 @@ publish:
- ipv6
- secure
before_script:
- pacman -Syu --needed --noconfirm qemu-headless virtualbox packer
- pacman -Syu --needed --noconfirm qemu-headless packer
script:
- packer build -var "vagrant_cloud_token=$VAGRANT_API_TOKEN" vagrant.json
only:
......
<?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:id="file1" ovf:href="packer-virtualbox.vmdk"/>
</References>
<DiskSection>
<Info>List of the virtual disks used in the package</Info>
<Disk ovf:capacity="DISK_CAPACITY" 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="packer-virtualbox-UNIX">
<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">ArchLinux_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>packer-virtualbox-UNIX</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>
</System>
<Item>
<rasd:Caption>2 virtual CPU</rasd:Caption>
<rasd:Description>Number of virtual CPUs</rasd:Description>
<rasd:ElementName>2 virtual CPU</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>2</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
<rasd:Caption>1024 MB of memory</rasd:Caption>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>1024 MB of memory</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>1024</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: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>5</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>17</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>6</rasd:InstanceID>
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
</Item>
</VirtualHardwareSection>
<vbox:Machine ovf:required="false" version="1.16-linux" uuid="{MACHINE_UUID}" name="packer-virtualbox-UNIX" OSType="ArchLinux_64" snapshotFolder="Snapshots">
<ovf:Info>Complete VirtualBox machine configuration in VirtualBox format</ovf:Info>
<Hardware>
<CPU count="2">
<PAE enabled="true"/>
<LongMode enabled="true"/>
<X2APIC enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
</CPU>
<Memory RAMSize="1024"/>
<Boot>
<Order position="1" device="HardDisk"/>
<Order position="2" device="DVD"/>
<Order position="3" device="None"/>
<Order position="4" device="None"/>
</Boot>
<VideoCapture file="." fps="25"/>
<RemoteDisplay enabled="true">
<VRDEProperties>
<Property name="TCP/Address" value="127.0.0.1"/>
<Property name="TCP/Ports" value="5912"/>
</VRDEProperties>
</RemoteDisplay>
<BIOS>
<IOAPIC enabled="true"/>
<SmbiosUuidLittleEndian enabled="true"/>
</BIOS>
<Network>
<Adapter slot="0" enabled="true" MACAddress="MAC_ADDRESS" type="82540EM">
<NAT/>
</Adapter>
</Network>
<AudioAdapter driver="OSS" enabledIn="false" enabledOut="false"/>
<Clipboard/>
</Hardware>
<StorageControllers>
<StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
<Image uuid="{DISK_UUID}"/>
</AttachedDevice>
</StorageController>
</StorageControllers>
</vbox:Machine>
</VirtualSystem>
</Envelope>
#!/bin/bash
set -e
set -x
cd "${OUTPUT}"
qemu-img convert -f qcow2 -O vmdk "${VM_NAME}" "${VM_NAME}.vmdk"
rm "${VM_NAME}"
cp ../box.ovf .
# VirtualBox-6.1.12 src/VBox/NetworkServices/Dhcpd/Config.cpp line 276
sed -e "s/MACHINE_UUID/$(uuidgen)/" \
-e "s/DISK_UUID/$(uuidgen)/" \
-e "s/DISK_CAPACITY/$(qemu-img info --output=json "${VM_NAME}.vmdk" | jq '."virtual-size"')/" \
-e "s/UNIX/$(date +%s)/" \
-e "s/MAC_ADDRESS/080027$(openssl rand -hex 3 | tr '[:lower:]' '[:upper:]')/" \
-i box.ovf
......@@ -11,14 +11,14 @@
},
"builders": [
{
"type": "virtualbox-iso",
"type": "qemu",
"name": "virtualbox",
"cpus": 2,
"memory": 1024,
"boot_wait": "{{user `boot_wait`}}",
"http_directory": "http",
"disk_discard": "unmap",
"disk_size": "{{user `disk_size`}}",
"hard_drive_discard": "true",
"guest_os_type": "ArchLinux_64",
"iso_checksum": "file:{{user `iso_checksum_url`}}",
"iso_url": "{{user `iso_url`}}",
"ssh_username": "vagrant",
......@@ -26,8 +26,9 @@
"ssh_port": 22,
"ssh_timeout": "2000s",
"shutdown_command": "sudo systemctl poweroff",
"guest_additions_mode": "disable",
"headless": "{{user `headless`}}",
"accelerator": "{{user `accelerator`}}",
"disk_compression": true,
"boot_command": [
"<enter><wait10><wait10><wait10><wait10><wait10><enter><enter>",
"curl -O 'http://{{.HTTPIP}}:{{.HTTPPort}}/install{,-common,-chroot}.sh'<enter><wait>",
......@@ -36,6 +37,7 @@
},
{
"type": "qemu",
"name": "libvirt",
"cpus": 2,
"memory": 1024,
"boot_wait": "{{user `boot_wait`}}",
......@@ -69,7 +71,7 @@
],
"execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'",
"only": [
"virtualbox-iso"
"virtualbox"
]
},
{
......@@ -81,32 +83,42 @@
],
"execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'",
"only": [
"qemu"
"libvirt"
]
}
],
"post-processors": [
[
{
"name": "publish",
"type": "vagrant",
"keep_input_artifact": false,
"output": "Arch-Linux-x86_64-{{ .Provider }}-{{isotime \"2006-01-02\"}}.box"
"type": "shell-local",
"only": [
"virtualbox"
],
"environment_vars": [
"OUTPUT=output-{{build_name}}",
"VM_NAME=packer-{{build_name}}"
],
"script": "post-processor/virtualbox.sh"
},
{
"type": "vagrant-cloud",
"type": "artifice",
"only": [
"virtualbox-iso"
"virtualbox"
],
"access_token": "{{user `vagrant_cloud_token`}}",
"box_tag": "archlinux/archlinux",
"version": "{{isotime \"2006.01.02\"}}"
"files": [
"output-{{build_name}}/packer-{{build_name}}.vmdk",
"output-{{build_name}}/box.ovf"
]
},
{
"name": "publish",
"type": "vagrant",
"keep_input_artifact": false,
"output": "Arch-Linux-x86_64-{{ .Provider }}-{{isotime \"2006-01-02\"}}.box",
"provider_override": "{{build_name}}"
},
{
"type": "vagrant-cloud",
"only": [
"qemu"
],
"access_token": "{{user `vagrant_cloud_token`}}",
"box_tag": "archlinux/archlinux",
"version": "{{isotime \"2006.01.02\"}}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment