Modern Apps git

MAOS.git

Public
git clone https://git.maproj.org/MAOS.git
main ▾

MAOS.git / patches / script.patch

script.patch75 lines · 3.5 KiBRaw
1diff --git a/generate-release.sh b/generate-release.sh
2index 736dfd1..2524ed6 100755
3--- a/generate-release.sh
4+++ b/generate-release.sh
5@@ -6,6 +6,30 @@ source "$(dirname ${BASH_SOURCE[0]})/common.sh"
6
7 [[ $# -eq 2 ]] || user_error "expected two arguments: DEVICE BUILD_NUMBER"
8
9+# MAOS: progress reporting. progress_bar TOTAL PATTERN CMD... runs CMD, counts output
10+# lines matching PATTERN, and redraws a single [####----] N/TOTAL line on stderr while
11+# passing all output through (nothing hidden).
12+progress_bar() {
13+ local total="$1" pattern="$2"; shift 2
14+ "$@" 2>&1 | awk -v total="$total" -v pat="$pattern" '
15+ { print > "/dev/stderr"; fflush("/dev/stderr") }
16+ $0 ~ pat {
17+ n++; pct = int(50 * n / total); if (pct > 50) pct = 50;
18+ bar = sprintf("%*s", pct, ""); gsub(/ /, "#", bar);
19+ pad = sprintf("%*s", 50 - pct, ""); gsub(/ /, "-", pad);
20+ printf "\r [MAOS] [%s%s] %d/%d", bar, pad, n, total > "/dev/stderr";
21+ }
22+ END { printf "\n" > "/dev/stderr" }'
23+}
24+count_signables() {
25+ unzip -l "$1" 2>/dev/null | grep -cE "\.(apk|apex)$"
26+}
27+
28+# MAOS: stage logging + optional OTA skip. SKIP_OTA=1 skips ota_from_target_files +
29+# generate-metadata (saves ~15-20 min) for local flash-test builds; the install/factory
30+# images are unaffected. Default (unset/empty) builds everything as upstream.
31+stage() { echo ""; echo "===== [generate-release] STAGE $1/4: $2 ($(date -u +%H:%M:%S)) ====="; }
32+
33 chrt -b -p 0 $$
34
35 DEVICE=$1
36@@ -73,7 +97,10 @@ fi
37 AVB_PKMD="$KEY_DIR/avb_pkmd.bin"
38 AVB_ALGORITHM=SHA256_RSA4096
39
40-sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --avb_vbmeta_algorithm $AVB_ALGORITHM \
41+stage 1 "sign target_files (APK+APEX, RSA-4096)"
42+_sign_total=$(count_signables "$TARGET_FILES_INPUT")
43+echo " [MAOS] signing ~$_sign_total APK/APEX files..."
44+progress_bar "$_sign_total" "^ signing:" sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --avb_vbmeta_algorithm $AVB_ALGORITHM \
45 --extra_apks com.android.adbd.apex="$KEY_DIR/releasekey" \
46 --extra_apex_payload_key com.android.adbd.apex="$KEY_DIR/avb.pem" \
47 --extra_apks AdServicesApk.apk="$KEY_DIR/releasekey" \
48@@ -179,10 +206,16 @@ sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --av
49 --extra_apex_payload_key com.google.pixel.camera.hal.apex="$KEY_DIR/avb.pem" \
50 $TARGET_FILES_INPUT $TARGET_FILES
51
52-ota_from_target_files -k "$KEY_DIR/releasekey" $OTA_ARGS $TARGET_FILES \
53- $DEVICE-ota_update-$BUILD_NUMBER.zip
54-script/generate-metadata $DEVICE-ota_update-$BUILD_NUMBER.zip
55+if [[ -n "${SKIP_OTA:-}" ]]; then
56+ stage 2 "OTA SKIPPED (SKIP_OTA set) - no ota_update zip, no metadata"
57+else
58+ stage 2 "full OTA (block diff, slowest single step)"
59+ ota_from_target_files -k "$KEY_DIR/releasekey" $OTA_ARGS $TARGET_FILES \
60+ $DEVICE-ota_update-$BUILD_NUMBER.zip
61+ script/generate-metadata $DEVICE-ota_update-$BUILD_NUMBER.zip
62+fi
63
64+stage 3 "device images (per-partition + super)"
65 img_from_target_files $TARGET_FILES $DEVICE-img-$BUILD_NUMBER.zip
66
67 source device/common/generate-factory-images-common.sh
68@@ -195,6 +228,7 @@ fi
69
70 # Second arg to optimize-factory-image is the name of outer zip directory.
71 # Output zip name defaults to <outer zip dir name>.zip
72+stage 4 "factory + install zips (super split for flashing)"
73 fastboot -S $MAX_DOWNLOAD_SIZE optimize-factory-image $DEVICE-factory-$BUILD_NUMBER.zip $DEVICE-install-$BUILD_NUMBER
74
75 if [[ -f "$KEY_DIR/id_ed25519" ]]; then