diff --git a/images/native-finalize.sh b/images/native-finalize.sh new file mode 100755 index 0000000..c14c964 --- /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 "${1}" >&2 + echo "${1}.xz" +fi diff --git a/images/native-post.sh b/images/native-post.sh new file mode 100755 index 0000000..540a035 --- /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..c01d77b --- /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