Skip to content
Merged
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
21 changes: 8 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
run: |
pip3 install demjson3
- name: Run jsonlint
run: |
jsonlint packer/*json
- name: Install Hashicorp repo
run: >
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor |
Expand All @@ -53,10 +43,15 @@ jobs:
sudo apt-get install -y -qq packer
- name: Packer validate
run: |
packer validate packer/ubuntu-build.json
packer validate packer/mint-build.json
# Allow beta/test builds to fail validation
packer validate -var-file=packer/beta-vars.json packer/mint-build.json || true
packer validate -var-file=mint-beta.pkrvars.hcl . || true
# This runs last to ensure it's exit status is captured
packer validate .
working-directory: packer
- name: Check Packer HCL formatting
run: |
packer fmt -diff -check .
working-directory: packer
Python:
name: Run Python lint tests
runs-on: ubuntu-20.04
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

# Packer-related binaries
packer/packer_cache/*
packer/artifacts_mint/*
packer/artifacts_ubuntu/*
packer/artifacts*/*
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ Linux and Windows hosts, but feedback on other platforms is always welcome.

Due to difficulties with Packer packaging, this VM is frequently built with the
latest version of Packer available directly from Hashicorp. Check the
`mint-build.json` file for the current minimum version required.
`main.pkr.hcl` file for the current minimum version required.

Once the prerequisites are installed, change into the `cs-vm-build/packer`
directory and execute `packer build mint-build.json`. This will take a
directory and execute `packer build -only "*.mint" .`. This will take a
considerable amount of time, depending on host resources available, but should
output progress indicators along the way.

Expand All @@ -164,15 +164,31 @@ specify `dsound` for Windows, `coreaudio` for Mac.
### Building beta images

A large number of variables can be overridden at once by passing a `var-file`
to Packer. An example of this is provided as `beta-vars.json`, and can be used
to Packer. An example of this is provided as `mint-beta.pkrvars.hcl`, and can be used
like this:

`packer build -var-file=beta-vars.json mint-build.json`
`packer build -var-file=mint-beta.pkrvars.hcl -only "*.mint" .`

Packer allows further overrides, with precedence given to the last option in the
command. For example, to build a beta image on Windows, use this command:

`packer build -var-file=beta-vars.json -var 'audio=dsound' mint-build.json`
`packer build -var-file=mint-beta.pkrvars.hcl -var 'audio=dsound' -only "*.mint" .`

### Building Ubuntu images

Native support is available for creating an Ubuntu variant of the image (and in
fact, all previous commands have specifically excluded Ubuntu image builds). By
default, the `packer` configuration will build both a Mint and Ubuntu VM. Try it
with:

`packer build .`

Much as with the previous commands, you can build only an ubuntu-based image by
running:

`packer build -only "*.ubuntu" .`

Support for building beta variants of Ubuntu images is not currently supported.

## Contributing

Expand Down
10 changes: 0 additions & 10 deletions packer/beta-vars.json

This file was deleted.

123 changes: 123 additions & 0 deletions packer/main.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
packer {
required_version = ">= 1.7.0"
}

