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

buildextend-metal: Make sysroot-ro an opt-in image.yaml parameter #1235

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ if [ "${image_type}" == metal4k ]; then
disk_args+=("--no-x86-bios-partition")
fi

sysroot_ro="$(python3 -c 'import sys, yaml; v=yaml.safe_load(sys.stdin).get("sysroot-readonly", False); print("1" if v else "")' < "$configdir/image.yaml")"
Copy link
Contributor

Choose a reason for hiding this comment

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

I really am not a fan of this shell pattern. We need a bash helper function.

if [ -n "${sysroot_ro}" ]; then
disk_args+=("--sysroot-ro")
fi

set -x
# Extract the target kernel config, which may inform how we build disks.
target_moduledir=$(ostree --repo="${ostree_repo}" ls "${commit}" /usr/lib/modules | grep -o '/usr/lib/modules/.*')
Expand Down
7 changes: 6 additions & 1 deletion src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Options:
--save-var-subdirs: "yes" to workaround selabel issue for RHCOS
--rootfs-size: Create the root filesystem with specified size
--boot-verity: Provide this to enable ext4 fs-verity for /boot
--sysroot-ro: Enable read-only /sysroot
--rootfs: xfs|ext4verity|luks
--no-x86-bios-partition: don't create a BIOS partition on x86_64

Expand All @@ -49,6 +50,7 @@ EOC
disk=
rootfs_size="0"
boot_verity=0
sysroot_ro=0
rootfs_type="xfs"
x86_bios_partition=1
extrakargs=""
Expand All @@ -70,6 +72,7 @@ do
--save-var-subdirs) save_var_subdirs="${1}"; shift;;
--rootfs-size) rootfs_size="${1}"; shift;;
--boot-verity) boot_verity=1;;
--sysroot-ro) sysroot_ro=1;;
--rootfs) rootfs_type="${1}" shift;;
--no-x86-bios-partition) x86_bios_partition=0;;
*) echo "${flag} is not understood."; usage; exit 10;;
Expand Down Expand Up @@ -409,7 +412,9 @@ esac
ostree config --repo $rootfs/ostree/repo set sysroot.bootloader "${bootloader_backend}"
# Opt-in to https://github.com/ostreedev/ostree/pull/1767 AKA
# https://github.com/ostreedev/ostree/issues/1265
ostree config --repo $rootfs/ostree/repo set sysroot.readonly true
if [ "${sysroot_ro}" = 1 ]; then
ostree config --repo $rootfs/ostree/repo set sysroot.readonly true
fi

touch $rootfs/boot/ignition.firstboot

Expand Down