Skip to content

Commit ca2f7b6

Browse files
authored
lib/generate.sh: Fix EROFS file UIDs and use compression (#176)
The EROFS mkfs invocation missed the --all-root flag to make sure that the files are owned by root regardless of the current UID during image generation. By default EROFS also doesn't compress and we can use LZ4 as a lightweight compresson option (LZMA would also work). Add the --all-root flag and the compression flag to mkfs.erofs to use UID 0 and compress the contents.
2 parents 253f4fa + 59a0cde commit ca2f7b6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/generate.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ function _generate_sysext() {
109109
announce "Creating extension image '${fname}' and generating SHA256SUM"
110110
case "$format" in
111111
btrfs)
112-
mkfs.btrfs --mixed -m single -d single --shrink --rootdir "${basedir}" "${fname}"
112+
# Note: We didn't chown to root:root, meaning that the file ownership is left as is
113+
mkfs.btrfs --mixed -m single -d single --shrink --compress zstd --rootdir "${basedir}" "${fname}"
113114
;;
114115
ext2|ext4)
115116
truncate -s "${ext_fs_size}" "${fname}"
@@ -120,7 +121,9 @@ function _generate_sysext() {
120121
mksquashfs "${basedir}" "${fname}" -all-root -noappend -xattrs-exclude '^btrfs.'
121122
;;
122123
erofs)
123-
mkfs.erofs "${fname}" "${basedir}"
124+
# Compression recommendations from https://erofs.docs.kernel.org/en/latest/mkfs.html
125+
# and forcing a zero UUID for reproducibility (maybe we could also hash the name and version)
126+
mkfs.erofs -zlz4hc,12 -C65536 -Efragments,ztailpacking -Uclear --all-root "${fname}" "${basedir}"
124127
;;
125128

126129
esac

wasmcloud.sysext/create.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function populate_sysext_root() {
3333

3434
mkdir -p "${sysextroot}/usr/bin"
3535
cp -a "wasmcloud-${rel_arch}-unknown-linux-musl" "${sysextroot}/usr/bin/wasmcloud"
36+
chmod +x "${sysextroot}/usr/bin/wasmcloud"
3637
cp -a "nats-server-${nats}-linux-${go_arch}/nats-server" "${sysextroot}/usr/bin/"
3738
}
3839
# --

0 commit comments

Comments
 (0)