source "virtualbox-iso" "base-build" {
cpus = 2
memory = 4096
disk_size = 20480
guest_os_type = "Ubuntu_64"
gfx_vram_size = 64

format = "ova"
gfx_controller = "vmsvga"
gfx_accelerate_3d = true
hard_drive_discard = true
hard_drive_interface = "sata"
hard_drive_nonrotational = true
headless = "${var.headless}"
http_directory = "http"
iso_interface = "sata"
rtc_time_base = "UTC"
sata_port_count = 2
sound = "${var.audio}"
ssh_username = "${var.ssh_user}"
ssh_password = "${var.ssh_pass}"
ssh_timeout = "100m"

boot_wait = "5s"
boot_command = [
"<esc><wait><esc><wait><esc><wait>",
"c<wait>",
"linux /casper/vmlinuz fsck.mode=skip<wait> noprompt",
" auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg",
" automatic-ubiquity debug-ubiquity keymap=us<enter>",
# Different distributions name (and compress) the initrd differently. Fortunately,
# GRUB is mostly smart and if the file doesn't exist, it just won't apply that directive.
# So to prevent duplication, we specify both and let GRUB ignore the wrong one.
"initrd /casper/initrd<enter><wait>",
"initrd /casper/initrd.lz<enter><wait>",
"boot<enter>"
]
shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff"

vboxmanage = [
["modifyvm", "{{ .Name }}", "--audioin", "off"],
["modifyvm", "{{ .Name }}", "--clipboard-mode", "bidirectional"],
["modifyvm", "{{ .Name }}", "--mouse", "usbtablet"],
["modifyvm", "{{ .Name }}", "--pae", "on"],
["modifyvm", "{{ .Name }}", "--usb", "on", "--usbehci", "off", "--usbxhci", "off"],
["modifyvm", "{{ .Name }}", "--vrde", "off"],
["storagectl", "{{ .Name }}", "--name", "IDE Controller", "--remove"],
["storagectl", "{{ .Name }}", "--name", "SATA Controller", "--hostiocache", "on"]
]
vboxmanage_post = [
["storageattach", "{{ .Name }}", "--storagectl", "SATA Controller", "--port", "1", "--type", "dvddrive", "--medium", "emptydrive"]
]
}

build {
source "source.virtualbox-iso.base-build" {
name = "mint"
vm_name = "${var.vm_name} Linux Mint ${var.semester}"
iso_url = "${local.mint_info.mirror_url}/${local.mint_info.iso_file}"
iso_checksum = "file:${local.mint_info.mirror_url}/sha256sum.txt"
output_filename = "image-${lower(var.semester)}-mint"
output_directory = "${local.artifact_dir_prefix}mint"
export_opts = [
"--manifest",
"--vsys", "0",
"--description", "Build date: ${local.build_id}\nPacker version: ${packer.version}",
"--product", "${var.vm_name} Linux Mint ${var.semester}",
"--producturl", "https://linuxmint.com/",
"--vendor", "JMU Unix Users Group",
"--vendorurl", "${var.git_repo}",
"--version", "${var.mint_version.version}"
]
}

source "source.virtualbox-iso.base-build" {
name = "ubuntu"
vm_name = "${var.vm_name} Ubuntu ${var.semester}"
iso_url = "${local.ubuntu_info.mirror_url}/${local.ubuntu_info.iso_file}"
iso_checksum = "file:${local.ubuntu_info.mirror_url}/SHA256SUMS"
output_filename = "image-${lower(var.semester)}-ubuntu"
output_directory = "${local.artifact_dir_prefix}ubuntu"
export_opts = [
"--manifest",
"--vsys", "0",
"--description", "Build date: ${local.build_id}\nPacker version: ${packer.version}",
"--product", "${var.vm_name} Ubuntu ${var.semester}",
"--producturl", "https://ubuntu.com/",
"--vendor", "JMU Unix Users Group",
"--vendorurl", "${var.git_repo}",
"--version", "${var.ubuntu_version.version}"
]
}

provisioner "shell" {
execute_command = "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
environment_vars = [
"DEBIAN_FRONTEND=noninteractive"
]
inline = [
"echo STOPPING APT",
"systemctl stop unattended-upgrades.service || true",
"while(pgrep -a apt-get); do sleep 1; done",
"echo UPDATE",
"apt-get update",
"echo INSTALL",
"apt-get install -V -y git ansible aptitude",
"git clone -b ${var.git_branch} ${var.git_repo}",
"cd /home/oem/cs-vm-build/scripts",
"./oem-build",
"/usr/sbin/oem-config-prepare"
]
}

post-processor "checksum" {
checksum_types = ["sha256"]
keep_input_artifact = true
output = "${local.artifact_dir_prefix}${source.name}/image-${lower(var.semester)}-${source.name}.{{ .ChecksumType }}sum"
}
}
7 changes: 7 additions & 0 deletions packer/mint-beta.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
semester = "Fa22"

mint_version = {
version = "21"
name = "vanessa"
beta = true
}
119 changes: 0 additions & 119 deletions packer/mint-build.json

This file was deleted.

Loading