Skip to content

Commit 0bfb51e

Browse files
authored
Update build script to facilitate iso builds (#241)
## Description Linuxkit also offers an option to build kernel as an iso file. Update the build script to be able Hook as an ISO. ## Why is this needed Apart from the default build, this change provides the users to be able to mount Hook as an ISO and boot using the virtual media option. Fixes: # ## How Has This Been Tested? Set `LINUXKIT_ISO` to true and built hook as an ISO. Mounted the ISO on a Dell R340 as a virtual media device and booted using the ISO. As this flow kicks in only when the above env var is set, it should affect any existing user workflow. ## Checklist: If this gets approved, I will update the Readme appropriately to document the option to build as an ISO. I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
2 parents a562ffd + ae5eb27 commit 0bfb51e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The most important environment variables are:
137137
- `HOOK_LK_CONTAINERS_OCI_BASE`: OCI base coordinates for the LinuxKit containers.
138138
- `CACHE_DIR`: directory where the build system will cache downloaded files. Relative to the project root.
139139
- `USE_LATEST_BUILT_KERNEL`: set this to `yes` to use the latest built kernel from `quay.io/tinkerbell/hook-kernel`.
140+
- `LINUXKIT_ISO`: set this to `yes` to build an ISO image instead of a kernel and initrd.
140141
- exclusively for the `qemu` command:
141142
- `TINK_SERVER=<ip>`: the IP address of the Tinkerbell GRPC server. No default.
142143
- `MAC=<mac>`: the MAC address of the machine that will be provisioned. No default.

bash/linuxkit.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ function linuxkit_build() {
8383
declare lk_cache_dir="${CACHE_DIR}/linuxkit"
8484
mkdir -p "${lk_cache_dir}"
8585

86+
# if LINUXKIT_ISO is set, build an ISO with the kernel and initramfs
87+
if [[ -n "${LINUXKIT_ISO}" ]]; then
88+
declare lk_iso_output_dir="out"
89+
mkdir -p "${lk_iso_output_dir}"
90+
91+
declare -a lk_iso_args=(
92+
"--docker"
93+
"--arch" "${kernel_info['DOCKER_ARCH']}"
94+
"--format" "iso-efi-initrd"
95+
"--name" "hook"
96+
"--cache" "${lk_cache_dir}"
97+
"--dir" "${lk_iso_output_dir}"
98+
"hook.${inventory_id}.yaml" # the linuxkit configuration file
99+
)
100+
101+
log info "Building Hook ISO with kernel ${inventory_id} using linuxkit: ${lk_iso_args[*]}"
102+
"${linuxkit_bin}" build "${lk_iso_args[@]}"
103+
return 0
104+
fi
105+
86106
declare -a lk_args=(
87107
"--docker"
88108
"--arch" "${kernel_info['DOCKER_ARCH']}"

0 commit comments

Comments
 (0)