Skip to content
Closed
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
65 changes: 53 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -440,33 +440,74 @@ bin/virtdeploy: tools/cmd/virtdeploy/* tools/go.sum tools/pkg/* tools/pkg/virtde
INSTALLER_OUT_DIR := bin
INSTALLER_DIR := tools/installer

# If necessary create End-User License Agreement example file in execution directory
bin/EULA.txt:
@mkdir -p bin
@echo "SAMPLE EULA" > $@

# EULA.txt required at runtime; added to ensure binary will be able to run
bin/liveinstaller: \
$(shell find $(INSTALLER_DIR)/ -type f) \
$(INSTALLER_DIR)/go.sum \
bin/EULA.txt
$(INSTALLER_DIR)/go.sum
@mkdir -p bin
cd $(INSTALLER_DIR)/liveinstaller && \
CGO_ENABLED=0 go build -o $(CURDIR)/$(INSTALLER_OUT_DIR)/liveinstaller

# EULA.txt required at runtime; added to ensure binary will be able to run
bin/attendedinstaller-simulator: \
$(shell find $(INSTALLER_DIR)/imagegen/ -type f) \
$(INSTALLER_DIR)/go.sum \
bin/EULA.txt
$(INSTALLER_DIR)/go.sum
@mkdir -p bin
cd $(INSTALLER_DIR)/imagegen/attendedinstaller/attendedinstaller_tests && \
CGO_ENABLED=0 go build -o $(CURDIR)/$(INSTALLER_OUT_DIR)/attendedinstaller-simulator attendedinstaller_simulator.go

.PHONY: run-attendedinstaller-simulator
run-attendedinstaller-simulator: bin/attendedinstaller-simulator bin/EULA.txt
run-attendedinstaller-simulator: bin/attendedinstaller-simulator
@cd bin && ./attendedinstaller-simulator && cd -

# AZL INSTALLER IMAGES

artifacts/test-image/azl-installer-mos.vhdx: \
artifacts/baremetal.vhdx \
bin/trident-rpms-azl3.tar.gz \
tests/images/azl-installer/mos/mos.yaml \
artifacts/imagecustomizer \
$(shell find tests/images/azl-installer/mos/ -type f 2>/dev/null)
@mkdir -p artifacts/test-image/
sudo rm -rf bin/trident_rpms
mkdir -p bin/trident_rpms
$(eval TEMP_DIR := $(shell mktemp -d))
tar -xf bin/trident-rpms-azl3.tar.gz -C $(TEMP_DIR)
cp $(TEMP_DIR)/RPMS/*/*.rpm bin/trident_rpms/
rm -rf $(TEMP_DIR)
Comment on lines +472 to +475
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary directory cleanup should happen even if the previous commands fail. Consider using a trap or ensure this cleanup occurs in all code paths to prevent temporary directory accumulation.

Suggested change
$(eval TEMP_DIR := $(shell mktemp -d))
tar -xf bin/trident-rpms-azl3.tar.gz -C $(TEMP_DIR)
cp $(TEMP_DIR)/RPMS/*/*.rpm bin/trident_rpms/
rm -rf $(TEMP_DIR)
@TEMP_DIR=$$(mktemp -d) ; \
trap 'rm -rf "$$TEMP_DIR"' EXIT ; \
tar -xf bin/trident-rpms-azl3.tar.gz -C "$$TEMP_DIR" && \
cp "$$TEMP_DIR"/RPMS/*/*.rpm bin/trident_rpms/

Copilot uses AI. Check for mistakes.
Comment on lines +469 to +475
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to manually unpack bin/trident-rpms-azl3.tar.gz? I think the make target for this already places the RPMs at /bin/RPMS so we can just copy those over to bin/trident_rpms/?


sudo ./artifacts/imagecustomizer \
--log-level debug \
--rpm-source ./bin/trident_rpms/ \
--build-dir ./artifacts/test-image \
--image-file $< \
--output-image-file $@ \
--output-image-format vhdx \
--config-file tests/images/azl-installer/mos/mos.yaml

AZL_INSTALLER_IMAGES_PATH = tests/images/azl-installer/iso/images
AZL_INSTALLER_BIN_PATH = tests/images/azl-installer/iso/bin
artifacts/test-image/azl-installer.iso: \
artifacts/test-image/azl-installer-mos.vhdx \
artifacts/imagecustomizer \
bin/liveinstaller \
artifacts/test-image/regular.cosi \
$(shell find tests/images/azl-installer/iso/ -type f 2>/dev/null)
# Copy runtime images to prepare for inclusion in the ISO
rm -rf $(AZL_INSTALLER_IMAGES_PATH)
mkdir -p $(AZL_INSTALLER_IMAGES_PATH)
cp artifacts/test-image/regular.cosi $(AZL_INSTALLER_IMAGES_PATH)/trident-testimage.cosi
rm -rf $(AZL_INSTALLER_BIN_PATH)
mkdir -p $(AZL_INSTALLER_BIN_PATH)
cp bin/liveinstaller $(AZL_INSTALLER_BIN_PATH)/

mkdir -p artifacts/test-image/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ./artifacts/test-image/

sudo ./artifacts/imagecustomizer \
--log-level debug \
--build-dir ./artifacts/test-image/ \
--image-file $< \
--output-image-file $@ \
--config-file tests/images/azl-installer/iso/mos-iso.yaml \
--output-image-format iso

