Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Adding files to support command line testing of image creation #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions images/native-finalize.sh
Original file line number Diff line number Diff line change
@@ -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: <image_name>-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
12 changes: 12 additions & 0 deletions images/native-post.sh
Original file line number Diff line number Diff line change
@@ -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: <image_name>-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}"
5 changes: 4 additions & 1 deletion images/native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"}]
18 changes: 18 additions & 0 deletions images/task-compress-image.sh
Original file line number Diff line number Diff line change
@@ -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-<job_name>.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
15 changes: 15 additions & 0 deletions images/task-wait-to-boot.sh
Original file line number Diff line number Diff line change
@@ -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-<job_name>.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