From a9d3535c9b5198750e3805571e143c9e911ec8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 11 Jun 2026 16:19:38 +0000 Subject: [PATCH] enhance archive metadata --- scripts/generate-tarball.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/generate-tarball.sh b/scripts/generate-tarball.sh index 6f51994..10fb1b7 100755 --- a/scripts/generate-tarball.sh +++ b/scripts/generate-tarball.sh @@ -27,7 +27,7 @@ tmp_dir=$(mktemp -d) trap 'rm -rf "$tmp_dir"' EXIT # Generate the file list from the TARGET_CHROOT, excluding files and directories in the BUTANE_BLOCKLIST -declare -a files_to_include=() +declare -A files_to_include=() filelist_file="$tmp_dir/filelist.txt" for path in $(find "$TARGET_CHROOT"); do rel_path="${path#$TARGET_CHROOT}" @@ -45,7 +45,7 @@ for path in $(find "$TARGET_CHROOT"); do echo "${rel_path#/}" >> "$filelist_file" # Although, the absolute path is stored in the metadata file. - files_to_include+=("$rel_path") + files_to_include["$rel_path"]="$(stat --format='%u %g %a %F' "$path")" done # Generate metadata.json @@ -71,8 +71,23 @@ else fi if [ "${#files_to_include[@]}" -gt 0 ]; then echo "files:" >> "$metadata_file" - for file in "${files_to_include[@]}"; do - echo "- $file" + for file in "${!files_to_include[@]}"; do + read -r owner group mode type <<< "${files_to_include[$file]}" + if [ "$type" == "directory" ]; then + type="dir" + elif [ "$type" == "regular file" ]; then + type="file" + else + echo "Unsupported file type: $type for file $file" + exit 1 + fi + cat <> "$metadata_file" else echo "files: []" >> "$metadata_file"