.PHONY: validate
validate: $(TRIDENT_CONFIG) bin/trident
@bin/trident validate $(TRIDENT_CONFIG)
Expand Down
2 changes: 2 additions & 0 deletions tests/images/azl-installer/iso/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/images/
/bin/
23 changes: 23 additions & 0 deletions tests/images/azl-installer/iso/mos-iso.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
os:
additionalFiles:
- source: scripts/installation.sh
destination: /root/installer/installation.sh

iso:
initramfsType: full-os
additionalFiles:
- source: images/trident-testimage.cosi
destination: /images/azure-linux-core.cosi
- source: bin/liveinstaller
destination: /installer/liveinstaller

kernelCommandLine:
extraCommandLine:
- console=tty0
- console=tty1
- console=ttyS0
- loglevel=6

scripts:
postCustomization:
- path: scripts/startup-command.sh
24 changes: 24 additions & 0 deletions tests/images/azl-installer/iso/scripts/installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -ex
trap '/bin/bash' ERR

# Mount CD-ROM using symlink
mkdir -p /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

LIVEINSTALLER_PATH="/mnt/cdrom/installer/liveinstaller"
IMAGES_DIR="/mnt/cdrom/images/"
TRIDENT_CONFIG="/etc/trident/config.yaml"
WORKING_DIR="/root/installer"

# Copy to execute liveinstaller
cp "$LIVEINSTALLER_PATH" "$WORKING_DIR"

cd "$WORKING_DIR"
"$WORKING_DIR/liveinstaller" \
--images-dir=$IMAGES_DIR \
--host-config-output=$TRIDENT_CONFIG \
--log-level=trace \
--log-file=$WORKING_DIR/liveinstaller.log 2>&1 | tee "$WORKING_DIR/output_liveinstaller.log"

/bin/bash
5 changes: 5 additions & 0 deletions tests/images/azl-installer/iso/scripts/startup-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
INSTALLATION="/root/installer/installation.sh"
chmod +x "$INSTALLATION"

chsh -s "$INSTALLATION" root
58 changes: 58 additions & 0 deletions tests/images/azl-installer/mos/files/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by [email protected], not this
# unit.
ConditionPathExists=/dev/tty0

[Service]
# the VT is cleared by TTYVTDisallocate
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty --autologin root --noclear %I linux
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION

[Install]
WantedBy=getty.target
DefaultInstance=tty1
46 changes: 46 additions & 0 deletions tests/images/azl-installer/mos/files/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

[Service]
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I screen
Type=idle
Restart=always
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

[Install]
WantedBy=getty.target
81 changes: 81 additions & 0 deletions tests/images/azl-installer/mos/mos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
storage:
bootType: efi

disks:
- partitionTableType: gpt
maxSize: 4G
partitions:
- id: esp
type: esp
size: 8M

- id: rootfs
size: grow

filesystems:
- deviceId: esp
type: fat32
mountPoint:
path: /boot/efi
options: umask=0077

- deviceId: rootfs
type: ext4
mountPoint:
path: /

os:
hostname: azl-installer-mos
bootloader:
resetType: hard-reset

selinux:
mode: disabled

kernelCommandLine:
# Replicates BM base image settings, that would otherwise be lost
extraCommandLine:
- console=tty0
- console=ttyS0
- rd.info
- log_buf_len=1M

packages:
install:
- calamares
- curl
- device-mapper
- dnf
- dosfstools
- efibootmgr
- iproute
- iptables
- jq
- lsof
- mdadm
- nano
- netplan
- openssh-server
- squashfs-tools
- tar
- tpm2-tools
- trident-provisioning
- vim
- veritysetup
# Accessibility packages
- pcaudiolib
# Debug accessibility packages.
# Successfully installed, but failed to create ISO.
# - alsa-lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these packages intentionally commented out?

# - alsa-utils
# - espeak-ng
# - espeakup
# - kernel-drivers-accessibility
# - kernel-drivers-sound

additionalFiles:
# Getty service files for root autologin
- source: files/[email protected]
destination: /usr/lib/systemd/system/[email protected]
- source: files/[email protected]
destination: /usr/lib/systemd/system/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"installer/imagegen/attendedinstaller/views"
"installer/imagegen/attendedinstaller/views/confirmview"
"installer/imagegen/attendedinstaller/views/diskview"
"installer/imagegen/attendedinstaller/views/eulaview"
"installer/imagegen/attendedinstaller/views/hostnameview"
"installer/imagegen/attendedinstaller/views/imageselectorview"
"installer/imagegen/attendedinstaller/views/installerview"
Expand Down Expand Up @@ -369,7 +368,10 @@ func (ai *AttendedInstaller) initializeViews() (err error) {
ai.allViews = append(ai.allViews, installerView)
}

ai.allViews = append(ai.allViews, eulaview.New())
// EULA view is disabled for now, as the EULA is not yet available.
// The ISO installer is not currently intended for redistribution outside of the
// Trident repository, which is covered by the MIT open source license.
// ai.allViews = append(ai.allViews, eulaview.New())

imageselectorView := imageselectorview.New(ai.availableImages, ai.hostConfigData)
if imageselectorView.NeedsToPrompt() {
Expand Down
Loading