Create a new directory for eOS sources and enter it:
mkdir a14
cd a14
mkdir -p a14/.repo/local_manifests
repo init -u https://gitlab.e.foundation/e/os/releases.git -b refs/tags/v2.8-a14 --git-lfs
git clone https://github.com/MisterZtr/treble_manifest.git .repo/local_manifests -b 14
repo sync -j 1 --fail-fast --force-sync
Take the patches from here:
In the source directory a14 create a directory named patches with subdirectory named trebledroid:
mkdir -p patches/trebledroid
Copy from AndyCGYan patches the folowing directories in the trebledroid directory:
patches_platform, patches_treble, patches_treble_prerequisite and patches_treble_td.
Remove from patches/trebledroid/patches_treble the treble_app directory.
In the patches directory we put also a script named apply-patches.sh:
#!/bin/bash
set -e
source="$(readlink -f -- $1)"
treble_prerequisite="$source/patches/trebledroid/patches_treble_prerequisite"
treble_td="$source/patches/trebledroid/patches_treble_td"
platform="$source/patches/trebledroid/patches_platform"
treble="$source/patches/trebledroid/patches_treble"
printf "\n ### APPLYING treble_prerequisite PATCHES ###\n";
sleep 3.0;
for path in $(cd $treble_prerequisite; echo *); do
tree="$(tr _ / <<<$path | sed -e 's;platform/;;g')"
printf "\n| $path ###\n";
[ "$tree" == build ] && tree=build/make
[ "$tree" == frameworks/proto/logging ] && tree=frameworks/proto_logging
[ "$tree" == vendor/hardware/overlay ] && tree=vendor/hardware_overlay
pushd $tree
for patch in $treble_prerequisite/$path/*.patch; do
# Check if patch is already applied
if patch -f -p1 --dry-run -R < $patch > /dev/null; then
printf "### ALREADY APPLIED: $patch \n";
continue
fi
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
printf "### FAILED APPLYING: $patch \n"
fi
done
popd
done
printf "\n ### APPLYING treble_td PATCHES ###\n";
sleep 3.0;
for path in $(cd $treble_td; echo *); do
tree="$(tr _ / <<<$path | sed -e 's;platform/;;g')"
printf "\n| $path ###\n";
[ "$tree" == build ] && tree=build/make
[ "$tree" == frameworks/proto/logging ] && tree=frameworks/proto_logging
[ "$tree" == vendor/hardware/overlay ] && tree=vendor/hardware_overlay
pushd $tree
for patch in $treble_td/$path/*.patch; do
# Check if patch is already applied
if patch -f -p1 --dry-run -R < $patch > /dev/null; then
printf "### ALREADY APPLIED: $patch \n";
continue
fi
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
printf "### FAILED APPLYING: $patch \n"
fi
done
popd
done
printf "\n ### APPLYING platform PATCHES ###\n";
sleep 3.0;
for path in $(cd $platform; echo *); do
tree="$(tr _ / <<<$path | sed -e 's;platform/;;g')"
printf "\n| $path ###\n";
[ "$tree" == build ] && tree=build/make
[ "$tree" == frameworks/proto/logging ] && tree=frameworks/proto_logging
[ "$tree" == vendor/hardware/overlay ] && tree=vendor/hardware_overlay
pushd $tree
for patch in $platform/$path/*.patch; do
# Check if patch is already applied
if patch -f -p1 --dry-run -R < $patch > /dev/null; then
printf "### ALREADY APPLIED: $patch \n";
continue
fi
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
printf "### FAILED APPLYING: $patch \n"
fi
done
popd
done
printf "\n ### APPLYING treble PATCHES ###\n";
sleep 3.0;
for path in $(cd $treble; echo *); do
tree="$(tr _ / <<<$path | sed -e 's;platform/;;g')"
printf "\n| $path ###\n";
[ "$tree" == build ] && tree=build/make
[ "$tree" == frameworks/proto/logging ] && tree=frameworks/proto_logging
[ "$tree" == vendor/hardware/overlay ] && tree=vendor/hardware_overlay
pushd $tree
for patch in $treble/$path/*.patch; do
# Check if patch is already applied
if patch -f -p1 --dry-run -R < $patch > /dev/null; then
printf "### ALREADY APPLIED: $patch \n";
continue
fi
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
printf "### FAILED APPLYING: $patch \n"
fi
done
popd
done
The code is ugly and in general all the process to generate a gsi can be made automate, but i prefer to see every step since for now everything is in an experimental phase. Also my time and energy are very limited so i really want some enthusiast takes over and improves the entire process.
Apply the patches from the source tree:
bash patches/apply-patches.sh . | tee /dev/stderr | grep 'FAILED\|ALREADY\|failed' > error.txt
The patches will be applied and a file error.txt is generated in the source tree.
This will help to see what patches give error or are already adopted by eOS team and to eliminate or improve.
After patching the next step:
cd device/phh/treble
git clean -fdx
bash generate.sh lineage
Create a file treble_arm64_bvN.mk in device/phh/treble directory with the content:
TARGET_GAPPS_ARCH := arm64
include build/make/target/product/aosp_arm64.mk
$(call inherit-product, device/phh/treble/base.mk)
$(call inherit-product, device/phh/treble/lineage.mk)
PRODUCT_NAME := treble_arm64_bvN
PRODUCT_DEVICE := tdgsi_arm64_ab
PRODUCT_BRAND := google
PRODUCT_SYSTEM_BRAND := google
PRODUCT_MODEL := TrebleDroid
# Overwrite the inherited "emulator" characteristics
PRODUCT_CHARACTERISTICS := device
PRODUCT_PACKAGES +=
LINEAGE_BUILDTYPE := VANILLA
LINEAGE_EXTRAVERSION := -EXT4
LINEAGE_BUILD := GSI
Also, you need to add a line in the file AndroidProducts.mk:
$(LOCAL_DIR)/treble_arm64_bvN.mk \
Come out from device/phh/treble back to source tree.
Enter directory vendor/hardware_overlay:
cd vendor/hardware_overlay
git add TrebleApp/app.apk
git commit -m "TrebleApp"
Come back to source tree a14 directory.
Prepare to build:
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 50G
You can use other formula though.
source build/envsetup.sh
source vendor/lineage/vars/aosp_target_release
lunch treble_arm64_bvN-ap2a-userdebug
WITH_ADB_INSECURE=true make systemimage
That’s it. I will answer as far as I can understand. I’m not a specialist myself.
In fact the whole process is an adaptation of AndyCGYan’s script: