Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Vagrant to build the image in mac os or windows hosts #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.vagrant
*.iso
*.deb
*.log
sharedvm/*
/initramfs.fakeroot
/initramfs/*
Expand Down
38 changes: 38 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "ubuntu/bionic64"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
# vb.gui = true

# Customize the amount of memory on the VM:
vb.memory = "4096"
end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y xorriso p7zip-full fakeroot binutils isolinux
SHELL
end
35 changes: 0 additions & 35 deletions build-and-run → build
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ fi
UNIQ=`date | sha1sum | cut -c 1-7`
ISO=`find ./iso/netinstall* | head -n1`

VMS_ROOT="${HOME}/VirtualBox VMs"
VM="Ubuntu-`echo ${ISO} | cut -d "-" -f 2-3`-${UNIQ}"
VM_HDD="${VMS_ROOT}/${VM}/${VM}"
VM_HDD_FILE="${VM_HDD}.vdi"

shout "Setting up"

# Some dependency checks
directory_exists "${VMS_ROOT}" "Cannot find VirtualBox VM directory ${VMS_ROOT}"
file_exists "${ISO}" "Cannot find iso ${ISO}"
is_runnable "vboxmanage" "Cannot find/run vboxmanage"
is_runnable "xorriso" "Cannot find/run xorriso"
is_runnable "7z" "Cannot find/run 7z"
is_runnable "sha1sum" "Cannot find/run sha1sum"
Expand Down Expand Up @@ -98,33 +93,3 @@ xorriso -as mkisofs \
./tmp

shout "Cleanup"

shout "Booting VM to start install"

VBoxManage -v &> /dev/null || { echo "ERROR: VBoxManage not in path!"; exit 1; }
VBoxManage createvm --name "${VM}" --register
VBoxManage modifyvm "${VM}" --ostype Ubuntu_64 --memory 8192 --vram 64 --rtcuseutc on --ioapic on \
--clipboard bidirectional --cpus 2 --firmware efi64

# ISO image to boot
VBoxManage storagectl "${VM}" --name ide0 --add ide
VBoxManage storageattach "${VM}" --storagectl ide0 --device 0 --port 0 --type dvddrive --medium ./${VM}-unattended.iso

# Storage to be used as primary disk
VBoxManage storagectl "${VM}" --name nvme0 --add pcie --controller NVMe --portcount 1
VBoxManage createhd --filename "${VM_HDD_FILE}" --size 40960
VBoxManage storageattach "${VM}" --storagectl nvme0 --port 0 --type hdd --medium "${VM_HDD_FILE}"

# Other stuff
VBoxManage modifyvm "${VM}" --nic1 nat
VBoxManage startvm --type=gui "${VM}"

# Wait until we're done with it
wait_vm_quit ${VM}

echo -n "Remove the ${VM} VM?"
read answer

if [[ "$answer" != "${answer#[Yy]}" ]]; then
VBoxManage unregistervm "$VM" --delete
fi