### Virt-install Command for OVMF Guest Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Example command to install an OVMF guest using virt-install. It specifies memory, vCPUs, OS variant, boot options including the OVMF loader, and disk configurations. ```bash LDR="loader=/usr/share/OVMF/OVMF_CODE.fd,loader_ro=yes,loader_type=pflash" virt-install \ --name fedora20 \ --memory 2048 \ --vcpus 2 \ --os-variant fedora20 \ --boot hd,cdrom,$LDR \ --disk size=20 \ --disk path=Fedora-Live-Xfce-x86_64-20-1.iso,device=cdrom,bus=scsi ``` -------------------------------- ### Mock Environment Setup and Build Commands Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/pyproject-rpm-macros/README.md Commands to clean a mock environment, install a specific version of python-rpm-macros, download sources, build an SRPM, and build within mock. ```bash mock -r fedora-rawhide-x86_64 clean ``` ```bash mock -r fedora-rawhide-x86_64 install .../python-rpm-macros-*.noarch.rpm ``` ```bash spectool -g $PKG.spec ``` ```bash rpmbuild -bs --define '_sourcedir .' $PKG.spec ``` ```bash mock -r fedora-rawhide-x86_64 -n -N $SRPM ``` -------------------------------- ### Install azldev CLI Tool Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md Installs the 'azldev' CLI tool from source. Ensure Go is installed and the .azldev-version file exists. ```bash go install "github.com/microsoft/azure-linux-dev-tools/cmd/azldev@$(cat .azldev-version)" ``` -------------------------------- ### Install and Configure Spec Review Dependencies Source: https://github.com/microsoft/azurelinux/blob/4.0/scripts/ci/spec-review/README.md Sets up a Python virtual environment, installs necessary Python packages, and verifies the Copilot CLI installation. Ensure you have a GitHub token configured. ```bash cd ~/repos/azurelinux python -m venv .venv && source .venv/bin/activate pip install -r scripts/ci/spec-review/requirements.txt gh copilot # OR npm install -g @github/copilot> copilot --version # verify CLI ``` -------------------------------- ### Start and Enable MUNGE Service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/m/munge/README.md Use systemctl commands to start the munge service and ensure it is enabled to run on boot. ```bash systemctl start munge ``` ```bash systemctl enable munge ``` -------------------------------- ### Boot Installed System with QEMU/KVM Source: https://github.com/microsoft/azurelinux/blob/4.0/docs/iso-installer-in-local-vm.md Boots the installed Azure Linux system from the virtual disk using QEMU/KVM, without the ISO. This command configures the VM with similar hardware settings as the installer but uses the virtual disk as the primary boot device. ```bash qemu-system-x86_64 \ -name azl4 \ -machine q35,accel=kvm \ -cpu host \ -smp 2 \ -m 4096 \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/ovmf/OVMF_CODE.fd \ -drive if=pflash,format=raw,file=./azl4_VARS.fd \ -device virtio-blk-pci,drive=disk0 \ -drive id=disk0,if=none,file=azl4.qcow2,format=qcow2 \ -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \ -nographic \ -serial mon:stdio ``` -------------------------------- ### Example OpenFirmware Device Paths Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt These are examples of OpenFirmware (OFW) device paths as read from QEMU's 'bootorder' fw_cfg file. They are used to filter and reorder UEFI boot options. ```text /pci@i0cf8/scsi@4/disk@0,0 ``` ```text /pci@i0cf8/ide@1,1/drive@1/disk@0 ``` ```text /pci@i0cf8/ethernet@3/ethernet-phy@0 ``` -------------------------------- ### Test Template with Setup and Teardown Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/r/rubygem-test-unit-notify/readme.html This template demonstrates the basic structure of a test file using Test-Unit-Notify. It includes functions for setup and teardown, which are executed before and after each test, respectively. ```c #include #include "HEADER_FILE_OF_YOUR_PROGRAM" void test_condition(void); void test_strstr(void); static int condition = 0; void cut_setup (void) { condition = 1; } void cut_teardown (void) { condition = 0; } void test_condition(void) { cut_set_message("The condition value should be set to 1 in cut_setup()"); cut_assert_equal_int(1, condition); ... ``` -------------------------------- ### IDE CD-ROM Configuration for Installer Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Configures an IDE CD-ROM for an installer image, setting it as the second boot option. This allows booting from installation media. ```bash OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly" OPTS="$OPTS,file=Fedora-Live-Xfce-x86_64-20-1.iso" OPTS="$OPTS -device ide-cd,bus=ide.1,drive=cd0,bootindex=1" ``` -------------------------------- ### URL Dependency Specification Examples Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/pyproject-rpm-macros/README.md Examples of how dependency URLs are specified and how they are converted to RPM requirements without version constraints. ```text https://github.com/ActiveState/appdirs/archive/8eacfa312d77aba28d483fbfb6f6fc54099622be.zip /some/path/foo-1.2.3.tar.gz git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3 ``` ```text appdirs@https://github.com/ActiveState/appdirs/archive/8eacfa312d77aba28d483fbfb6f6fc54099622be.zip foo@file:///some/path/foo-1.2.3.tar.gz ``` ```text python3dist(appdirs) python3dist(foo) ``` ```text git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3#egg=sphinx ``` ```text python3dist(sphinx) ``` -------------------------------- ### Install Wheel Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/pyproject-rpm-macros/README.md Use the %pyproject_install macro in the %install section to install the built wheel. This macro installs all wheels into pyproject-wheeldir/. ```rpm %install %pyproject_install ``` -------------------------------- ### Temporary Directory Example Source: https://github.com/microsoft/azurelinux/blob/4.0/AGENTS.md Example of how to structure temporary directories within the project's work directory to avoid permission issues and keep files organized. ```bash workDir="/home/user/azurelinux/base/build/work" use "./base/build/work/scratch/" for all temp dirs, or a subdir like "./base/build/work/scratch/thing" ``` -------------------------------- ### Enable and Start saslauthd Service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/postfix/README-Postfix-SASL-RedHat.txt Ensure the saslauthd service is enabled to start on system boot and then start the service immediately. This daemon handles authentication requests on behalf of Postfix. ```bash /sbin/chkconfig --level 345 saslauthd on /sbin/service saslauthd start ``` -------------------------------- ### Build with Meson Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/l/libdrm/README.rst Use the Meson build system to configure, build, and install libdrm. Specify the installation prefix with --prefix or via `meson configure`. ```bash meson builddir/ ninja -C builddir/ install ``` -------------------------------- ### Copilot CLI Agent URL Input Example Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md An example of providing a Koji task URL to the 'azl-diagnose' agent for diagnosing build failures. ```markdown > https://koji.example.com/koji/taskinfo?taskID=1234 ``` -------------------------------- ### Copilot CLI Agent Prompt Example Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md An example of a natural language query to the 'azl-diagnose' agent for checking the status of a package. ```markdown > what is the status of the lolcat package ``` -------------------------------- ### Copilot CLI Prompt Example Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md An example of a natural language prompt for GitHub Copilot CLI to add a package with specific modifications. ```markdown > Add the cowsay package, but make it clippysay and make clippy the default ``` -------------------------------- ### Install Copilot CLI Plugin Locally Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md Install the Azure Linux Copilot plugin from a local clone for cross-repo access. This makes the repo's skills available from any working directory. ```bash copilot plugin install --plugin-dir /path/to/azurelinux ``` -------------------------------- ### Sed Command Examples Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt Demonstrates various sed commands for line deletion, pattern printing, and conditional substitution. ```bash $d # delete the last line of the file /[0-9]{3}/p # print lines with 3 consecutive digits 5!s/ham/cheese/ # except on line 5, replace 'ham' with 'cheese' /awk/!s/aaa/bb/ # unless 'awk' is found, replace 'aaa' with 'bb' 17,/foo/d # delete all lines from line 17 up to 'foo' ``` -------------------------------- ### Build with Autotools Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/l/libdrm/README.rst Use the legacy Autotools build system to configure, build, and install libdrm. Specify installation prefixes with --prefix and --exec-prefix. ```bash ./configure make make install ``` -------------------------------- ### Example kmod RPM Output Source: https://github.com/microsoft/azurelinux/blob/4.0/docs/oss-kmod-packaging-strategy.md Illustrates the typical RPM packages generated from a successful kernel build, highlighting the kmod subpackage. ```text kernel-6.18.5-1.8.azl4.x86_64.rpm kernel-core-6.18.5-1.8.azl4.x86_64.rpm kernel-modules-6.18.5-1.8.azl4.x86_64.rpm kmod-nvidia-open-595.58.03-6.18.5-1.8.azl4.x86_64.rpm ← kmod subpackage (driver 595.58.03) ``` -------------------------------- ### List Components Source: https://github.com/microsoft/azurelinux/blob/4.0/AGENTS.md Run this command before modifying a component to get a list of available components. ```bash azldev comp list -p -q -O json ``` -------------------------------- ### UEFI Shell Device Path Example Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt An example of a memory-mapped UEFI shell's device path. This path is noted as being inexpressible by QEMU's OFW device paths, illustrating limitations in the matching algorithm. ```text MemoryMapped(0xB,0x900000,0x10FFFFF)/ FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) ``` -------------------------------- ### Download Fedora LiveCD Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Downloads the Fedora LiveCD ISO image for installation. ```bash wget https://dl.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Xfce-x86_64-20-1.iso ``` -------------------------------- ### Example RPM Spec File for Tree-sitter TypeScript Parser Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/t/tree-sitter-srpm-macros/README.md An example RPM spec file demonstrating the usage of the 'tree_sitter' BuildSystem and the '%{tree_sitter -l ...}' macro for a TypeScript parser package. ```specfile Name: tree-sitter-typescript Version: 0.21.2 Release: %autorelease License: MIT URL: https://github.com/tree-sitter/%{name} Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz BuildSystem: tree_sitter %{tree_sitter -l %{quote:TypeScript and TSX}} %changelog %autochangelog ``` -------------------------------- ### Enable clamav-milter service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/c/clamav/README.fedora.md Enables the clamav-milter service to start on boot. ```bash systemctl enable clamav-milter.service ``` -------------------------------- ### Running SED on Macintosh (MPW Shell) Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt Example of piping 'echo' output to sed for substitution within the MPW Shell environment on Macintosh. ```shell echo aa | sed 's/a/Z/g' ``` -------------------------------- ### Relative Address Range Example Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt Matches lines starting from the line matched by '/RE/' up to the next _num_ lines. This requires GNU sed 3.02+, ssed, or sed15+. ```sed /RE/,+num ``` -------------------------------- ### Boot Azure Linux ISO with QEMU/KVM Source: https://github.com/microsoft/azurelinux/blob/4.0/docs/iso-installer-in-local-vm.md Launches a QEMU/KVM virtual machine to boot the Azure Linux ISO installer. This command configures the VM with specific hardware settings, storage, and network, attaching the terminal to the guest serial console. ```bash qemu-system-x86_64 \ -name azl4-live \ -machine q35,accel=kvm \ -cpu host \ -smp 2 \ -m 4096 \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/ovmf/OVMF_CODE.fd \ -drive if=pflash,format=raw,file=./azl4_VARS.fd \ -device virtio-blk-pci,drive=disk0,bootindex=0 \ -drive id=disk0,if=none,file=azl4.qcow2,format=qcow2 \ -device ide-cd,drive=cd0,bootindex=1 \ -drive id=cd0,if=none,file=azurelinux-4.0-x86_64.iso,media=cdrom,readonly=on \ -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \ -nographic \ -serial mon:stdio ``` -------------------------------- ### Sed: Change Block Content Conditionally Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt This example shows how to replace an entire block of text (between 'start' and 'end') with new content if a specific 'regex' is found within that block. It uses the 'c' command for changing the block. ```sed /regex/c\ 1: This will replace the entire block\ 2: with these two lines of text. ``` -------------------------------- ### QEMU Command-Line Options for OVMF Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Configure QEMU with options for monitor, USB tablet, and virtio-net devices for an OVMF guest. This setup is useful for testing network connectivity and basic VM functionality. ```bash OPTS="$OPTS -monitor stdio" OPTS="$OPTS -device piix3-usb-uhci -device usb-tablet" OPTS="$OPTS -netdev id=net0,type=user" OPTS="$OPTS -device virtio-net-pci,netdev=net0,romfile=" OPTS="$OPTS -device qxl-vga" qemu-system-x86_64 $OPTS ``` -------------------------------- ### Install MCP Python Packages Source: https://github.com/microsoft/azurelinux/blob/4.0/DEVELOPING.md Installs the required MCP Python packages for the 'azl-diagnose' agent and Koji-related tools. Installs packages for the current user. ```bash pip3 install --user -r scripts/mcps/requirements.txt ``` -------------------------------- ### Start clamav-milter service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/c/clamav/README.fedora.md Starts the clamav-milter service. This should be done after enabling it. ```bash systemctl start clamav-milter.service ``` -------------------------------- ### Start clamd@scan service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/c/clamav/README.fedora.md Starts the clamd@scan service. This should be done after enabling it. ```bash systemctl start clamd@scan.service ``` -------------------------------- ### Basic VM Configuration with OVMF Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Sets up a basic virtual machine with i440fx machine type, KVM acceleration, memory, and CPU count. This is a foundational configuration for running OVMF. ```bash OPTS="-M pc-i440fx-2.1 -enable-kvm -m 2048 -smp 2" ``` -------------------------------- ### Build and Test VM Base Image Source: https://github.com/microsoft/azurelinux/blob/4.0/base/images/tests/README.md Builds the VM base image and then runs tests against it using the azldev tool. ```bash azldev image build vm-base azldev image test vm-base ``` -------------------------------- ### Example Test Result Output Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/r/rubygem-test-unit-notify/readme.html An example of a test result output showing progress, failures, and a summary of test execution. ```text ..........F................................................. 1) Failure: test_test_case_count <1 == cut_test_case_get_n_tests(test_object, NULL)> expected: <1> but was: <0> test/test-cut-test-case.c:143: test_test_case_count() Finished in 0.020857 seconds 60 test(s), 253 assertion(s), 1 failure(s), 0 error(s), 0 pending(s), 0 notification(s) ``` -------------------------------- ### Architecture Guard Example Source: https://github.com/microsoft/azurelinux/blob/4.0/docs/oss-kmod-packaging-strategy.md Shows how to use architecture guards in RPM spec files to conditionally skip kmod build steps for unsupported architectures. ```spec %ifarch x86_64 aarch64 ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/microsoft/azurelinux/blob/4.0/CONTRIBUTING.md Examples demonstrating the use of different types and scopes within the Conventional Commits specification for commit messages. ```markdown feat(cowsay): add new component imported from Fedora ``` ```markdown fix(kernel): correct kmod-macros include path ``` ```markdown docs: clarify overlay description requirement ``` ```markdown ci: pin azldev runner image to a tagged release ``` -------------------------------- ### Create Virtual Disk Image Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Creates a 20 GB virtual disk image in qcow2 format for the virtual machine. ```bash qemu-img create -f qcow2 fedora.img 20G ``` -------------------------------- ### Pass Options to Declarative Buildsystem Macros Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/pyproject-rpm-macros/README.md Demonstrates how to pass options to individual macros within the declarative buildsystem using BuildOption. This allows customization of default behaviors for macros like %pyproject_save_files, %autosetup, %pyproject_buildrequires, %pyproject_wheel, and %pyproject_check_import. ```spec # pass options for %%pyproject_save_files (mandatory when not overriding %%install) BuildOption(install): -l _module +auto # replace the default options for %%autosetup BuildOption(prep): -S git_am -C # pass options to %%pyproject_buildrequires BuildOption(generate_buildrequires): docs-requirements.txt -t # pass options to %%pyproject_wheel BuildOption(build): -C--global-option=--no-cython-compile # pass options to %%pyproject_check_import BuildOption(check): -e '*.test*' ``` -------------------------------- ### Create Virtual Disk and UEFI Vars for QEMU Source: https://github.com/microsoft/azurelinux/blob/4.0/docs/iso-installer-in-local-vm.md Creates an empty virtual disk image and a private copy of the UEFI variable store required for QEMU/KVM installations. ```bash qemu-img create -f qcow2 azl4.qcow2 16G cp /usr/share/edk2/ovmf/OVMF_VARS.fd ./azl4_VARS.fd ``` -------------------------------- ### Conditional Execution for Range /RE/,30 in Sed Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt Execute commands on a range up to line 30, but only if the start pattern occurs on or before line 30. This prevents matching if the start pattern appears after line 30. ```sed 1,30{/RE/,$ your_commands;} ``` -------------------------------- ### Build and Test Container Base Image Source: https://github.com/microsoft/azurelinux/blob/4.0/base/images/tests/README.md Builds the container base image and then runs tests against it using the azldev tool. ```bash azldev image build container-base azldev image test container-base ``` -------------------------------- ### Print every 5th line starting from line 2 Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/s/sed/sedfaq.txt This command prints lines from a file at a specified interval. It starts printing from the second line and continues to print every fifth line thereafter. ```bash sed -n '2~5p' file ``` -------------------------------- ### Pass Configuration Settings to Build Backends Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/p/pyproject-rpm-macros/README.md Use the -C flag with %pyproject_buildrequires or %pyproject_wheel macros to pass configuration settings to the build backend. Options can be in the form of -C KEY, -C KEY=VALUE, or -C--option-with-dashes. ```shell %pyproject_buildrequires -C KEY=VALUE ``` ```shell %pyproject_wheel -C--option-with-dashes ``` -------------------------------- ### Short-form Hard Drive UEFI Device Path Example Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt Illustrates a relative UEFI device path for a hard drive, which can be matched against an absolute device path during boot option processing. ```text HD(1,GPT,14DD1CC5-D576-4BBF-8858-BAF877C8DF61,0x800,0x64000)/\EFI\fedora\shim.efi ``` -------------------------------- ### Enable clamd@scan service Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/c/clamav/README.fedora.md Enables the clamd@scan service to start on boot. ```bash systemctl enable clamd@scan.service ``` -------------------------------- ### Assembly: Transitioning to 64-bit Long Mode Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/e/edk2/ovmf-whitepaper-c770f8c.txt This assembly code demonstrates the steps involved in transitioning from 32-bit flat mode to 64-bit flat mode, including setting up page tables and enabling paging. ```assembly Transition32FlatTo64Flat [UefiCpuPkg/.../Ia32/Flat32ToFlat64.asm] SetCr3ForPageTables64 [OvmfPkg/ResetVector/Ia32/PageTables64.asm] ; dynamically build the initial page tables in RAM, at address ; PcdOvmfSecPageTablesBase (refer to the memory map above), ; identity-mapping the first 4 GB of address space ; set CR3 to PcdOvmfSecPageTablesBase ; enable PAE ; set LME ; enable paging ``` -------------------------------- ### Clone Cutter Repository Source: https://github.com/microsoft/azurelinux/blob/4.0/specs/r/rubygem-test-unit-notify/readme.html Clone the Cutter repository from GitHub to get the source code. ```bash % git clone https://github.com/clear-code/cutter.git ``` -------------------------------- ### Build Comps XML File Source: https://github.com/microsoft/azurelinux/blob/4.0/base/comps/README-comps-xml.md Builds the final comps.xml file from the edited and sorted comps-*.xml.in file. Replace 'f43' with the specific Fedora release number. ```bash $ make comps-f43.xml ```