diff --git a/.github/workflows/idv-iso-builder.yaml b/.github/workflows/idv-iso-builder.yaml new file mode 100644 index 0000000..117c01c --- /dev/null +++ b/.github/workflows/idv-iso-builder.yaml @@ -0,0 +1,55 @@ +--- +# SPDX-FileCopyrightText: (C) 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# This is a workflow that is triggered to build EMT desktop virtualization (IDV) ISO +name: EMT IDV ISO Builder +permissions: + contents: read +# Controls when the action will run. Workflow runs when manually triggered using the UI +# or API. +on: + push: + branches: + - emt-dv-iso + - main + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + tag: + # description to be shown in the UI + description: 'release tag to be build' + # Default value if no value is explicitly provided + default: '3.0.20250806' + # Input has to be provided for the workflow to run + required: true + # The data type of the input + type: string + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # A workflow run is made up of one or more jobs that can run sequentially or in parallel + build-idv-iso: + # The type of runner that the job will run on + runs-on: ubuntu-24.04 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Runs a single command using the runners shell + - name: Build EMT IDV ISO + run: | + wget https://raw.githubusercontent.com/open-edge-platform/edge-desktop-virtualization/refs/heads/emt-dv-iso/emt-dv-iso/build_idv_iso.sh + chmod a+x build_idv_iso.sh + if [[ -z "${{ inputs.myInput }}" ]]; then + ./build_idv_iso.sh + else + ./build_idv_iso.sh -t "${{ inputs.myInput }}" + fi + ls -lrt + - name: Upload a Build Artifact + uses: actions/upload-artifact@v4.6.2 + with: + # Artifact name + name: emt-idv-iso + # A file, directory or wildcard pattern that describes what to upload + path: idv*.iso diff --git a/emt-dv-iso/README.md b/emt-dv-iso/README.md new file mode 100644 index 0000000..cb3f898 --- /dev/null +++ b/emt-dv-iso/README.md @@ -0,0 +1,122 @@ + +# Building EMT ISO with Desktop Virtualization (graphics SR-IOV) + +- [Building EMT ISO with Desktop Virtualization (graphics SR-IOV)](#building-emt-iso-with-desktop-virtualization-graphics-sr-iov) + - [Option-1 : Standalone (One-click) Build Script](#option-1--standalone-one-click-build-script) + - [Run the script with default parameters](#run-the-script-with-default-parameters) + - [Run the scripts with custom parameters](#run-the-scripts-with-custom-parameters) + - [ISO file will be generated in the same path](#iso-file-will-be-generated-in-the-same-path) + - [Demo : One-click EMT IDV ISO build script](#demo--one-click-emt-idv-iso-build-script) + - [Option-2 : Manual Steps](#option-2--manual-steps) + - [Pre-requisite](#pre-requisite) + - [Step 1: clone the EMT repo](#step-1-clone-the-emt-repo) + - [Step 2: Checkout the tag](#step-2-checkout-the-tag) + - [Step 3: Copy the idv.json to edge-microvisor-toolkit/toolkit/imageconfigs/](#step-3-copy-the-idvjson-to-edge-microvisor-toolkittoolkitimageconfigs) + - [Step 4: Build the tools](#step-4-build-the-tools) + - [Step 5: Build the ISO for desktop virtualization (IDV)](#step-5-build-the-iso-for-desktop-virtualization-idv) + - [Troubleshoot](#troubleshoot) + - [Clean build](#clean-build) + - [Working with Proxies](#working-with-proxies) + - [Option-3 : Github Actions](#option-3--github-actions) + - [Demo : EMT IDV ISO generation as part of github actions/workflow](#demo--emt-idv-iso-generation-as-part-of-github-actionsworkflow) + +## Option-1 : Standalone (One-click) Build Script + +> **Prerequisite** : Ubuntu 22.04 or Ubuntu 24.04 + +### Run the script with default parameters +```sh +sudo ./build_idv_iso.sh +``` +Command line arguments are optional. Below default values will be used : +- Latest emt release tag : [3.0.20250718](https://github.com/open-edge-platform/edge-microvisor-toolkit/releases/tag/3.0.20250718) +- [idv.json](https://github.com/open-edge-platform/edge-desktop-virtualization/blob/emt-dv-iso/emt-dv-iso/idv.json) + +### Run the scripts with custom parameters + +Build script supports 2 custom parameters (optional): +1. [-t *tag-name*] : This is the git release tag-name against which build should run. +2. [-f *image-config-json-file*] : This is the emt image config .json file. One can generate the custom images using this config file. + +For ex: +```sh +sudo ./build_idv_iso.sh -t 3.0.20250718 -f ./idv.json +``` + +### ISO file will be generated in the same path + +emt-idv-iso-out + +### Demo : One-click EMT IDV ISO build script + +https://github.com/user-attachments/assets/8e3f609b-9632-4ea6-807d-1560856a20db + +## Option-2 : Manual Steps + +The image configuration is part of this repo [here](./idv.json) + +### Pre-requisite + +[Build Requirements](https://github.com/open-edge-platform/edge-microvisor-toolkit/blob/3.0/toolkit/docs/building/prerequisites-ubuntu.md#build-requirements-on-ubuntu) + +> The steps and build requirements are common across ubuntu-24.04 and ubuntu-22.04 +> It is recommended to built against a stable/release tag. + + +### Step 1: clone the EMT repo +```sh +git clone https://github.com/open-edge-platform/edge-microvisor-toolkit +``` +### Step 2: Checkout the tag +```sh +cd edge-microvisor-toolkit +git checkout tags/ +``` +> The release tags can be found [here](https://github.com/open-edge-platform/edge-microvisor-toolkit/releases) + +### Step 3: Copy the idv.json to edge-microvisor-toolkit/toolkit/imageconfigs/ +```sh +wget https://raw.githubusercontent.com/open-edge-platform/edge-desktop-virtualization/refs/heads/emt-dv-iso/emt-dv-iso/idv.json +cp idv.json toolkit/imageconfigs/ +``` +> One can copy any custom idv.json file as per the requirement. + +### Step 4: Build the tools +```sh +cd toolkit +sudo make toolchain REBUILD_TOOLS=y +``` +### Step 5: Build the ISO for desktop virtualization (IDV) +```sh +sudo make iso -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/idv.json +``` +> ISO file will be generated @ 'edge-microvisor-toolkit/out/images' + +### Troubleshoot + +#### Clean build + +For re-building with any other tags, its recommended to start clean and repeat above Steps 1 to 5. + ```sh +cd edge-microvisor-toolkit +sudo make -C toolkit clean +``` + +#### Working with Proxies + +If you are behind proxies and have them set, use -E option with all make commands +For ex : +``` +sudo -E make toolchain REBUILD_TOOLS=y +sudo -E make iso -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/idv.json +``` + +## Option-3 : Github Actions + +Generation of EMT IDV ISO can be part of github actions/workflow. + +[Reference workflow file](https://raw.githubusercontent.com/open-edge-platform/edge-desktop-virtualization/refs/heads/emt-dv-iso/.github/workflows/idv-iso-builder.yaml) + +### Demo : EMT IDV ISO generation as part of github actions/workflow + +https://github.com/user-attachments/assets/66f508a0-c9c8-4f4e-9be7-f60a42a995fb diff --git a/emt-dv-iso/build_idv_iso.sh b/emt-dv-iso/build_idv_iso.sh new file mode 100755 index 0000000..e50741d --- /dev/null +++ b/emt-dv-iso/build_idv_iso.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +# Copyright (C) 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +set -eE +start_time=$(date +%s) +# Define color variables for readability +RED='\e[31m' +GREEN='\e[32m' +BLUE='\e[34m' +ENDCOLOR='\e[0m' # Reset to default color + +# ------------------- Default Values ------------------------------ + +# Default tag. This will be the latest EMT release tag. +DEFAULT_TAG=3.0.20250806 + +# Default image config .json file. If this is NULL, default will be fetched from the repo. +DEFAULT_IDV_JSON_PATH="" +# This will be used only if above is NULL +DEFAULT_IDV_JSON_GIT_FETCH="https://raw.githubusercontent.com/open-edge-platform/edge-desktop-virtualization/refs/heads/emt-dv-iso/emt-dv-iso/idv.json" + +# ------------------- Global Variables ---------------------------- + +# Git repo to build against. This can be any forked repo of EMT as well. +GIT_REPO=https://github.com/open-edge-platform/edge-microvisor-toolkit.git + +# Full path of the image config JSON. +IDV_JSON_PATH=$DEFAULT_IDV_JSON_PATH + +# If no TAG is provided by user, lets use the default tag +TAG=$DEFAULT_TAG + +# Register the current directory +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function launch_build() { + echo -e "${RED}------------------------- Build Details -----------------------------------${ENDCOLOR}" + echo -e "${BLUE}Current working directory : ${GREEN}$DIR ${ENDCOLOR}" + echo -e "${BLUE}No. of CPUs on the system : ${GREEN}$(nproc)${ENDCOLOR}" + echo -e "${BLUE}git repo to be used : ${GREEN}$GIT_REPO ${ENDCOLOR}" + echo -e "${BLUE}tag (a release tag) : ${GREEN}$TAG ${ENDCOLOR}" + echo -e "${BLUE}image config Json Path : ${GREEN}$IDV_JSON_PATH ${ENDCOLOR}" + echo -e "${BLUE}Json git fetch path (if above Json Path is NULL) : ${GREEN}$DEFAULT_IDV_JSON_GIT_FETCH ${ENDCOLOR}" + echo -e "${RED}--------------------------------------------------------------------------${ENDCOLOR}" + + # clone the emt repo + echo -e "${BLUE}Cloning the EMT repo @${GREEN}${GIT_REPO}${ENDCOLOR}" + git clone $GIT_REPO + cd edge-microvisor-toolkit + + # checkout the required TAG + echo -e "${BLUE}Checkout tag : ${GREEN}${TAG}${ENDCOLOR}" + git checkout $TAG + + # pre-requisites + echo -e "${BLUE}Installing all the pre-requisites${ENDCOLOR}" + sudo ./toolkit/docs/building/prerequisites-ubuntu.sh + sudo ln -vsf /usr/lib/go-1.21/bin/go /usr/bin/go + sudo ln -vsf /usr/lib/go-1.21/bin/gofmt /usr/bin/gofmt + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + sudo usermod -aG docker $USER + + # build the toolkit + cd toolkit + if [[ -z "$IDV_JSON_PATH" ]]; then + echo -e "${BLUE}JSON input not provided. Hence download the default one.${ENDCOLOR}" + wget $DEFAULT_IDV_JSON_GIT_FETCH + cp idv.json ./imageconfigs + else + echo -e "${BLUE}JSON input provided is : ${GREEN}$IDV_JSON_PATH${ENDCOLOR}" + cp $IDV_JSON_PATH ./imageconfigs/idv.json + fi + sudo make -j$(nproc) toolchain REBUILD_TOOLS=y VALIDATE_TOOLCHAIN_GPG=n + + # build the iso image + sudo make iso -j$(nproc) REBUILD_TOOLS=y REBUILD_PACKAGES=n VALIDATE_TOOLCHAIN_GPG=n CONFIG_FILE=./imageconfigs/idv.json + + # copy the generated iso to same parent folder + cp ../out/images/idv/*.iso ../../. + + echo -e ${GREEN}"Build Successful!" + echo -e "${BLUE}Generated ISO available at : ${GREEN}$DIR${ENDCOLOR}" + echo -e ${BLUE}"Available ISO Files : " ${GREEN} $DIR/*.iso ${ENDCOLOR} +} + +function cleanup() { + echo -e "${GREEN}Performing cleanup ${ENDCOLOR}" + cd $DIR + sudo rm -rf edge-microvisor-toolkit + end_time=$(date +%s) + runtime=$((end_time - start_time)) + echo -e ${BLUE}"Total Build runtime: ${GREEN}$runtime seconds"${ENDCOLOR} +} + +while getopts ':t:f:h' opt; do + case "$opt" in + t) + tag_arg="$OPTARG" + TAG=$tag_arg + echo "Processing option 't' with '${TAG}' argument" + ;; + + f) + file_arg="$OPTARG" + IDV_JSON_PATH=$(realpath "$file_arg") + echo "Processing option 'f' with '${IDV_JSON_PATH}' argument" + ;; + + h) + echo "Usage: $(basename $0) [-t tag-name] [-f image-config-json-file]" + exit 0 + ;; + + :) + echo -e "option requires an argument.\nUsage: $(basename $0) [-t tag-name] [-f image-config-json-file]" + exit 1 + ;; + + ?) + echo -e "Invalid command option.\nUsage: $(basename $0) [-t tag-name] [-f image-config-json-file]" + exit 1 + ;; + esac +done +shift "$(($OPTIND -1))" + +trap cleanup EXIT +trap cleanup ERR + +#---------------------- main ------------------------ + +launch_build diff --git a/emt-dv-iso/docs/emt-idv-iso-out.png b/emt-dv-iso/docs/emt-idv-iso-out.png new file mode 100644 index 0000000..a1bd79a Binary files /dev/null and b/emt-dv-iso/docs/emt-idv-iso-out.png differ diff --git a/emt-dv-iso/idv.json b/emt-dv-iso/idv.json new file mode 100644 index 0000000..475aa4d --- /dev/null +++ b/emt-dv-iso/idv.json @@ -0,0 +1,46 @@ +{ + "SystemConfigs": [ + { + "Name": "EMT-Desktop-Virtualization", + "PackageLists": [ + "packagelists/grub2-mkconfig.json", + "packagelists/developer-packages.json", + "packagelists/virtualization-host-full-packages.json", + "packagelists/core-packages-image.json", + "packagelists/core-tools-packages.json", + "packagelists/ssh-server.json", + "packagelists/qemu-guest-packages.json", + "packagelists/xorg-x11-packages.json", + "packagelists/selinux-full.json", + "packagelists/intel-gpu-base.json", + "packagelists/drtm.json", + "packagelists/virt-guest-packages.json", + "packagelists/intel-wireless.json" + ], + "Packages": [ + "lsb-release", + "nbd", + "ntfs-3g", + "ntfs-3g-system-compression", + "ntfs-3g-libs", + "wpa_supplicant", + "igt-gpu-tools" + ], + "KernelCommandLine": { + "ExtraCommandLine": "udmabuf.list_limit=8192 i915.enable_guc=3 i915.max_vfs=7 intel_iommu=on i915.force_probe=*", + "SELinux": "permissive" + }, + "KernelOptions": { + "default": "kernel" + }, + "AdditionalFiles": { + "additionalconfigs/99-dhcp-en.network": "/etc/systemd/network/99-dhcp-en.network" + }, + "PostInstallScripts": [ + { + "Path": "additionalconfigs/configure-systemd-networkd-client-identifier.sh" + } + ] + } + ] +}