-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathbundle_apps.sh
More file actions
executable file
·76 lines (66 loc) · 3.24 KB
/
bundle_apps.sh
File metadata and controls
executable file
·76 lines (66 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
output=../apps/
outputjson="$output"/app_index.json
output=$(readlink -f "$output")
outputjson=$(readlink -f "$outputjson")
app_store_base_url="${APPS_BASE_URL:-https://apps.micropythonos.com}"
#mpks="$output"/mpks/
#icons="$output"/icons/
mkdir -p "$output"
#mkdir -p "$mpks"
#mkdir -p "$icons"
#rm "$output"/*.mpk
#rm "$output"/*.png
rm -f "$outputjson"
# These apps are for testing, or aren't ready yet:
# com.quasikili.quasidoodle doesn't work on touch screen devices AND has the wrong download URL
# com.micropythonos.errortest is an intentional bad app for testing (caught by tests/test_graphical_launch_all_apps.py)
# com.micropythonos.nostr isn't ready for release yet
blacklist="com.quasikili.quasidoodle com.micropythonos.errortest com.micropythonos.nostr"
blacklist="$blacklist com.micropythonos.doom_launcher com.micropythonos.duke_launcher com.micropythonos.retrocore_launcher" # not ready yet
blacklist="$blacklist com.micropythonos.doom com.micropythonos.breakout" # not ready yet
blacklist="$blacklist cz.ucw.pavel.calendar cz.ucw.pavel.cellular cz.ucw.pavel.compass cz.ucw.pavel.weather" # not ready yet
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
for apprepo in internal_filesystem/apps; do
echo "Listing apps in $apprepo"
ls -1 "$apprepo" | sort | while read appdir; do
if echo "$blacklist" | grep "$appdir"; then
echo "Skipping $appdir because it's in blacklist $blacklist"
else
echo "Bundling $apprepo/$appdir"
pushd "$apprepo"/"$appdir"
manifest=META-INF/MANIFEST.JSON
version=$( jq -r '.version' "$manifest" )
result=$?
if [ $result -ne 0 ]; then
echo "Failed to parse $apprepo/$appdir/$manifest !"
exit 1
fi
jq --arg appdir "$appdir" --arg version "$version" --arg base_url "$app_store_base_url" '. + {
icon_url: ($base_url + "/apps/" + $appdir + "/icons/" + $appdir + "_" + $version + "_64x64.png"),
download_url: ($base_url + "/apps/" + $appdir + "/mpks/" + $appdir + "_" + $version + ".mpk")
}' "$manifest" | tee -a "$outputjson"
result=$?
if [ $result -ne 0 ]; then
echo "Failed to enrich $apprepo/$appdir/$manifest !"
exit 1
fi
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 | grep -v ".git/" | sort | TZ=CET zip -X -r0 "$mpkname" -@
cp res/mipmap-mdpi/icon_64x64.png "$thisappdir"/icons/"$appdir"_"$version"_64x64.png
popd
fi
done
done
# remove the last , to have valid json:
truncate -s -1 "$outputjson"
echo "]" | tee -a "$outputjson"