Skip to content

Commit a4ec7f5

Browse files
committed
Use find -print0 and xargs -0 to fix file hashing with special character filenames
Example: ``` ++ find images/hook-embedded -type f -not -type l -print ++ LC_ALL=C ++ sort ++ xargs sha256sum ++ sha256sum ++ cut '-d ' -f1 sha256sum: images/hook-embedded/images/overlay2/4f2b976a728e2f978ec5a0728e7a7de5ac8e86d05424567038829628a23a0787/diff/nix/store/q94x70qac6cnly6w60mlgfkaa8npk9xw-systemd-257.5/example/systemd/system/system-systemdx2dcryptsetup.slice: No such file or directory ``` Signed-off-by: Zubarev Alexander <[email protected]>
1 parent 0182cbc commit a4ec7f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bash/hook-lk-containers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function build_hook_linuxkit_container() {
2424
# Lets hash the contents of the directory and use that as a tag
2525
declare container_files_hash
2626
# NOTE: linuxkit containers must be in the images/ directory
27-
container_files_hash="$(find "${container_base_dir}/${container_dir}" -type f -print | LC_ALL=C sort | xargs sha256sum | sha256sum | cut -d' ' -f1)"
27+
container_files_hash="$(find "${container_base_dir}/${container_dir}" -type f -print0 | LC_ALL=C sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
2828
declare container_files_hash_short="${container_files_hash:0:8}"
2929

3030
declare container_oci_ref="${HOOK_LK_CONTAINERS_OCI_BASE}${container_dir}:${container_files_hash_short}-${DOCKER_ARCH}"

0 commit comments

Comments
 (0)