How to compile a LineageOS based Custom ROM for a not official
supported phone
Most Custom ROMs for Android phones are based on LineageOS but
they do not officially support all phones supported by LineageOS.
Many of the Custom ROMs based on LineageOS can be easily
compiled for phones not official supported by these Custom ROMs,
provided that a few prerequisites are met:
1. The target phone must be supported by the official LineageOS
version used for the Custom ROM
2. The repository with the files for the vendor directory
for the target phone must be available somewhere
Note:
Many repositories with vendor and device trees for various phones
are available here: https://github.com/TheMuppets and here: https://github.com/DonkeyCoyote
3. The custom ROM must use the directory vendor/lineage
(some LineageOS based Custom ROMs, like CalyxOS, don't use
that directory)
4. The custom ROM should use the build scripts from the LineageOS
Once these requirements are met, the instructions below can be used
to create the Custom ROM for another phone:
First use the instructions from the documentation for the Custom ROM
to download the repositories for the Custom ROM to your PC.
Then add the repository for the vendor tree for the target phone -
e.g. to create a Custom ROM for the ASUS Zenfone 8:
# prepare the environment for building an OS image for the
ASUS Zenfone 8
#
cat >.repo/local_manifests/local_manifests.xml
<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="TheMuppets/proprietary_vendor_asus_sake"
path="vendor/asus/sake" revision="21.0"
clone-depth="1" />
</manifest>
EOT
and sync the repositories for the target phone, in this example this
can be done using this command:
repo sync TheMuppets/proprietary_vendor_asus_sake
Note that the revision used for the vendor tree, 21.0 in the
example above, must match the LineageOS version that was
used to create the Custom ROM!
Now you can start the build:
To start the build for the target phone, use either these commands
for custom ROMs based on Android 13 (or older):
# prepare the environment
#
source build/envsetup.sh
# Notes:
#
# the lunch command downloads the missing repositories
for the target phone from the LineageOS repositories
#
lunch lineage_sake-user
# start the build
#
time brunch lineage_sake-user
or these commands for Custom ROMs based on Android 14 (or
newer):
# prepare the environment
source build/envsetup.sh
# Notes:
#
# the lunch command downloads the missing repositories
for the target phone from the LineageOS repositories
#
# use the script print_security_patch
to get the build ID for the lunch and brunch commands ("bp1a" in
this example)
#
lunch lineage_sake-bp1a-user
# start the build
#
time brunch lineage_sake-bp1a-user
Note:
replace "sake" in the commands above with the codename for
the target phone (sake is the codename for the ASUS
Zenfone 8)
The codenames used in LineageOS are documented on the download
page for the LineageOS images.
If the necessary repositories for the target phone are missing in
the LineageOS repositories or the lunch command does
not find them, you can add them manually to the file local_manifests.xml,
e.g. for the ASUS Zenfone 8 that are these repositories:
<project path="device/asus/sake" remote="github"
name="LineageOS/android_device_asus_sake" revision="lineage-21"
/>
<project path="kernel/asus/sm8350" remote="github"
name="LineageOS/android_kernel_asus_sm8350" revision="lineage-21"
/>
I have successfully used this approach to create these Custom ROMs
for the ASUS Zenfone 8:
crDroid 11.7 (see How
to compile the crDroid CustomROM for the ASUS Zenfone 8)
EvolutionX 10.7 (see How
to compile the evolutionX Custom ROM for the ASUS Zenfone 8)
iodeOS 4.x
see here
for a list of available OS Images for the ASUS Zenfone 8.
see here
for instructions to compile the various LineageOS based
Distributions for the ASUS Zenfone 8 (the instructions can
be used as an example for building Custom ROMs for other phones)
-----------
How to compile the iodeOS 4.x for the ASUS Zenfone 8
iodeOS is
another LineageOS
based Custom ROM that does not support the ASUS Zenfone 8
but can be easily build for the ASUS Zenfone 8.
The official instructions to build the iodeOS are
here
https://gitlab.iode.tech/os/public/manifests/android
To build an iodeOS 4.x image (= LineageOS 20 = Android
13) for the ASUS Zenfone 8 execute these steps:
# define some variables
# branch to use (v4 is LineageOS 20 = Android 13)
#
BRANCH="v4-staging"
LINEAGE_VERSION="lineage-20"
LOCAL_DIR="/datapool001/develop/iodeos/4.x"
# create a new directory for the iodeOS
repositories
#
mkdir -p "${LOCAL_DIR}"
cd "${LOCAL_DIR}"
# init the iodeOS
repositories
#
repo init -u
https://gitlab.iode.tech/os/public/manifests/android.git -b
${BRANCH}
mkdir -p .repo/local_manifests
# ignore the repositories for the emulator
#
cat >.repo/local_manifests/remove-bloat.xml <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remove-project
name="device/generic/mini-emulator-arm64" />
<remove-project
name="device/generic/mini-emulator-x86" />
<remove-project
name="device/generic/mini-emulator-x86_64" />
</manifest>
EOT
# add the repositories necessary for building an OS
image for the ASUS Zenfone 8
#
cat >.repo/local_manifests/local_manifests.xml
<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project
name="TheMuppets/proprietary_vendor_asus_sake"
path="vendor/asus/sake" revision="${LINEAGE_VERSION}"
clone-depth="1" />
</manifest>
EOT
# download the repositories with the source
code for the iodeOS
#
repo sync --force-sync
# download the Git LFS stored objects
cd "${LOCAL_DIR}"/vendor/extra
git lfs pull iode ${BRANCH}
cd "${LOCAL_DIR}"
# prepare the build environment
#
source build/envsetup.sh
# the lunch command downloads the missing repositories for the
ASUS Zenfone 8
#
lunch lineage_sake-user
# start the build
#
time brunch lineage_sake-user
Notes
There is also a docker image for building the iodeOS :
https://github.com/petefoth/IodeBuild
As far as I know, the docker image can not be used to build an image
for an unsupported phone without modifications.
---------------
How to compile the iodeOS 6.x for the ASUS Zenfone 8
iodeOS is
another LineageOS
based Custom ROM that does not support the ASUS Zenfone 8
but can be easily build for the ASUS Zenfone 8.
The official instructions to build the iodeOS are
here
https://gitlab.iode.tech/os/public/manifests/android
To build an iodeOS 6.x image (= LineageOS 21 = Android
14) for the ASUS Zenfone 8 execute these steps:
# define some variables
# branch to use (v6 is LineageOS 21 = Android 14)
#
BRANCH="v6.9"
LINEAGE_VERSION="lineage-21"
LOCAL_DIR="/datapool001/develop/iodeos/6.x"
# create a new directory for the iodeOS
repositories
#
mkdir -p "${LOCAL_DIR}"
cd "${LOCAL_DIR}"
# init the iodeOS
repositories
#
repo init -u
https://gitlab.iode.tech/os/public/manifests/android.git -b
${BRANCH}
# download the repositories with the source code for
the iodeOS
#
repo sync --force-sync
# download the Git LFS stored objects
cd "${LOCAL_DIR}"/vendor/extra
git lfs pull iode ${BRANCH}
cd "${LOCAL_DIR}"
# add the repositories necessary for building an OS
image for the ASUS Zenfone 8
#
mkdir -p .repo/local_manifests
cat >.repo/local_manifests/local_manifests.xml <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="TheMuppets/proprietary_vendor_asus_sake"
path="vendor/asus/sake" revision="${LINEAGE_VERSION}"
clone-depth="1" />
</manifest>
EOT
# download the LineageOS repositories for
vendor/asus
#
repo sync TheMuppets/proprietary_vendor_asus_sake
source build/envsetup.sh
# the lunch command downloads the missing repositories for the
ASUS Zenfone 8
#
# Note: use the script print_security_patch
to get the build ID for the lunch and brunch commands ("bp1a" in
this example)
#
lunch lineage_sake-bp1a-user
# start the build
#
time brunch lineage_sake-bp1a-user
Notes
There is also a docker image for building the iodeOS :
https://github.com/petefoth/IodeBuild
As far as I know, the docker image can not be used to build an image
for an unsupported phone without modifications.