Make .mpk (zip) app bundles deterministic

This commit is contained in:
Thomas Farstrike
2025-06-28 08:59:59 +02:00
parent 9f0768f3df
commit 914e5d4e08
+20 -18
View File
@@ -19,24 +19,26 @@ echo "[" | tee -a "$outputjson"
# currently, this script doesn't purge unnecessary information from the manifests, such as activities
for apprepo in internal_filesystem/apps internal_filesystem/builtin/apps; do
echo "Listing apps in $apprepo"
ls -1 "$apprepo" | while read appdir; do
echo "Bundling $apprepo/$appdir"
pushd "$apprepo"/"$appdir"
manifest=META-INF/MANIFEST.JSON
version=$( jq -r '.version' "$manifest" )
cat "$manifest" | tee -a "$outputjson"
echo -n "," | tee -a "$outputjson"
thisappdir="$output"/apps/"$appdir"
mkdir -p "$thisappdir"
mkdir -p "$thisappdir"/mpks
mkdir -p "$thisappdir"/icons
mpkname="$thisappdir"/mpks/"$appdir"_"$version".mpk
echo "Creating $mpkname"
zip -r0 "$mpkname" .
cp res/mipmap-mdpi/icon_64x64.png "$thisappdir"/icons/"$appdir"_"$version"_64x64.png
popd
done
echo "Listing apps in $apprepo"
ls -1 "$apprepo" | while read appdir; do
echo "Bundling $apprepo/$appdir"
pushd "$apprepo"/"$appdir"
manifest=META-INF/MANIFEST.JSON
version=$( jq -r '.version' "$manifest" )
cat "$manifest" | tee -a "$outputjson"
echo -n "," | tee -a "$outputjson"
thisappdir="$output"/apps/"$appdir"
mkdir -p "$thisappdir"
mkdir -p "$thisappdir"/mpks
mkdir -p "$thisappdir"/icons
mpkname="$thisappdir"/mpks/"$appdir"_"$version".mpk
echo "Setting file modification times to a fixed value..."
find . -type f -exec touch -t 202501010000.00 {} \;
echo "Creating $mpkname with deterministic file order..."
find . -type f | sort | TZ=CET zip -X "$mpkname" -@
cp res/mipmap-mdpi/icon_64x64.png "$thisappdir"/icons/"$appdir"_"$version"_64x64.png
popd
done
done
# remove the last , to have valid json: