From 6fcaf874d7781d91efceec671229375f1145aa9a Mon Sep 17 00:00:00 2001 From: Robert Monnet Date: Wed, 24 Jun 2026 13:19:36 -0400 Subject: [PATCH] Add a script to regenerate the manifest automatically This script rebuild the manifest based on the content of the disk/ directory. The files under disk are listed in alphabetical order. The version has to be specified as a parameter to the script. --- build_disk_manifest.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 build_disk_manifest.sh diff --git a/build_disk_manifest.sh b/build_disk_manifest.sh new file mode 100755 index 0000000..af2154a --- /dev/null +++ b/build_disk_manifest.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This script build disk/manifest.json from the list of files located in the ./disk/ +# directory. + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +version="$1" +disk_dir="./disk" +manifest="$disk_dir/manifest.json" + +first_item=true + +echo "{" > "$manifest" +echo " \"_version\": \"$version\"," >> "$manifest" + +while IFS= read -r -d '' file; do + filename=$(basename "$file") + if [[ "$filename" == manifest.json* ]]; then + continue + fi + if [ "$first_item" = true ]; then + first_item=false + else + echo "," >> "$manifest" + fi + file_loc="${file#$disk_dir}" + printf ' "%s": "%s"' "$file_loc" "${file_loc#/}" >> "$manifest" +done < <(find "$disk_dir" -type f -print0 | sort -z) + +echo "" >> "$manifest" +echo "}" >> "$manifest"