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

rpm2img: ensure /usr/share/bottlerocket exists #381

Merged

Conversation

bcressey
Copy link
Contributor

Issue number:
Related: bottlerocket-os/bottlerocket-core-kit#163

Description of changes:
Create the /usr/share/bottlerocket directory before writing any files to it, just in case a package hasn't already created it.

Testing done:
This was annoying to test, given the implicit expectations in rpm2img that a kernel package will be installed, but with some local hacks I was able to confirm that a version of aws-dev which removed the kernel-6.1 package dependency failed later in the script:

  #18 6.266 + KMOD_DIR=/tmp/tmp.93mm5b2Vug/lib/modules
  #18 6.266 + [[ yes == \y\e\s ]]
  #18 6.266 + find /tmp/tmp.93mm5b2Vug/lib/modules -name '*.ko.gz' -exec gunzip '{}' ';'
  #18 6.269 find: '/tmp/tmp.93mm5b2Vug/lib/modules': No such file or directory
  #18 6.270 + cleanup

Said hacks:

❯ git diff
diff --git a/twoliter/embedded/rpm2img b/twoliter/embedded/rpm2img
index 855791c..4d4a592 100755
--- a/twoliter/embedded/rpm2img
+++ b/twoliter/embedded/rpm2img
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash

-set -eu -o pipefail
+set -eux -o pipefail
 shopt -qs failglob

 OUTPUT_FMT="raw"
diff --git a/twoliter/embedded/rpm2kmodkit b/twoliter/embedded/rpm2kmodkit
index 079d98c..1626b4b 100755
--- a/twoliter/embedded/rpm2kmodkit
+++ b/twoliter/embedded/rpm2kmodkit
@@ -31,7 +31,7 @@ mkdir -p "${OUTPUT_DIR}" "${KIT_DIR}/${KMOD_KIT}"
 # Extract any RPMs and find the kernel development archive.
 pushd "${EXTRACT_DIR}" >/dev/null
 find "${ARCHIVE_DIR}" -type f -name '*.rpm' \
-  -exec rpm2cpio {} \; | cpio -idm --quiet
+  -exec rpm2cpio {} \; | cpio -idm --quiet ||:
 find -name 'kernel-devel.tar.xz' \
   -exec mv {} "${KIT_DIR}/${KMOD_KIT}" \;
 popd >/dev/null

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.

Otherwise, this directory only exists if an installed packages places
a file there.

Historically, this always worked because the kernel-devel package
includes a squashfs archive in that directory. However, we shouldn't
rely on coincidences like that.

Signed-off-by: Ben Cressey <[email protected]>
@bcressey bcressey requested review from cbgbt and yeazelm September 27, 2024 03:45
@bcressey bcressey merged commit 2af8b5a into bottlerocket-os:develop Sep 27, 2024
1 check passed
@bcressey bcressey deleted the mkdir-usr-share-bottlerocket branch September 27, 2024 04:30
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