75 lines
2.6 KiB
Bash
Executable File
75 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Copyright (C) 2018-20 Akhil Narang
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
# AOSiP upload script
|
|
|
|
# shellcheck disable=SC2086,SC2029
|
|
# SC2086: Double quote to prevent globbing and word splitting
|
|
# SC2029: Note that, unescaped, this expands on the client side.
|
|
|
|
export TZ=UTC
|
|
DATE="$(date +%Y%m%d)"
|
|
OMNI_VERSION="omni-13-${DATE}-cheetah-gapps"
|
|
SIGNED_OTAPACKAGE="${OMNI_VERSION}.zip"
|
|
INSTALLIMG=("boot.img" "dtbo.img" "init_boot.img" "vendor_boot.img" "vendor_kernel_boot.img")
|
|
INSTALLZIP="${OMNI_VERSION}-bootkit.zip"
|
|
SIGNED_TARGET_FILES="signed-target_files.zip"
|
|
SIGNED_IMAGE_PACKAGE="${OMNI_VERSION}-fastboot.zip"
|
|
OUT="out/target/product/cheetah"
|
|
TEMP_DIR=$(mktemp -d)
|
|
UPLOAD="./upload_assets"
|
|
mkdir -pv "$UPLOAD"
|
|
if [[ $WITH_GAPPS ]]; then
|
|
SIGNING_FLAGS="-e CronetDynamite.apk= -e DynamiteLoader.apk= -e DynamiteModulesA.apk= -e AdsDynamite.apk= -e DynamiteModulesC.apk= -e MapsDynamite.apk= -e GoogleCertificates.apk= -e AndroidPlatformServices.apk= -e PrebuiltGmsCoreSc.apk= -e MlkitBarcodeUIPrebuilt.apk= -e VisionBarcodePrebuilt.apk="
|
|
fi
|
|
|
|
echo "Signing target_files APKs"
|
|
sign_target_files_apks -o -d ~/.android-certs $SIGNING_FLAGS "$OUT"/obj/PACKAGING/target_files_intermediates/omni_cheetah-target_files-eng.*.zip "$UPLOAD/$SIGNED_TARGET_FILES" || exit 1
|
|
|
|
if [[ $WITH_OTA ]]; then
|
|
echo "Generating signed otapackage"
|
|
ota_from_target_files -k ~/.android-certs/releasekey "$UPLOAD/$SIGNED_TARGET_FILES" "$UPLOAD/$SIGNED_OTAPACKAGE" || exit 1
|
|
fi
|
|
|
|
echo "Generating signed images package"
|
|
img_from_target_files "$UPLOAD/$SIGNED_TARGET_FILES" "$UPLOAD/$SIGNED_IMAGE_PACKAGE" || exit 1
|
|
|
|
if [[ $WITH_BOOTKIT ]]; then
|
|
echo "Setting up bootkit"
|
|
TEMP_DIR=$(mktemp -d)
|
|
for IMAGE in "${INSTALLIMG[@]}"; do
|
|
7z e "$UPLOAD/$SIGNED_TARGET_FILES" IMAGES/"$IMAGE" -so > "$TEMP_DIR/$IMAGE"
|
|
done
|
|
find "$TEMP_DIR" -print | zip -j "$UPLOAD/$INSTALLZIP" -@
|
|
rm -vrf "${TEMP_DIR:?}/"*
|
|
fi
|
|
|
|
cd $UPLOAD || exit
|
|
|
|
if [[ $WITH_MD5 ]]; then
|
|
echo "Generating MD5 checksums"
|
|
md5sum {"$SIGNED_OTAPACKAGE","$SIGNED_IMAGE_PACKAGE","$INSTALLZIP"} >> "$OMNI_VERSION-md5sums.txt"
|
|
fi
|
|
|
|
echo "Removing old zips from webserver"
|
|
ssh oizys 'rm -rf /srv/www/cheetah/omni-*.*'
|
|
echo "Uploading to webserver and gdrive"
|
|
for FILE in "$OMNI_VERSION"{,-*}.zip; do
|
|
scp $FILE cirrus:/srv/www/cheetah/
|
|
rclone copy -P --drive-chunk-size=256M $FILE gdrive:/uploads/cheetah/
|
|
done
|
|
cd - || exit
|
|
ls -lah $UPLOAD
|
|
read -p "Remove ./upload (y/n)? " answer
|
|
case ${answer:0:1} in
|
|
y|Y )
|
|
rm -rfv $UPLOAD
|
|
;;
|
|
* )
|
|
exit
|
|
;;
|
|
esac
|
|
|
|
# dialog --yesno "Remove ./upload (build zips)" 20 60 && rm -rfv $UPLOAD
|