[Google Pixel 6 Pro] FireRattus:
This code can only possibly be used if you have already successfully built graphene and used AVBRoot for patching

You will also need to look through the entire script and modify it to your needs, not just the part at the top, although I have tried to make it easier

#!/bin/bash
# DO NOT USE THIS SCRIPT WITHOUT MODIFICATION AND UNDERSTANDING WHAT EVERY SINGLE LINE WILL DO
# THIS IS MEANT ONLY AS A REFERENCE AND EXAMPLE, BE CAREFUL
# UPDATE THESE FOR NEW VERSIONS OR DIFFERENT DEVICES
SOURCEROOT=~/grapheneraviole
DEVICE=raven
DEVICEU=Raven
BUILD_ID=TQ3A.230705.001
BUILD_NUM=2023071100
BUILD_NUMBER=2023071100
DECRYPKEY=PASSWORD-For-Keys
AVBHOME=~/AVBRoot/avbroot/
MAGISK=~/AVBRoot/avbroot/Magisk-v26.1.apk
MAGISK_PREINIT_DEVICE=metadata
BUILD_DIR=~/Desktop/GrapheneOS/Builds
echo Enter password for sudo prompts
read -p "Sudo: " supass
echo cd to build dir
cd $SOURCEROOT
echo initialize repo
repo init -u https://github.com/GrapheneOS/platform_manifest.git -b refs/tags/$BUILD_NUMBER
echo sync repo build sources slowly
repo sync -j1 --force-sync
echo create a working build environment.
source script/envsetup.sh
echo build required files aapt2
m aapt2
echo skip downloading latest vendor files assumes already downloaded
# download matching OTA and Factory builds from https://developers.google.com/android/images & https://developers.google.com/android/ota MANUALLY PLACE IN vendor/adevtool/dl/ Or Uncomment next line
# vendor/adevtool/bin/run download vendor/adevtool/dl/ -d $DEVICE -b $BUILD_ID -t factory ota
echo Extracting vendor files
echo $supass | sudo -S vendor/adevtool/bin/run generate-all vendor/adevtool/config/$DEVICE.yml -c vendor/state/$DEVICE.json -s vendor/adevtool/dl/$DEVICE-${BUILD_ID,,}-*.zip
echo $supass | sudo -S chown -R $(logname):$(logname) vendor/{google_devices,adevtool}
vendor/adevtool/bin/run ota-firmware vendor/adevtool/config/$DEVICE.yml -f vendor/adevtool/dl/$DEVICE-ota-${BUILD_ID,,}-*.zip
echo Remove Old Build files verbose
echo $supass | sudo -S rm -r -v out
echo SETUP BUILD ENVIRONMENT
source script/envsetup.sh
echo export build number to match release
export BUILD_NUMBER=$BUILD_NUM
echo Choose release $DEVICE, user, just wait
choosecombo release $DEVICE user
echo Start Build of target files package
m vendorbootimage target-files-package -j8
# I do this twice because sometimes it fails the first attempt but works the second with no changes, Idk why
m vendorbootimage target-files-package -j8
echo BUILD TOOLS needed to generate OTA update packages:
m otatools-package
echo BUILD SIGNED RELEASE with the release.sh script, requires password if set
echo $DECRYPKEY | script/release.sh $DEVICE
echo BUILD COMPLETE
echo now for avbroot patching
cd $AVBHOME
python avbroot.py \
patch \
--input $SOURCEROOT/out/release-$DEVICE-*/$DEVICE-ota_update-*.zip \
--privkey-avb Keys/Graphene/avb.key \
--privkey-ota Keys/Graphene/ota.key \
--cert-ota Keys/Graphene/ota.crt \
--magisk $MAGISK \
--magisk-preinit-device $MAGISK_PREINIT_DEVICE
echo clean old TempOut folder and recreate folder structure
echo $supass | sudo -S rm -r -v $BUILD_DIR/TempOut/
mkdir $BUILD_DIR/TempOut/
mkdir $BUILD_DIR/TempOut/$DEVICEU/
mkdir $BUILD_DIR/TempOut/Oriole/
echo Copy Completed Factory Build
cp $SOURCEROOT/out/release-$DEVICE-*/$DEVICE-factory-*.zip $BUILD_DIR/TempOut
echo Copy Completed OTA Build
cp $SOURCEROOT/out/release-$DEVICE-*/$DEVICE-ota_update-*.zip $BUILD_DIR/TempOut
echo Copy Completed Patched OTA Build
cp $SOURCEROOT/out/release-$DEVICE-*/$DEVICE-ota_update-*.zip.patched $BUILD_DIR/TempOut
echo Extract Patched files to patch factory image
python avbroot.py \
extract \
--input $SOURCEROOT/out/release-$DEVICE-*/$DEVICE-ota_update-*.zip.patched \
--directory $BUILD_DIR/TempOut/$DEVICEU
echo testing replacing zip files
cd $BUILD_DIR/TempOut/
echo Unzip Factory Build
unzip $DEVICE-factory-$BUILD_NUMBER.zip
echo Add Correct AVB Key to Extracted files
cp ../avb_pkmd.bin $DEVICE-factory-$BUILD_NUMBER/avb_pkmd.bin
cd $DEVICEU
echo Replace old image files with magisk patched files
zip -u ../$DEVICE-factory-$BUILD_NUMBER/image-$DEVICE-$BUILD_NUMBER.zip *
cd ..
echo zip together all patched and updated files
zip -r GrapheneOS-$DEVICE-factory-patched-$BUILD_NUMBER.zip $DEVICE-factory-$BUILD_NUMBER/*
echo Remove unrequired extracted files
rm -r -v $DEVICE-factory-$BUILD_NUMBER
echo Rename Patched OTA
mv $DEVICE-ota_update-$BUILD_NUMBER.zip.patched GrapheneOS-$DEVICE-ota_update-$BUILD_NUMBER.zip.patched
echo CD to Completed builds dir
cd $BUILD_DIR/$DEVICEU/GrapheneRoms/
echo Creeate new folders to place new files
mkdir $BUILD_NUMBER
mkdir $BUILD_NUMBER/Patched
echo Copy all new completed and patched builds files
cp $BUILD_DIR/TempOut/$DEVICE-factory-$BUILD_NUMBER.zip $BUILD_NUMBER/
cp $BUILD_DIR/TempOut/GrapheneOS-$DEVICE-factory-patched-$BUILD_NUMBER.zip $BUILD_NUMBER/Patched/
cp $BUILD_DIR/TempOut/$DEVICE-ota_update-$BUILD_NUMBER.zip $BUILD_NUMBER/
cp $BUILD_DIR/TempOut/GrapheneOS-$DEVICE-ota_update-$BUILD_NUMBER.zip.patched $BUILD_NUMBER/Patched/
echo DONE RAVEN
read -p "Everything is done, press enter to exit"
exit