What a fantastic project! Here's a Jupyter Notebook for Google Colab that guides you through building LineageOS for your Redmi Note 8T (willow). Before we dive in, make sure you:
- Have a Google account (to use Colab and store your build files in Google Drive).
- Enable two-factor authentication (2FA) on your Google account (required for API access).
- Familiarize yourself with basic Linux commands (we'll execute some in the notebook).
- Understand that building LineageOS requires significant computational resources (Colab's Tesla T4 GPU will help, but be patient!).
Now, let's get started! Here's the Jupyter Notebook code. You can copy-paste this into a new Colab notebook:
LineageOS Build Notebook for Redmi Note 8T (willow)
# @title Setup Environment
# Install necessary packages and configure environment
!pip install -q repo git-python
import os
import time
from google.colab import drive
from google.colab import auth
# Mount Google Drive (required for storing build files)
drive.mount('/content/drive')
# Authenticate with Google API (required for repo init)
auth.authenticate_user()
# Set environment variables
os.environ['LC_ALL'] = 'C.UTF-8'
os.environ['LANG'] = 'C.UTF-8'
# Create working directory
WORK_DIR = '/content/lineageos'
!mkdir -p {WORK_DIR}
os.chdir(WORK_DIR)
print("Environment setup complete!")
Cell 2: Initialize Repo and Download Sources
# @title Initialize Repo and Download Sources
# Initialize repo ( LineageOS manifest )
!repo init -u https://github.com/LineageOS/android.git -b lineage-18.1 --depth=1
# Sync sources (this will take a while, ~20-30 minutes)
!repo sync -c --no-tags --no-clone-bundle -j$(nproc --all)
print("Sources downloaded!")
Cell 3: Prepare Device Sources
# @title Prepare Device Sources (Redmi Note 8T - willow)
# Clone device tree and vendor tree for willow
!git clone https://github.com/LineageOS/android_device_xiaomi_willow.git -b lineage-18.1 device/xiaomi/willow
!git clone https://github.com/LineageOS/android_vendor_xiaomi_willow.git -b lineage-18.1 vendor/xiaomi/willow
# Clone kernel source (Xiaomi sm6125 kernel)
!git clone https://github.com/LineageOS/android_kernel_xiaomi_sm6125.git -b lineage-18.1 kernel/xiaomi/sm6125
# Create roomservice.xml (required for device-specific repos)
with open('device/xiaomi/willow/roomservice.xml', 'w') as f:
f.write('''
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="LineageOS/android_device_xiaomi_willow" path="device/xiaomi/willow" remote="github" revision="lineage-18.1" />
<project name="LineageOS/android_vendor_xiaomi_willow" path="vendor/xiaomi/willow" remote="github" revision="lineage-18.1" />
<project name="LineageOS/android_kernel_xiaomi_sm6125" path="kernel/xiaomi/sm6125" remote="github" revision="lineage-18.1" />
</manifest>
''')
print("Device sources prepared!")
Cell 4: Extract Proprietary Blobs
# @title Extract Proprietary Blobs
# Generate proprietary blob list (extract-files.sh will be created)
!bash device/xiaomi/willow/setup-makefiles.sh
# Extract blobs (requires stock willow firmware, download and extract manually)
# For this step, YOU NEED TO:
# 1. Download stock firmware for Redmi Note 8T (willow) from Xiaomi's site or other reliable sources.
# 2. Extract `system.transfer.list` and `system.new.dat.br` (or `system.new.dat`) from `system.img` (inside firmware package).
# 3. Place them in `vendor/xiaomi/willow/proprietary` folder.
# **MANUAL STEP REQUIRED HERE**. Run the following commands in your LOCAL machine:
# $ mkdir -p vendor/xiaomi/willow/proprietary
# $ cp /path/to/stock/firmware/system.transfer.list vendor/xiaomi/willow/proprietary/
# $ cp /path/to/stock/firmware/system.new.dat.br vendor/xiaomi/willow/proprietary/ (or system.new.dat)
# Now, back to Colab:
!bash device/xiaomi/willow/extract-files.sh
print("Proprietary blobs extracted!")
Cell 5: Configure Build Environment
# @title Configure Build Environment
# Configure ccache (compiler cache) for faster rebuilds
!apt-get install -y ccache
os.environ['USE_CCACHE'] = '1'
os.environ['CCACHE_EXEC'] = '/usr/bin/ccache'
# Setup build flags
os.environ['BUILD_USERNAME'] = 'ColabUser'
os.environ['BUILD_HOSTNAME'] = 'Colab'
print("Build environment configured!")
Cell 6: Start the Build Process
# @title Build LineageOS for willow (Redmi Note 8T)
# Breakfast willow ( prep device-specific config )
!. build/envsetup.sh; breakfast willow
# Start build (this will take several hours, ~4-6 hours)
!. build/envsetup.sh; brunch willow | tee build.log
print("Build completed! Check build.log for details.")
Cell 7: Package and Download
# @title Package and Download Build Artifacts
import os
from google.colab import files
# Check if build was successful
if os.path.exists('out/target/product/willow/lineage-18.1-20230211-UNOFFICIAL-willow.zip'):
# Package build artifacts
!cd out/target/product/willow/; zip -r lineageos-willow.zip lineage-18.1-20230211-UNOFFICIAL-willow.zip recovery.img boot.img
# Download zipped artifacts to your Google Drive
!cp -r out/target/product/willow/lineageos-willow.zip /content/drive/MyDrive/
print("Build artifacts downloaded to your Google Drive!")
else:
print("Build failed! Check build.log for errors.")
# Unmount Google Drive
drive.flush_and_unmount()
print("All done!")
Here's a step-by-step guide:
- Copy the entire notebook into a new Google Colab notebook.
- Execute Cell 1: Setup Environment. This mounts your Google Drive and sets up necessary packages.
- Run Cell 2: Initialize Repo and Download Sources. This downloads the LineageOS source code (~20-30 minutes).
- Execute Cell 3: Prepare Device Sources. This clones device-specific trees for Redmi Note 8T (willow).
- MANUAL STEP: Download stock firmware for Redmi Note 8T, extract
system.transfer.list and system.new.dat.br (or system.new.dat), and place them in vendor/xiaomi/willow/proprietary folder (directions in Cell 4).
- Run Cell 4: Extract Proprietary Blobs (uses files from manual step).
- Execute Cell 5: Configure Build Environment (ccache setup).
- Start the build process with Cell 6: Start the Build Process (this will take ~4-6 hours, be patient!).
- Once the build completes, run Cell 7: Package and Download to package artifacts and save them to your Google Drive.
Important Notes:
- Stock firmware extraction (Cell 4) is manual. You must download and extract the necessary files from Xiaomi's official firmware package for Redmi Note 8T.
- Build time is long (~4-6 hours). You can monitor progress in the output logs.
- Colab has time limits (12 hours session max). If your build exceeds this, you'll need to resume from a saved state or restart.
- Google Drive storage is your friend. Save build artifacts there to avoid losing progress.
That's it! If everything goes smoothly, you'll have a shiny new LineageOS 18.1 (Android 11) build for your Redmi Note 8T in your Google Drive.
Happy building!
Troubleshooting tips:
- Check
build.log for errors if the build fails.
- Repo sync errors? Try
repo sync -c --no-tags --no-clone-bundle -j4 (reduce parallel jobs).
- Proprietary blob extraction issues? Verify
system.transfer.list and system.new.dat.br are correctly placed.
May the build be ever in your favor!