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
|
|
|
]
|
|
|
|
|
2025-01-24 23:32:24 +01:00
|
|
|
# Upload artifacts
|
2023-09-01 20:13:47 +02:00
|
|
|
provisioner "file" {
|
2025-01-24 23:32:24 +01:00
|
|
|
destination = "/tmp/"
|
2024-10-06 23:01:39 +02:00
|
|
|
sources = [
|
2025-01-24 23:32:24 +01:00
|
|
|
"${path.cwd}/packer/src/",
|
|
|
|
"${path.cwd}/packer/init.sh",
|
|
|
|
"${path.cwd}/packer/clean.sh",
|
|
|
|
"${path.cwd}/../.pkg/",
|
2024-10-06 23:01:39 +02:00
|
|
|
]
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
2025-01-24 23:32:24 +01:00
|
|
|
# Full system provisioning
|
2023-09-01 20:13:47 +02:00
|
|
|
provisioner "shell" {
|
|
|
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
|
|
inline = [
|
2025-01-24 23:32:24 +01:00
|
|
|
# Wait for cloud-init to finish
|
2023-09-01 20:13:47 +02:00
|
|
|
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for Cloud-Init...'; sleep 20; done",
|
|
|
|
|
2025-01-24 23:32:24 +01:00
|
|
|
# Ensure cloud-init is successful
|
|
|
|
"cloud-init status",
|
2023-09-01 20:13:47 +02:00
|
|
|
|
2025-01-24 23:32:24 +01:00
|
|
|
# Remove logs and artifacts so cloud-init can re-run
|
|
|
|
"cloud-init clean",
|
|
|
|
|
|
|
|
# Install local files and config
|
|
|
|
"bash /tmp/init.sh",
|
|
|
|
|
|
|
|
# Minimize the image
|
|
|
|
"bash /tmp/clean.sh",
|
|
|
|
]
|
2023-09-01 20:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|