2023-09-01 20:13:47 +02:00
|
|
|
# apparmor.d - Full set of apparmor profiles
|
2024-02-07 00:16:21 +01:00
|
|
|
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
|
2023-09-01 20:13:47 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
build {
|
|
|
|
sources = [
|
2024-10-06 23:01:39 +02:00
|
|
|
"source.qemu.archlinux",
|
|
|
|
"source.qemu.debian",
|
|
|
|
"source.qemu.fedora",
|
|
|
|
"source.qemu.opensuse",
|
|
|
|
"source.qemu.ubuntu22",
|
|
|
|
"source.qemu.ubuntu24",
|
2023-09-01 20:13:47 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
# Upload local files
|
|
|
|
provisioner "file" {
|
|
|
|
destination = "/tmp"
|
|
|
|
sources = ["${path.cwd}/packer/src"]
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2024-10-06 23:01:39 +02:00
|
|
|
only = ["qemu.archlinux"]
|
2023-09-01 20:13:47 +02:00
|
|
|
destination = "/tmp/src/"
|
2024-10-06 23:01:39 +02:00
|
|
|
sources = [
|
2024-10-07 15:05:40 +02:00
|
|
|
"${path.cwd}/../.pkg/apparmor.d-${var.version}-1-x86_64.pkg.tar.zst",
|
2024-10-06 23:01:39 +02:00
|
|
|
]
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2024-10-06 23:01:39 +02:00
|
|
|
only = ["qemu.opensuse"]
|
2023-09-01 20:13:47 +02:00
|
|
|
destination = "/tmp/src/"
|
2024-10-17 00:58:48 +02:00
|
|
|
sources = ["${path.cwd}/../.pkg/apparmor.d-${var.version}-1.x86_64.rpm"]
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2024-10-06 23:01:39 +02:00
|
|
|
only = ["qemu.debian", "qemu.ubuntu22", "qemu.ubuntu24"]
|
2023-09-01 20:13:47 +02:00
|
|
|
destination = "/tmp/src/"
|
2024-10-17 00:58:48 +02:00
|
|
|
sources = ["${path.cwd}/../.pkg/apparmor.d_${var.version}-1_amd64.deb"]
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Wait for cloud-init to finish
|
|
|
|
provisioner "shell" {
|
|
|
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
|
|
inline = [
|
|
|
|
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for Cloud-Init...'; sleep 20; done",
|
|
|
|
"cloud-init clean", # Remove logs and artifacts so cloud-init can re-run
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install local files and config
|
|
|
|
provisioner "shell" {
|
|
|
|
script = "${path.cwd}/packer/init/init.sh"
|
|
|
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Minimize the image
|
|
|
|
provisioner "shell" {
|
|
|
|
script = "${path.cwd}/packer/init/clean.sh"
|
|
|
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
|
|
}
|
|
|
|
|
|
|
|
post-processor "vagrant" {
|
2024-10-07 15:05:40 +02:00
|
|
|
output = "${var.base_dir}/packer_${var.prefix}${source.name}-${var.flavor}.box"
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
post-processor "shell-local" {
|
|
|
|
inline = [
|
2024-10-07 15:05:40 +02:00
|
|
|
"vagrant box add --force --name ${var.prefix}${source.name}-${var.flavor} ${var.base_dir}/packer_${var.prefix}${source.name}-${var.flavor}.box"
|
2023-09-01 20:13:47 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|