Skip to content

Commit 914e5d4

Browse files
Make .mpk (zip) app bundles deterministic
1 parent 9f0768f commit 914e5d4

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

scripts/bundleapps.sh

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ echo "[" | tee -a "$outputjson"
1919
# currently, this script doesn't purge unnecessary information from the manifests, such as activities
2020

2121
for apprepo in internal_filesystem/apps internal_filesystem/builtin/apps; do
22-
echo "Listing apps in $apprepo"
23-
ls -1 "$apprepo" | while read appdir; do
24-
echo "Bundling $apprepo/$appdir"
25-
pushd "$apprepo"/"$appdir"
26-
manifest=META-INF/MANIFEST.JSON
27-
version=$( jq -r '.version' "$manifest" )
28-
cat "$manifest" | tee -a "$outputjson"
29-
echo -n "," | tee -a "$outputjson"
30-
thisappdir="$output"/apps/"$appdir"
31-
mkdir -p "$thisappdir"
32-
mkdir -p "$thisappdir"/mpks
33-
mkdir -p "$thisappdir"/icons
34-
mpkname="$thisappdir"/mpks/"$appdir"_"$version".mpk
35-
echo "Creating $mpkname"
36-
zip -r0 "$mpkname" .
37-
cp res/mipmap-mdpi/icon_64x64.png "$thisappdir"/icons/"$appdir"_"$version"_64x64.png
38-
popd
39-
done
22+
echo "Listing apps in $apprepo"
23+
ls -1 "$apprepo" | while read appdir; do
24+
echo "Bundling $apprepo/$appdir"
25+
pushd "$apprepo"/"$appdir"
26+
manifest=META-INF/MANIFEST.JSON
27+
version=$( jq -r '.version' "$manifest" )
28+
cat "$manifest" | tee -a "$outputjson"
29+
echo -n "," | tee -a "$outputjson"
30+
thisappdir="$output"/apps/"$appdir"
31+
mkdir -p "$thisappdir"
32+
mkdir -p "$thisappdir"/mpks
33+
mkdir -p "$thisappdir"/icons
34+
mpkname="$thisappdir"/mpks/"$appdir"_"$version".mpk
35+
echo "Setting file modification times to a fixed value..."
36+
find . -type f -exec touch -t 202501010000.00 {} \;
37+
echo "Creating $mpkname with deterministic file order..."
38+
find . -type f | sort | TZ=CET zip -X "$mpkname" -@
39+
cp res/mipmap-mdpi/icon_64x64.png "$thisappdir"/icons/"$appdir"_"$version"_64x64.png
40+
popd
41+
done
4042
done
4143

4244
# remove the last , to have valid json:

0 commit comments

Comments
 (0)