mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-12-25 06:27:49 +01:00
test: improve vm image generation
This commit is contained in:
parent
b4311dac65
commit
3393d8f649
9 changed files with 47 additions and 8 deletions
|
@ -21,7 +21,7 @@ $(PACKERS):
|
||||||
make --directory=../ package dist=${@}
|
make --directory=../ package dist=${@}
|
||||||
packer build -force -var version=${VERSION} \
|
packer build -force -var version=${VERSION} \
|
||||||
-var disk_size=${disk} -var flavor="${flavor}" \
|
-var disk_size=${disk} -var flavor="${flavor}" \
|
||||||
-only=main.qemu.${@}-${flavor} packer/
|
-only=qemu.${@}-${flavor} packer/
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@packer fmt packer/
|
@packer fmt packer/
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#cloud-config
|
#cloud-config
|
||||||
|
|
||||||
hostname: ${hostname}
|
hostname: ${hostname}
|
||||||
|
locale: en_IE
|
||||||
|
keyboard:
|
||||||
|
layout: ie
|
||||||
|
|
||||||
ssh_pwauth: true
|
ssh_pwauth: true
|
||||||
users:
|
users:
|
||||||
|
@ -45,6 +48,7 @@ packages:
|
||||||
|
|
||||||
# Install Applications
|
# Install Applications
|
||||||
- firefox
|
- firefox
|
||||||
|
- chromium
|
||||||
- terminator
|
- terminator
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#cloud-config
|
#cloud-config
|
||||||
|
|
||||||
hostname: ${hostname}
|
hostname: ${hostname}
|
||||||
|
locale: en_IE
|
||||||
|
keyboard:
|
||||||
|
layout: ie
|
||||||
|
|
||||||
ssh_pwauth: true
|
ssh_pwauth: true
|
||||||
users:
|
users:
|
||||||
|
@ -38,14 +41,14 @@ packages:
|
||||||
- networkmanager
|
- networkmanager
|
||||||
|
|
||||||
# Install Graphical Interface
|
# Install Graphical Interface
|
||||||
- xorg-server
|
- plasma-meta
|
||||||
- plasma
|
- plasma-wayland-session
|
||||||
- sddm
|
- sddm
|
||||||
- konsole
|
- konsole
|
||||||
- kde-applications
|
|
||||||
|
|
||||||
# Install Applications
|
# Install Applications
|
||||||
- firefox
|
- firefox
|
||||||
|
- chromium
|
||||||
- terminator
|
- terminator
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
|
|
|
@ -61,7 +61,9 @@ clean_arch() {
|
||||||
_msg "Pacman clean configuration"
|
_msg "Pacman clean configuration"
|
||||||
|
|
||||||
pacman -Syu --noconfirm
|
pacman -Syu --noconfirm
|
||||||
pacman -Rsccn --noconfirm "$(pacman -Qdtq)"
|
pacman -Qdtq | while IFS='' read -r pkg; do
|
||||||
|
pacman -Rsccn --noconfirm "$pkg"
|
||||||
|
done
|
||||||
pacman -Scc --noconfirm
|
pacman -Scc --noconfirm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ readonly DISTRIBUTION
|
||||||
main() {
|
main() {
|
||||||
install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/.config/"
|
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/.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 -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/parser.conf /etc/apparmor/parser.conf
|
||||||
install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local
|
install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/multiarch.d/site.local
|
||||||
|
@ -28,7 +29,7 @@ main() {
|
||||||
debian | ubuntu)
|
debian | ubuntu)
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y apparmor-profiles build-essential config-package-dev \
|
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
|
dpkg -i $SRC/apparmor.d_*_all.deb
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#cloud-config
|
#cloud-config
|
||||||
|
|
||||||
hostname: ${hostname}
|
hostname: ${hostname}
|
||||||
|
locale: en_IE
|
||||||
|
keyboard:
|
||||||
|
layout: ie
|
||||||
|
|
||||||
ssh_pwauth: true
|
ssh_pwauth: true
|
||||||
users:
|
users:
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
build {
|
build {
|
||||||
name = "main"
|
|
||||||
sources = [
|
sources = [
|
||||||
"source.qemu.archlinux-gnome",
|
"source.qemu.archlinux-gnome",
|
||||||
"source.qemu.archlinux-kde",
|
"source.qemu.archlinux-kde",
|
||||||
|
@ -12,6 +11,7 @@ build {
|
||||||
"source.qemu.ubuntu-server",
|
"source.qemu.ubuntu-server",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Upload local files
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
destination = "/tmp"
|
destination = "/tmp"
|
||||||
sources = ["${path.cwd}/packer/src"]
|
sources = ["${path.cwd}/packer/src"]
|
||||||
|
@ -29,6 +29,7 @@ build {
|
||||||
sources = ["${path.cwd}/../apparmor.d_${var.version}_all.deb"]
|
sources = ["${path.cwd}/../apparmor.d_${var.version}_all.deb"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wait for cloud-init to finish
|
||||||
provisioner "shell" {
|
provisioner "shell" {
|
||||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||||
inline = [
|
inline = [
|
||||||
|
@ -37,11 +38,13 @@ build {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install local files and config
|
||||||
provisioner "shell" {
|
provisioner "shell" {
|
||||||
script = "${path.cwd}/packer/init/init.sh"
|
script = "${path.cwd}/packer/init/init.sh"
|
||||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Minimize the image
|
||||||
provisioner "shell" {
|
provisioner "shell" {
|
||||||
script = "${path.cwd}/packer/init/clean.sh"
|
script = "${path.cwd}/packer/init/clean.sh"
|
||||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||||
|
|
23
tests/packer/src/monitors.xml
Normal file
23
tests/packer/src/monitors.xml
Normal 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>
|
|
@ -22,7 +22,7 @@ source "qemu" "ubuntu-server" {
|
||||||
output_directory = "${var.output}/"
|
output_directory = "${var.output}/"
|
||||||
vm_name = "${var.prefix}${source.name}.qcow2"
|
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||||
boot_wait = "10s"
|
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"
|
shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now"
|
||||||
cd_label = "cidata"
|
cd_label = "cidata"
|
||||||
cd_content = {
|
cd_content = {
|
||||||
|
|
Loading…
Reference in a new issue