-
Notifications
You must be signed in to change notification settings - Fork 34
feat(just): add overlay command for sysext testing #158
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
base: main
Are you sure you want to change the base?
Changes from all commits
e06e1cf
4fc1a23
9ec69a5
8ada5a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| *.raw | ||
| *.img | ||
| *.erofs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,46 @@ tree IMAGE="localhost/bluefin-common:latest": | |
| podman run --rm tree-temp | ||
| rm TreeContainerfile | ||
| podman rmi tree-temp | ||
|
|
||
| overlay $BLUEFIN_MERGE="1" $SOURCE="dir": | ||
| #!/usr/bin/env bash | ||
| ROOTFS_DIR="$(mktemp -d --tmpdir="${ROOTFS_BASE:-/tmp}")" | ||
| trap 'rm -rf "${ROOTFS_DIR}"' EXIT | ||
| NAME_TRIMMED=bfincommon | ||
|
|
||
| if [ "$SOURCE" == "dir" ] ; then | ||
| cp -a ./system_files/shared/. "${ROOTFS_DIR}" | ||
| if [ "${BLUEFIN_MERGE}" == "1" ] ; then | ||
| cp -a ./system_files/bluefin/. "${ROOTFS_DIR}" | ||
| fi | ||
| elif [ "$SOURCE" == "image" ] ; then | ||
| podman export "$(podman create ghcr.io/projectbluefin/common:latest)" -o - | tar -xvf - -C "${ROOTFS_DIR}" | ||
| fi | ||
|
|
||
| install -d -m0755 "${ROOTFS_DIR}/usr/lib/extension-release.d" | ||
| tee "${ROOTFS_DIR}/usr/lib/extension-release.d/extension-release.${NAME_TRIMMED}" <<EOF | ||
| ID="_any" | ||
| ARCHITECTURE="$(sed 's/_/-/g' <<< "$(arch)")" | ||
| EOF | ||
|
|
||
| if [ -e "${ROOTFS_DIR}/system_files" ] ; then | ||
| cp -a "${ROOTFS_DIR}/system_files/shared/." "${ROOTFS_DIR}" | ||
| if [ "${BLUEFIN_MERGE}" == "1" ] ; then | ||
| cp -a "${ROOTFS_DIR}/system_files/bluefin/." "${ROOTFS_DIR}" | ||
| fi | ||
| rm -r "${ROOTFS_DIR}/system_files" | ||
| fi | ||
|
|
||
| if [ -d "${ROOTFS_DIR}/etc" ] ; then | ||
| mv --no-clobber "${ROOTFS_DIR}/etc" "${ROOTFS_DIR}/usr/etc" | ||
| fi | ||
|
Comment on lines
+66
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The To correctly merge the contents of |
||
|
|
||
| for dir in "var" "run"; do | ||
| if [ -d "${ROOTFS_DIR}"/"${dir}" ] ; then | ||
| rm -r "${ROOTFS_DIR:?}/${dir}" | ||
| fi | ||
| done | ||
| filecontexts="/etc/selinux/targeted/contexts/files/file_contexts" | ||
| sudo setfiles -r "${ROOTFS_DIR}" "${filecontexts}" "${ROOTFS_DIR}" | ||
| sudo chcon --user=system_u --recursive "${ROOTFS_DIR}" | ||
| mkfs.erofs "${NAME_TRIMMED}.raw" "${ROOTFS_DIR}" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script should be configured to exit immediately if any command fails. Without this, an error in one of the steps (e.g.,
crane exportfailing) would be ignored, and the script would continue executing, potentially resulting in a corrupt or incomplete image. Addingset -euo pipefailis a best practice for writing robust shell scripts.set -e: Exits the script if any command fails.set -u: Treats unset variables as an error.set -o pipefail: Ensures that a pipeline's exit code is the exit code of the last command to exit with a non-zero status, which is crucial for thecrane | tarcommand on line 42.