test: improve vm image generation

This commit is contained in:
Alexandre Pujol 2023-07-18 22:22:08 +01:00
parent b4311dac65
commit 3393d8f649
Failed to generate hash of commit
9 changed files with 47 additions and 8 deletions

View file

@ -21,7 +21,7 @@ $(PACKERS):
make --directory=../ package dist=${@}
packer build -force -var version=${VERSION} \
-var disk_size=${disk} -var flavor="${flavor}" \
-only=main.qemu.${@}-${flavor} packer/
-only=qemu.${@}-${flavor} packer/
lint:
@packer fmt packer/

View file

@ -1,6 +1,9 @@
#cloud-config
hostname: ${hostname}
locale: en_IE
keyboard:
layout: ie
ssh_pwauth: true
users:
@ -45,6 +48,7 @@ packages:
# Install Applications
- firefox
- chromium
- terminator
runcmd:

View file

@ -1,6 +1,9 @@
#cloud-config
hostname: ${hostname}
locale: en_IE
keyboard:
layout: ie
ssh_pwauth: true
users:
@ -38,14 +41,14 @@ packages:
- networkmanager
# Install Graphical Interface
- xorg-server
- plasma
- plasma-meta
- plasma-wayland-session
- sddm
- konsole
- kde-applications
# Install Applications
- firefox
- chromium
- terminator
runcmd:

View file

@ -61,7 +61,9 @@ clean_arch() {
_msg "Pacman clean configuration"
pacman -Syu --noconfirm
pacman -Rsccn --noconfirm "$(pacman -Qdtq)"
pacman -Qdtq | while IFS='' read -r pkg; do
pacman -Rsccn --noconfirm "$pkg"
done
pacman -Scc --noconfirm
}

View file

@ -17,6 +17,7 @@ readonly DISTRIBUTION
main() {
install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/.config/"
install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/.bash_aliases "/home/$SUDO_USER/.bash_aliases"
install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/monitors.xml "/home/$SUDO_USER/.config/monitors.xml"
install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/htoprc "/home/$SUDO_USER/.config/htop/htoprc"
install -Dm0644 $SRC/parser.conf /etc/apparmor/parser.conf
install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local
@ -28,7 +29,7 @@ main() {
debian | ubuntu)
apt-get update -y
apt-get install -y apparmor-profiles build-essential config-package-dev \
debhelper devscripts htop qemu-guest-agent rsync vim
debhelper devscripts htop rsync vim
dpkg -i $SRC/apparmor.d_*_all.deb
;;

View file

@ -1,6 +1,9 @@
#cloud-config
hostname: ${hostname}
locale: en_IE
keyboard:
layout: ie
ssh_pwauth: true
users:

View file

@ -3,7 +3,6 @@
# SPDX-License-Identifier: GPL-2.0-only
build {
name = "main"
sources = [
"source.qemu.archlinux-gnome",
"source.qemu.archlinux-kde",
@ -12,6 +11,7 @@ build {
"source.qemu.ubuntu-server",
]
# Upload local files
provisioner "file" {
destination = "/tmp"
sources = ["${path.cwd}/packer/src"]
@ -29,6 +29,7 @@ build {
sources = ["${path.cwd}/../apparmor.d_${var.version}_all.deb"]
}
# Wait for cloud-init to finish
provisioner "shell" {
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
inline = [
@ -37,11 +38,13 @@ build {
]
}
# 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 }}'"

View file

@ -0,0 +1,23 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<scale>1</scale>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>Virtual-1</connector>
<vendor>RHT</vendor>
<product>QEMU Monitor</product>
<serial>0x00000000</serial>
</monitorspec>
<mode>
<width>1920</width>
<height>1080</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View file

@ -22,7 +22,7 @@ source "qemu" "ubuntu-server" {
output_directory = "${var.output}/"
vm_name = "${var.prefix}${source.name}.qcow2"
boot_wait = "10s"
firmware = "/usr/share/edk2-ovmf/x64/OVMF_CODE.fd"
firmware = "${var.firmware}"
shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now"
cd_label = "cidata"
cd_content = {