{
  "_comment": "Build with `packer build ubuntu.json`",
  "builders": [
    {
      "iso_urls": [ "output-ubuntu1804/ubuntu1804" ],
      "iso_checksum": "none",
      "disk_image": "true",
      "use_backing_file": "true",
      "headless": "{{ user `headless` }}",
      "disable_vnc": "false",
      "output_directory": "output-{{ user `vm_name` }}",
      "qemuargs": [
        [
          "-m",
          "{{ user `memory` }}"
        ],
        [
          "-display",
          "none"
        ],
        [
          "-machine",
          "accel=kvm"
        ],
        [
          "-cpu",
          "host"
        ],
        [
          "-smp",
          "cpus={{ user `cpus`}}"
        ],
        [
            "-serial",
            "mon:stdio"
        ]
      ],
      "shutdown_command": "echo '{{ user `ssh_password` }}'|sudo -S shutdown -P now",
      "ssh_password": "{{ user `ssh_password` }}",
      "ssh_timeout": "10000s",
      "ssh_username": "{{ user `ssh_username` }}",
      "type": "qemu",
      "vm_name": "{{ user `vm_name` }}"
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "scripts/guestinit.sh",
      "destination": "/home/ubuntu/guestinit.sh",
      "direction": "upload"
    },
    {
      "type": "file",
      "source": "bzImage",
      "destination": "/tmp/bzImage",
      "direction": "upload"
    },
    {
      "type": "file",
      "source": "kernel/config-5.4.46",
      "destination": "/tmp/config-5.4.46",
      "direction": "upload"
    },
    {
      "type": "file",
      "source": "kheaders.tar.bz2",
      "destination": "/tmp/kheaders.tar.bz2",
      "direction": "upload"
    },
    {
      "type": "shell",
      "inline": [
          "sudo mv /tmp/bzImage /boot/vmlinuz-5.4.46",
          "sudo mv /tmp/config-5.4.46 /boot/config-5.4.46",
          "sudo update-grub",
          "cd / && sudo tar xf /tmp/kheaders.tar.bz2"
      ]
    },
    {
      "type": "file",
      "source": "m5",
      "destination": "/tmp/m5",
      "direction": "upload"
    },
    {
      "type": "shell",
      "inline": ["sudo mv /tmp/m5 /sbin/m5"]
    }
  ],
  "variables": {
    "cleanup_pause": "",
    "cpus": "4",
    "custom_script": ".",
    "desktop": "false",
    "disk_size": "10000",
    "headless": "", "hostname": "vagrant",
    "memory": "4096",
    "preseed": "preseed.cfg",
    "ssh_fullname": "vagrant",
    "ssh_password": "ubuntu",
    "ssh_username": "ubuntu",
    "vagrantfile_template": "",
    "version": "0.1.0",
    "vm_name": "base"
  }
}

