Compiling LineageOS 21 for OnePlus 5 on Ubuntu 20.04

Primarily, the steps should refer to the official documentation.

1. Reference Materials

https://wiki.lineageos.org/devices/cheeseburger/build/

2. Problem Solving

1. Using Tsinghua’s mirror, various downloads failed, so I gave up and reverted to the original.

2. Use the official URL https://github.com/LineageOS/android.git, which requires a VPN.On my Ubuntu 20.04, I also encountered 10 errors or failed pulls, as detailed below:

https://github.com/LineageOS/android_external_vim   https://github.com/LineageOS/android_packages_modules_Bluetoothhttps://github.com/LineageOS/android_external_libvpxhttps://github.com/LineageOS/android_packages_apps_Settingshttps://github.com/LineageOS/android_vendor_lineage   https://github.com/LineageOS/android_packages_apps_Seedvault  https://github.com/LineageOS/android_developmenthttps://github.com/LineageOS/android_system_extrashttps://github.com/LineageOS/contributors-cloud-generator  https://github.com/LineageOS/android_packages_modules_Connectivity

To address this issue, I went to ~/android/lineage21/.repo/manifests and modified default.xml, commenting out the relevant code and using git clone to download separately.Note the corresponding directories as follows:

git clone https://github.com/LineageOS/android_external_libvpx.git libvpx -b lineage-21.0git clone https://github.com/LineageOS/android_packages_apps_Settings.git Settings -b lineage-21.0git clone https://github.com/LineageOS/android_packages_modules_Bluetooth.git Bluetooth -b lineage-21.0git clone https://github.com/LineageOS/android_packages_modules_Connectivity Connectivity  -b lineage-21.0git clone https://github.com/LineageOS/android_system_extras.git extras  -b lineage-21.0

Then I used repo sync -j 32 -c to synchronize the code. Fortunately, it worked.

3. Implemented a script extract.sh for Extractproprietaryblobs to complete the task directly. The script is as follows:

lineageZipPath=$1extractFilesPath=$2
echo "lineageZipPath="$1
echo "extractFilesPath="$2
#1.mkdir ~/android/system_dump/cd ~/android/system_dump/
#2.unzip $lineageZipPath system.transfer.list system.new.dat*unzip $lineageZipPath vendor.transfer.list vendor.new.dat*
#3.sudo apt-get install brotli
brotli --decompress --output=system.new.dat system.new.dat.br
brotli --decompress --output=vendor.new.dat vendor.new.dat.br
#4.git clone https://github.com/xpirt/sdat2img
python sdat2img/sdat2img.py system.transfer.list system.new.dat system.imgmkdir system/sudomount system.img system/
python sdat2img/sdat2img.py vendor.transfer.list vendor.new.dat vendor.imgsudorm system/vendor
mkdir system/vendor/
mount vendor.img system/vendor/
#5.cd $extractFilesPath./extract-files.sh ~/android/system_dump/
#6.sudo umount ~/android/system_dump/system/vendor
sudo umount ~/android/system_dump/system
#7.rm -rf ~/android/system_dump/

When running the script, such as

.extract.sh

~/android/Extractproprietaryblobs/cheeseburger/lineage-21.0-20240422-nightly-cheeseburger-signed.zip ~/android/lineage21/device/oneplus/cheeseburger/

Note: This zip file needs to be downloaded from the official site, and the latter path is for extract-files.sh.

4. Compile script to build the user version

. build/envsetup.sh
croot
brunch cheeseburger user

5. Compilation Error 1

[  2% 1227/55159] //system/sepolicy:vendor_sepolicy.cil.raw Building cil for vendor_sepolicy.cil.raw [common]FAILED: out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.rawout/host/linux-x86/bin/checkpolicy -C -M -c 30 -o out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.raw out/soong/.intermediates/system/sepolicy/vendor_sepolicy.conf/android_common/cheeseburger/vendor_sepolicy.conf && out/host/linux-x86/bin/build_sepolicy filter_out -f out/soong/.intermediates/system/sepolicy/reqd_policy_mask.cil/android_common/reqd_policy_mask.cil -t out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.raw # hash of input list: b1d306f1c8eb8b8db3437401a6014eabfad9a9e976b53d2cb37e725fe3d95a1edevice/oneplus/msm8998-common/sepolicy/vendor/hal_camera_default.te:10:ERROR 'unknown type vendor_sensors_dbg_prop' at token ';'on line 79573:#line 10allow hal_camera_default vendor_sensors_dbg_prop:file { getattr open read map };checkpolicy:  error(s) encountered while parsing configuration10:50:53 ninja failed with: exit status 1

Solution: Go to device/oneplus/msm8998-common/sepolicy/vendor/hal_camera_default.te and comment out line 10.

6. Compilation Error 2

[  1% 930/54701] //system/sepolicy:vendor_sepolicy.cil.raw Building cil for vendor_sepolicy.cil.raw [common]FAILED: out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.rawout/host/linux-x86/bin/checkpolicy -C -M -c 30 -o out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.raw out/soong/.intermediates/system/sepolicy/vendor_sepolicy.conf/android_common/cheeseburger/vendor_sepolicy.conf && out/host/linux-x86/bin/build_sepolicy filter_out -f out/soong/.intermediates/system/sepolicy/reqd_policy_mask.cil/android_common/reqd_policy_mask.cil -t out/soong/.intermediates/system/sepolicy/vendor_sepolicy.cil.raw/android_common/cheeseburger/vendor_sepolicy.cil.raw # hash of input list: b1d306f1c8eb8b8db3437401a6014eabfad9a9e976b53d2cb37e725fe3d95a1edevice/oneplus/msm8998-common/sepolicy/vendor/genfs_contexts:4:ERROR 'type qti_debugfs is not defined or is an attribute' at token 'genfscon'on line 81283:genfscon debugfs /rmt_storage/rmts     u:object_r:qti_debugfs:s0genfscon debugfs /msm_core             u:object_r:qti_debugfs:s0checkpolicy:  error(s) encountered while parsing configuration11:08:34 ninja failed with: exit status 1

Solution: Go to device/oneplus/msm8998-common/sepolicy/vendor/genfs_contexts and comment out

genfscon debugfs /rmt_storage/rmts u:object_r:qti_debugfs:s0

genfscon debugfs /msm_core u:object_r:qti_debugfs:s0

using # to comment them out.

Leave a Comment