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

Conversation

zmrow
Copy link
Contributor

@zmrow zmrow commented Jun 7, 2022

Description of changes:

    This change adds two new targets to the Makefile.  Both make use of the
    `bootconfig` tool in the latest version of the SDK.  The first new
    target, `boot-config`, gives users the ability to create a properly
    formatted Boot Configuration initrd given a valid config file.  The
    second new target `validate-boot-config`, validates the Boot
    Configuration initrd, listing its contents.  If the initrd is somehow in
    a bad format, the tool will fail and print an error.

    The Makefile targets expect a valid configuration file in the root of
    the Bottlerocket repo named "bootconfig-input".  The Boot Configuration
    initrd will be created in the root of the repo with the name
    "bootconfig.data", which is what Bottlerocket expects the file to be
    named when using it.

Testing done:
Create and validate new Boot Configuration:

$ cat bootconfig-input 
kernel {
    console = tty0, "ttyS1,115200n8"
}
init {
    systemd.log_level = debug
}

$ cargo make boot-config
...
[cargo-make] INFO - Running Task: boot-config
Creating a new boot config from input /home/fedora/bottlerocket/bottlerocket/bootconfig-input
Apply /tmp/bootconfig-input to /tmp/bootconfig.data
        Number of nodes: 8
        Size: 88 bytes
        Checksum: 6790
Boot configuration initrd may be found at /home/fedora/bottlerocket/bottlerocket/bootconfig.data
...

$ cargo make validate-boot-config
...
[cargo-make] INFO - Running Task: validate-boot-config
kernel.console = "tty0", "ttyS1,115200n8"
init.systemd.log_level = "debug"
...

Update the existing configuration:

$ cat bootconfig-input 
kernel {
    console = tty0
}

$ cargo make boot-config
...
Boot config exists at '/home/fedora/bottlerocket/bottlerocket/bootconfig.data', updating it with input /home/fedora/bottlerocket/bottlerocket/bootconfig-input
Apply /tmp/bootconfig-input to /tmp/bootconfig.data
        Number of nodes: 3
        Size: 31 bytes
        Checksum: 2360
Boot configuration initrd may be found at /home/fedora/bottlerocket/bottlerocket/bootconfig.data

$ cat bootconfig.data 
kernel {
    console = tty0
}
...

$ cargo make validate-boot-config
...
[cargo-make] INFO - Running Task: validate-boot-config
kernel.console = "tty0"

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

This change adds two new targets to the Makefile.  Both make use of the
`bootconfig` tool in the latest version of the SDK.  The first new
target, `boot-config`, gives users the ability to create a properly
formatted Boot Configuration initrd given a valid config file.  The
second new target `validate-boot-config`, validates the Boot
Configuration initrd, listing its contents.  If the initrd is somehow in
a bad format, the tool will fail and print an error.

The Makefile targets expect a valid configuration file in the root of
the Bottlerocket repo named "bootconfig-input".  The Boot Configuration
initrd will be created in the root of the repo with the name
"bootconfig.data", which is what Bottlerocket expects the file to be
named when using it.
@zmrow zmrow requested review from bcressey and etungsten June 7, 2022 21:59
Comment on lines +162 to +165
# 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"
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.

@zmrow zmrow merged commit ed6451e into bottlerocket-os:develop Jun 22, 2022
@zmrow zmrow deleted the makefile-bootconfig branch June 22, 2022 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants