Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: Add targets to create and validate Boot Configuration #2189

Merged
merged 1 commit into from
Jun 22, 2022
Merged
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
60 changes: 60 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ BUILDSYS_OVF_TEMPLATE = "${BUILDSYS_ROOT_DIR}/variants/${BUILDSYS_VARIANT}/templ
# The default name of uploaded OVAs; override by setting VMWARE_VM_NAME
VMWARE_VM_NAME_DEFAULT = "${BUILDSYS_NAME}-${BUILDSYS_VARIANT}-${BUILDSYS_ARCH}-v${BUILDSYS_VERSION_IMAGE}-${BUILDSYS_VERSION_BUILD}"

# Config file for Boot Configuration initrd generation
BOOT_CONFIG_INPUT = "${BUILDSYS_ROOT_DIR}/bootconfig-input"
# Boot Configuration initrd
BOOT_CONFIG = "${BUILDSYS_ROOT_DIR}/bootconfig.data"
Comment on lines +162 to +165
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's possible to override these variables with cargo make -e. But maybe that's ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 🤔

IMHO, I think that's probably ok considering we want to name the initrd a specific way. I suppose flexibility in the input file name would be nice, but I'm not sure how much it gets us.


[tasks.setup]
script = [
'''
Expand Down Expand Up @@ -428,6 +433,61 @@ fi
'''
]

[tasks.boot-config]
dependencies = ["fetch-sdk"]
script_runner = "bash"
script = [
'''
set -euo pipefail

if [ ! -s "${BOOT_CONFIG_INPUT}" ]; then
echo "No boot configuration file exists, please create one at ${BOOT_CONFIG_INPUT}"
exit 1
fi

# If a Boot Config initrd already exists update it, otherwise create a new one
boot_config_tmp=""
boot_config=""
if [ -s "${BOOT_CONFIG}" ]; then
echo "Boot config exists at '${BOOT_CONFIG}', updating it with input ${BOOT_CONFIG_INPUT}"
boot_config="${BOOT_CONFIG}"
else
echo "Creating a new boot config from input ${BOOT_CONFIG_INPUT}"
boot_config_tmp=$(mktemp /tmp/bootconfig.data.XXXXX)
boot_config="${boot_config_tmp}"
fi

docker run --rm \
--network=none \
--user "$(id -u):$(id -g)" \
--security-opt label:disable \
-v "${BOOT_CONFIG_INPUT}":/tmp/bootconfig-input \
-v "${boot_config}":/tmp/bootconfig.data \
"${BUILDSYS_SDK_IMAGE}" \
bootconfig -a /tmp/bootconfig-input /tmp/bootconfig.data

if [ -e "${boot_config_tmp}" ] ; then
mv "${boot_config_tmp}" "${BOOT_CONFIG}"
fi
echo "Boot configuration initrd may be found at ${BOOT_CONFIG}"
'''
]

[tasks.validate-boot-config]
dependencies = ["fetch-sdk"]
script_runner = "bash"
script = [
'''
docker run --rm \
--network=none \
--user "$(id -u):$(id -g)" \
--security-opt label:disable \
-v "${BOOT_CONFIG}":/tmp/bootconfig.data \
"${BUILDSYS_SDK_IMAGE}" \
bootconfig -l /tmp/bootconfig.data
'''
]

# Builds a package including its build-time and runtime dependency packages.
[tasks.build-package]
dependencies = ["check-cargo-version", "build-tools", "publish-setup", "fetch-licenses"]
Expand Down