Initial unified commit for Android 13, with TrebleDroid GSI target

This commit is contained in:
Andy CrossGate Yan 2022-11-11 12:24:44 +00:00
commit 1809ec0bc1
4 changed files with 232 additions and 0 deletions

31
README.md Normal file
View File

@ -0,0 +1,31 @@
## Building TrebleDroid-based LineageOS GSIs ##
Set up your environment by referring to [LineageOS Wiki](https://wiki.lineageos.org/devices/TP1803/build) (mainly "Install the build packages" and "Install the repo command").
Create a new working directory for your LineageOS build and navigate to it:
mkdir lineage-20-build-td; cd lineage-20-build-td
Initialize your LineageOS workspace:
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0
Clone both this and the patches repos:
git clone https://github.com/AndyCGYan/lineage_build_unified lineage_build_unified -b lineage-20-td
git clone https://github.com/AndyCGYan/lineage_patches_unified lineage_patches_unified -b lineage-20-td
Finally, start the build script - for example, to build for all supported archs:
bash lineage_build_unified/buildbot_unified.sh treble A64VN A64VS A64GN 64VN 64VS 64GN
Be sure to update the cloned repos from time to time!
---
Note: VNDKLite targets are generated from built images instead of source-built - refer to [sas-creator](https://github.com/AndyCGYan/sas-creator).
---
This script is also used to make device-specific and/or personal builds. To do so, understand the script, and try the `device` and `personal` keywords.

32
apply_patches.sh Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
set -e
patches="$(readlink -f -- $1)"
shopt -s nullglob
for project in $(cd $patches; echo *);do
p="$(tr _ / <<<$project |sed -e 's;platform/;;g')"
[ "$p" == build ] && p=build/make
[ "$p" == frameworks/proto/logging ] && p=frameworks/proto_logging
[ "$p" == vendor/hardware/overlay ] && p=vendor/hardware_overlay
[ "$p" == vendor/partner/gms ] && p=vendor/partner_gms
pushd $p
git clean -fdx; git reset --hard
for patch in $patches/$project/*.patch;do
if git apply --check $patch;then
git am $patch
elif patch -f -p1 --dry-run < $patch > /dev/null;then
#This will fail
git am $patch || true
patch -f -p1 < $patch
git add -u
git am --continue
else
echo "Failed applying $patch"
exit 1
fi
done
popd
done

158
buildbot_unified.sh Executable file
View File

@ -0,0 +1,158 @@
#!/bin/bash
echo ""
echo "LineageOS 20 Unified Buildbot"
echo "Executing in 5 seconds - CTRL-C to exit"
echo ""
sleep 5
if [ $# -lt 2 ]
then
echo "Not enough arguments - exiting"
echo ""
exit 1
fi
MODE=${1}
if [ ${MODE} != "device" ] && [ ${MODE} != "treble" ]
then
echo "Invalid mode - exiting"
echo ""
exit 1
fi
NOSYNC=false
PERSONAL=false
for var in "${@:2}"
do
if [ ${var} == "nosync" ]
then
NOSYNC=true
fi
if [ ${var} == "personal" ]
then
PERSONAL=true
fi
done
# Abort early on error
set -eE
trap '(\
echo;\
echo \!\!\! An error happened during script execution;\
echo \!\!\! Please check console output for bad sync,;\
echo \!\!\! failed patch application, etc.;\
echo\
)' ERR
START=`date +%s`
BUILD_DATE="$(date +%Y%m%d)"
prep_build() {
echo "Preparing local manifests"
mkdir -p .repo/local_manifests
cp ./lineage_build_unified/local_manifests_${MODE}/*.xml .repo/local_manifests
echo ""
echo "Syncing repos"
repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
echo ""
echo "Setting up build environment"
source build/envsetup.sh &> /dev/null
mkdir -p ~/build-output
echo ""
repopick 321337 -f # Deprioritize important developer notifications
repopick 321338 -f # Allow disabling important developer notifications
repopick 321339 -f # Allow disabling USB notifications
repopick 331534 -f # SystemUI: Add support to add/remove QS tiles with one tap
repopick 340916 # SystemUI: add burnIn protection
}
apply_patches() {
echo "Applying patch group ${1}"
bash ./lineage_build_unified/apply_patches.sh ./lineage_patches_unified/${1}
}
prep_device() {
:
}
prep_treble() {
apply_patches patches_treble_prerequisite
apply_patches patches_treble_td
}
finalize_device() {
:
}
finalize_treble() {
rm -f device/*/sepolicy/common/private/genfs_contexts
cd device/phh/treble
git clean -fdx
bash generate.sh lineage
cd ../../..
}
build_device() {
brunch ${1}
mv $OUT/lineage-*.zip ~/build-output/lineage-20.0-$BUILD_DATE-UNOFFICIAL-${1}$($PERSONAL && echo "-personal" || echo "").zip
}
build_treble() {
case "${1}" in
("A64VN") TARGET=a64_bvN; SECURE=true;;
("A64VS") TARGET=a64_bvS; SECURE=false;;
("A64GN") TARGET=a64_bgN; SECURE=true;;
("64VN") TARGET=arm64_bvN; SECURE=true;;
("64VS") TARGET=arm64_bvS; SECURE=false;;
("64GN") TARGET=arm64_bgN; SECURE=true;;
(*) echo "Invalid target - exiting"; exit 1;;
esac
lunch lineage_${TARGET}-userdebug
make installclean
make -j$(nproc --all) systemimage
mv $OUT/system.img ~/build-output/lineage-20.0-$BUILD_DATE-UNOFFICIAL-${TARGET}$(${SECURE} && echo "-secure" || echo "")$(${PERSONAL} && echo "-personal" || echo "").img
#make vndk-test-sepolicy
}
if ${NOSYNC}
then
echo "ATTENTION: syncing/patching skipped!"
echo ""
echo "Setting up build environment"
source build/envsetup.sh &> /dev/null
echo ""
else
prep_build
echo "Applying patches"
prep_${MODE}
apply_patches patches_platform
apply_patches patches_${MODE}
if ${PERSONAL}
then
apply_patches patches_platform_personal
apply_patches patches_${MODE}_personal
fi
finalize_${MODE}
echo ""
fi
for var in "${@:2}"
do
if [ ${var} == "nosync" ] || [ ${var} == "personal" ]
then
continue
fi
echo "Starting $(${PERSONAL} && echo "personal " || echo "")build for ${MODE} ${var}"
build_${MODE} ${var}
done
ls ~/build-output | grep 'lineage' || true
END=`date +%s`
ELAPSEDM=$(($(($END-$START))/60))
ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60))
echo "Buildbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds"
echo ""

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="TrebleDroid/vendor_hardware_overlay" path="vendor/hardware_overlay" remote="github" revision="pie" />
<project name="TrebleDroid/device_phh_treble" path="device/phh/treble" remote="github" revision="android-13.0" />
<project name="phhusson/vendor_vndk-tests" path="vendor/vndk-tests" remote="github" revision="master" />
<project name="phhusson/vendor_interfaces" path="vendor/interfaces" remote="github" revision="android-11.0" />
<project name="phhusson/vendor_lptools" path="vendor/lptools" remote="github" revision="master" />
<project name="phhusson/vendor_magisk" path="vendor/magisk" remote="github" revision="android-10.0" />
<remote name="gitlab" fetch="https://gitlab.com/" />
<project name="MindTheGapps/vendor_gapps" path="vendor/gapps" remote="gitlab" revision="tau" />
</manifest>