-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added package creation and flash script
- Loading branch information
1 parent
510104e
commit cdcce0f
Showing
7 changed files
with
299 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2023 Alexander Wolz <mail@alexanderwolz.de> | ||
|
||
|
||
function add() { | ||
local ELEMENT=$ANDROID_PRODUCT_OUT/$1 | ||
if [ -f $ELEMENT ] || [ -d $ELEMENT ]; then | ||
if [ ! -z $2 ]; then | ||
cp -rf $ELEMENT "$PACKAGE_IMAGE_DIR/$2" | ||
else | ||
cp -rf $ELEMENT "$PACKAGE_IMAGE_DIR/$1" | ||
fi | ||
else | ||
echo "Skipping - No such file: $1" | ||
fi | ||
} | ||
|
||
echo "" | ||
echo "---------------------------------------------------------------" | ||
echo "Create product package Tool" | ||
echo "---------------------------------------------------------------" | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
source "$SCRIPT_DIR/common.sh" || exit 1 | ||
|
||
DEVICE_NAMES=($(ls $LOCAL_AOSP_SYNCH)) | ||
if [ ${#DEVICE_NAMES[@]} == 0 ]; then | ||
echo "There are no devices available at $LOCAL_AOSP_SYNCH" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -z $1 ]; then | ||
DEVICE_NAME=$1 | ||
else | ||
echo "---------------------------------------------------------------" | ||
echo "Reading product device list .." | ||
chooseDevice "${DEVICE_NAMES[@]}" || exit 1 | ||
fi | ||
|
||
if [ -z $DEVICE_NAME ]; then | ||
echo "Something's wrong, try again" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
ANDROID_PRODUCT_OUT="$LOCAL_AOSP_SYNCH/$DEVICE_NAME" | ||
export ANDROID_PRODUCT_OUT | ||
|
||
echo "---------------------------------------------------------------" | ||
echo "Using product: $DEVICE_NAME" | ||
echo "---------------------------------------------------------------" | ||
|
||
echo "" | ||
while true; do | ||
read -p "Do you wish to create package for '$DEVICE_NAME'? [y/n] " selection | ||
case $selection in | ||
[y]*) break ;; | ||
[n]*) exit ;; | ||
*) echo "Please answer y or n." ;; | ||
esac | ||
done | ||
|
||
BUILD_PROPERTIES_FILE="$ANDROID_PRODUCT_OUT/system/build.prop" | ||
|
||
if [ ! -f $BUILD_PROPERTIES_FILE ]; then | ||
echo "Missing file $BUILD_PROPERTIES_FILE" | ||
exit 1 | ||
fi | ||
|
||
BUILD_PROPERTIES=$(cat $BUILD_PROPERTIES_FILE) || exit 1 | ||
|
||
API_LEVEL=$(echo "$BUILD_PROPERTIES" | grep ro.build.version.sdk= | cut -d'=' -f2) || exit 1 | ||
BUILD_FLAVOR=$(echo "$BUILD_PROPERTIES" | grep ro.build.flavor= | cut -d'=' -f2) || exit 1 | ||
PRODUCT_NAME=$(echo "$BUILD_PROPERTIES"| grep ro.build.product= | cut -d'=' -f2) || exit 1 | ||
ANDROID_VERSION=$(echo "$BUILD_PROPERTIES" | grep ro.system.build.version.release= | cut -d'=' -f2) || exit 1 | ||
BUILD_TYPE=$(echo "$BUILD_PROPERTIES" | grep ro.system.build.type= | cut -d'=' -f2) || exit 1 | ||
BUILD_ID=$(echo "$BUILD_PROPERTIES" | grep ro.system.build.id= | cut -d'=' -f2) || exit 1 | ||
|
||
NOW=$(date +"%Y%m%d-%H%M%S") | ||
BEGIN=$(date -u +%s) | ||
|
||
PACKAGE_ROOT=$PARENT_DIR"/packages" | ||
PACKAGE_DIR=$PACKAGE_ROOT"/"$BUILD_FLAVOR"_android"$ANDROID_VERSION"_"$NOW | ||
PACKAGE_IMAGE_DIR=$PACKAGE_DIR"/images-"$BUILD_FLAVOR"_android"$ANDROID_VERSION | ||
|
||
PACKAGE_IMAGE_ZIP=$PACKAGE_IMAGE_DIR.zip | ||
PACKAGE_DIR_ZIP=$PACKAGE_DIR.zip | ||
|
||
mkdir -p $PACKAGE_IMAGE_DIR || exit 1 | ||
|
||
echo "Checking files .." | ||
|
||
FLASH_FILE=$PACKAGE_DIR/flash.sh | ||
cp $SCRIPT_DIR/flash_product_zip.sh $FLASH_FILE | ||
sed -i '' -e "s/ZIP_FILE=\$1/ZIP_FILE=$(basename $PACKAGE_IMAGE_ZIP)/g" $FLASH_FILE | ||
chmod +x $FLASH_FILE | ||
|
||
BOOTLOADER="$ANDROID_PRODUCT_OUT/bootloader.img" | ||
if [ -f $BOOTLOADER ]; then | ||
echo "Adding bootloader.img" | ||
cp $BOOTLOADER $PACKAGE_DIR || exit 1 | ||
fi | ||
|
||
add system/build.prop build.prop | ||
add android-info.txt | ||
add boot.img | ||
add dtbo.img | ||
add init_boot.img | ||
add product.img | ||
add pvmfw.img | ||
add super_empty.img | ||
add system_dlkm.img | ||
add system_ext.img | ||
add system_other.img | ||
add system.img | ||
add vbmeta_system.img | ||
add vbmeta_vendor.img | ||
add vbmeta.img | ||
add vendor_boot.img | ||
add vendor_dlkm.img | ||
add vendor_kernel_boot.img | ||
add vendor.img | ||
add vendor/ #TODO merge this into image | ||
|
||
echo "Zipping images .." | ||
pushd $PACKAGE_IMAGE_DIR > /dev/null | ||
zip -r $PACKAGE_IMAGE_ZIP . || exit 1 | ||
popd > /dev/null | ||
|
||
#zip -r -j $PACKAGE_IMAGE_ZIP $PACKAGE_IMAGE_DIR/* || exit 1 | ||
rm -rf $PACKAGE_IMAGE_DIR || exit 1 | ||
|
||
echo "Zipping all content .." | ||
zip -j $PACKAGE_DIR_ZIP $PACKAGE_DIR/* || exit 1 | ||
|
||
echo "Cleaning up .." | ||
rm -rf $PACKAGE_DIR | ||
|
||
|
||
DURATION=$(($(date -u +%s)-$BEGIN)) | ||
echo "---------------------------------------------------------------" | ||
echo "Package can be found at $PACKAGE_DIR_ZIP" | ||
echo "---------------------------------------------------------------" | ||
echo "Finished - took $(($DURATION / 60)) minutes and $(($DURATION % 60)) seconds" | ||
echo "---------------------------------------------------------------" | ||
echo "" #newline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2023 Alexander Wolz <mail@alexanderwolz.de> | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
#copied from The Android Open Source Project | ||
if ! [ $($(which fastboot) --version | grep "version" | cut -c18-23 | sed 's/\.//g' ) -ge 3301 ]; then | ||
echo "fastboot too old; please download the latest version at https://developer.android.com/studio/releases/platform-tools.html" | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "---------------------------------------------------------------" | ||
echo "Flashing tool" | ||
echo "---------------------------------------------------------------" | ||
|
||
ZIP_FILE=$1 | ||
|
||
if [ -z $ZIP_FILE ]; then | ||
echo "Please specify zip file" | ||
exit 1 | ||
fi | ||
|
||
while true; do | ||
read -p "Do you wish to flash? [y/n] " selection | ||
case $selection in | ||
[y]*) break ;; | ||
[n]*) exit ;; | ||
*) echo "Please answer y or n." ;; | ||
esac | ||
done | ||
|
||
adb reboot bootloader | ||
|
||
if [ -f "$SCRIPT_DIR/bootloader.img" ]; then | ||
fastboot flash bootloader "$SCRIPT_DIR/bootloader.img" | ||
fastboot reboot-bootloader | ||
sleep 5 | ||
fi | ||
|
||
fastboot -w update $ZIP_FILE | ||
|
||
|
||
|
||
# now comes the tricky part with vendor files.. | ||
|
||
echo "waiting for device to come up .." | ||
adb wait-for-device | ||
|
||
echo "setting adb root .." | ||
adb root | ||
|
||
VERITY_MODE=$(adb shell getprop ro.boot.veritymode) | ||
if [ "$VERITY_MODE" == "enabled" ]; then | ||
echo "disabling verity .." | ||
adb disable-verity | ||
sleep 3 | ||
|
||
echo "rebooting .." | ||
adb reboot | ||
|
||
echo "waiting for device to come up .." | ||
adb wait-for-device | ||
|
||
echo "setting adb root .." | ||
adb root | ||
|
||
sleep 2 | ||
else | ||
echo "Verity is already disabled, skipping" | ||
fi | ||
|
||
echo "Remounting .." | ||
adb remount | ||
if [ "$?" -ne 0 ]; then | ||
echo "Committing checkpoint .." | ||
adb shell vdc checkpoint commitChanges | ||
adb remount | ||
|
||
echo "rebooting .." | ||
adb reboot | ||
|
||
echo "waiting for device to come up .." | ||
adb wait-for-device | ||
|
||
echo "setting adb root .." | ||
adb root | ||
|
||
echo "Try remount again .." | ||
adb remount | ||
fi | ||
|
||
#extracting vendor from zip to tmp folder | ||
ANDROID_PRODUCT_OUT_TMP="$SCRIPT_DIR/.product_out_tmp" | ||
rm -rf $ANDROID_PRODUCT_OUT_TMP | ||
mkdir -p $ANDROID_PRODUCT_OUT_TMP | ||
unzip $ZIP_FILE "vendor/*" -d "$ANDROID_PRODUCT_OUT_TMP" > /dev/null || exit 1 | ||
export ANDROID_PRODUCT_OUT=$ANDROID_PRODUCT_OUT_TMP | ||
|
||
echo "Syncing vendor partition .." | ||
adb sync vendor | ||
|
||
echo "Rebooting .." | ||
adb reboot || exit 1 | ||
|
||
rm -rf $ANDROID_PRODUCT_OUT_TMP | ||
|
||
echo "done" |
Oops, something went wrong.