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

add repack-variant #214

Merged
merged 2 commits into from
May 14, 2024
Merged

add repack-variant #214

merged 2 commits into from
May 14, 2024

Conversation

jpculp
Copy link
Member

@jpculp jpculp commented May 14, 2024

Description of changes:

Add the the initial target for repackaging a Bottlerocket variant. This target will skip the traditional workflow of building packages and using rpm2img. Instead the build system will point to a yet to be implemented img2img tool.

Includes some preliminary housekeeping. Removes some unnecessary checks, references, and dependencies. Renames Dockerfile to build.Dockerfile and adds a common argument for future build targets to skip cleanup if desired.

Testing done:

  • Built bottlerocket with the default make target
  • Verified cleanup occurred when built a second time
  • Attempted build with bottlerocket with the repack target
  • Verified cleanup did not occur when repacked a second time

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.

@jpculp jpculp requested review from bcressey and webern May 14, 2024 02:24
tools/buildsys/src/args.rs Outdated Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
tools/buildsys/src/builder.rs Outdated Show resolved Hide resolved
tools/buildsys/src/builder.rs Outdated Show resolved Hide resolved
@jpculp
Copy link
Member Author

jpculp commented May 14, 2024

  • Removed unnecessary items from manifest.rs.
  • Set Repack to the typical "variants" marker dir.
  • Switched Repack from 0b00000000 to 0b00001000.
  • Added OS_IMAGE_SIZE_GIB and DATA_IMAGE_SIZE_GIB to repack-variant.

@jpculp jpculp requested a review from bcressey May 14, 2024 06:45
Adjusts some things in the build system for preliminary support for an
additional build target. Removes some unnecessary checks, references,
and dependencies. Renames Dockerfile to build.Dockerfile and adds a
common argument for future build targets to skip cleanup if desired.

Signed-off-by: Patrick J.P. Culp <[email protected]>
@jpculp
Copy link
Member Author

jpculp commented May 14, 2024

Rebased.

tools/buildsys/src/args.rs Outdated Show resolved Hide resolved
tools/buildsys/src/args.rs Outdated Show resolved Hide resolved
@@ -504,6 +504,7 @@ fn is_manifest_type(pkg_metadata: &PackageMetadata, manifest_type: BuildType) ->
BuildType::Package => metadata_table.get("build-package").is_some(),
BuildType::Kit => metadata_table.get("build-kit").is_some(),
BuildType::Variant => metadata_table.get("build-variant").is_some(),
BuildType::Repack => metadata_table.get("build-variant").is_some(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be better as an error or an unreachable! - we shouldn't be taking this graph-walk path for a repack operation, and the longer we make it work before failing, the harder it will be to diagnose the logic error that let us reach this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this function returns a bool, unreachable! might be cleanest.

@jpculp
Copy link
Member Author

jpculp commented May 14, 2024

  • Adjust build_type_includes_test.
  • Set Repack to unreachable in is_manifest_type.

tools/buildsys/src/args.rs Outdated Show resolved Hide resolved
tools/buildsys/src/args.rs Outdated Show resolved Hide resolved
tools/buildsys/src/builder.rs Outdated Show resolved Hide resolved
@@ -504,6 +504,7 @@ fn is_manifest_type(pkg_metadata: &PackageMetadata, manifest_type: BuildType) ->
BuildType::Package => metadata_table.get("build-package").is_some(),
BuildType::Kit => metadata_table.get("build-kit").is_some(),
BuildType::Variant => metadata_table.get("build-variant").is_some(),
BuildType::Repack => unreachable!("Repacking is not defined in manifests"),
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 like this. Let's just return false since that is an accurate answer to the question is_manifest_type. A function that can panic seems out of character for us.

Edit: I have learned that this was Ben's preference so go ahead and merge it like this. I hope to make this function go away at some point with some refactoring, but we'll see...

Suggested change
BuildType::Repack => unreachable!("Repacking is not defined in manifests"),
BuildType::Repack => false,

twoliter/src/tools.rs Show resolved Hide resolved
Add the the initial target for repackaging a Bottlerocket variant. This
target will skip the traditional workflow of building packages and
using `rpm2img`. Instead the build system will point to a yet to be
implemented `img2img` tool.

Signed-off-by: Patrick J.P. Culp <[email protected]>
@jpculp
Copy link
Member Author

jpculp commented May 14, 2024

Adjusted some names and ordering.

@jpculp jpculp merged commit bbdbc20 into bottlerocket-os:develop May 14, 2024
1 check passed
@jpculp jpculp deleted the repack-variant branch May 14, 2024 22:17
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.

3 participants