From c66d0f0cde21f6583fb9a0217d69302660239ff5 Mon Sep 17 00:00:00 2001 From: Vinay Potluri Date: Wed, 27 Nov 2019 14:58:46 -0800 Subject: [PATCH] Adding files to support command line testing of image creation Adding the below listed files for successful image creation and testing on command line with make Signed-off-by: Vinay Potluri --- images/native-finalize.sh | 29 +++++++++++++++++++++++++++++ images/native-post.sh | 12 ++++++++++++ images/native.yaml | 5 ++++- images/task-compress-image.sh | 18 ++++++++++++++++++ images/task-wait-to-boot.sh | 15 +++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 images/native-finalize.sh create mode 100755 images/native-post.sh create mode 100755 images/task-compress-image.sh create mode 100755 images/task-wait-to-boot.sh diff --git a/images/native-finalize.sh b/images/native-finalize.sh new file mode 100755 index 0000000..870ba82 --- /dev/null +++ b/images/native-finalize.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# This is a finalize script that is run by clr-distro-factory to support +# user's requirement for conversion / compression of images before exporting. +# ex: -finalize.sh + +set -e + +SCRIPT_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")") + +if (( ${#} != 1 )); then + echo "${0}: Must receive exactly one file path." >&2 + exit 1 +fi + +if [[ ! -s "${1}" ]]; then + echo "${0}: Invalid input: '${1}' is empty." >&2 + exit 1 +fi + +file_ext="${1##*.}" + +if [[ "${file_ext}" == "iso" ]]; then + echo "${1}" +else + "${SCRIPT_DIR}/task-compress-image.sh" "${1}" "${1}.xz" >&2 + rm -rf "${@}" >&2 + echo "${1}.xz" +fi diff --git a/images/native-post.sh b/images/native-post.sh new file mode 100755 index 0000000..dcc2ccd --- /dev/null +++ b/images/native-post.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# This is a post install script that is run from the config after the image +# has been created by clr-installer for images with special requirements +# ex: -post.sh + +set -e + +SCRIPT_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")") + +# Delay booting to give user a change to change boot params +${SCRIPT_DIR}/task-wait-to-boot.sh "${1}" diff --git a/images/native.yaml b/images/native.yaml index b1cd711..423659c 100644 --- a/images/native.yaml +++ b/images/native.yaml @@ -27,7 +27,10 @@ targetMedia: type: part keyboard: us language: en_US.UTF-8 -bundles: [bootloader, os-core, os-core-update] +iso: true +keepImage: true telemetry: false +bundles: [bootloader, os-core, os-core-update] kernel: kernel-native block-devices: [{name: native, file: native.img}] +post-install: [{cmd: "${yamlDir}/native-post.sh ${chrootDir}"}] diff --git a/images/task-compress-image.sh b/images/task-compress-image.sh new file mode 100755 index 0000000..22ff6a6 --- /dev/null +++ b/images/task-compress-image.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# This is a task script that can be executed to perform specific tasks +# which are common between various images. +# Task scripts can be called commonly from post & finalize scripts. +# ex: task-.sh + +set -e + +if (( ${#} < 1 )); then + echo "${0}: Insufficient number of arguments." >&2 + exit 1 +fi + +if ! xz -q -T0 --stdout "${1}" > "${2:-${1}.xz}"; then + echo "${0}: Unable to compress file ${1}." >&2 + exit 1 +fi diff --git a/images/task-wait-to-boot.sh b/images/task-wait-to-boot.sh new file mode 100755 index 0000000..0c41ff0 --- /dev/null +++ b/images/task-wait-to-boot.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# This is a task script that can be executed to perform specific tasks +# which are common between various images. +# Task scripts can be called commonly from post & finalize scripts. +# ex: task-.sh + +#!/bin/bash + +# Have the installer image wait 5 seconds before launch +# Useful for users to change the boot command for debug + +echo "timeout 5" >> $1/boot/loader/loader.conf + +exit 0