Compile LineageOS for Oneplus 3 on Fedora 25

来源:互联网 发布:网络信息安全英语ppt 编辑:程序博客网 时间:2024/04/29 10:47


https://uwot.eu/blog/compile-lineageos-for-oneplus-3-on-fedora-25/


Android community is one big cancerous clusterfuck, it is no wonder that finding a decent guide on how to compile Android from source written in a somewhat comprehensible english is pretty much mission impossible.
Cyanogenmod Inc. shutting down their wiki and services overnight surely didn’t help either.
Required packages on Fedora 25 are (rpmfusion repo must be previously installed):

1
$ sudodnf install screen java-1.8.0-openjdk-devel git schedtool ncurses-devel ncurses-libs ncurses-compat-libs ImageMagick-devel libstdc++-devel bison gnupg lzma

For some reason the compilation process stores some temporary files in /tmp which, in Fedora 25, is mounted on a tmpfs ramdisk.
In case the ramdisk runs out of space for some retarded reason the build process instead of halting will go on like nothing happens and produce borked binaries as output.
To keep /tmp mounted on HDD run:

1
systemctl mask tmp.mount

Download the SDK and extract the files, if building on an headless machine just get the command line tools:https://developer.android.com/studio/index.html#downloads

1
2
3
4
5
6
7
8
9
10
11
$ mkdirandroid-sdk-linux
$ mvtools_r25.2.3-linux.zip android-sdk-linux
$ cdandroid-sdk-linux
$ unzip tools_r25.2.3-linux.zip
$ vi~/.bash_profile
---
export ANDROID_HOME=/home/user/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
---
$ source.bash_profile

Download the latest version of “Android SDK Tools”, “Android SDK Platform-tools”, “Android SDK Build-tools” and “SDK Plattform Android”:

1
2
3
### list available downloads
$ android list sdk
$ android update sdk --no-ui --filter 1,2,3,33

Get repo utility and create a directory where Android’s source code will be downloaded.
Screen utility might come in handy since the download will likely take some time (it is around 60 GB).

1
2
3
4
5
6
7
$ curl https://storage.googleapis.com/git-repo-downloads/repo> ~/bin/repo
$ chmoda+x ~/bin/repo
$ mkdir-p ~/android/system
$ cdandroid/system
### replace cm-14.1 with the desired branch
$ repo init -u git://github.com/LineageOS/android.git -b cm-14.1
$ repo sync

Now it is time to download the source code needed to compile for a specific device, which is a Oneplus 3 in my case.
Before actually compiling it is a good idea to run “make clobber” to clean the system from all the temp files created the previous time Android was compiled.
While this should not be necessary and makes the compilation procedure much longer it should ensure that everything is recompiled correctly every time even if some binary blobs have changed:

1
2
3
$ makeclobber
$ sourcebuild/envsetup.sh
$ breakfast oneplus3

Double check that all the needed repository are actually present in roomservice.xml file:

/android/system/.repo/local_manifests/roomservice.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xmlversion="1.0"encoding="UTF-8"?>
<manifest>
  <projectname="LineageOS/android_device_oneplus_oneplus3"path="device/oneplus/oneplus3"remote="github"/>
  <projectname="LineageOS/android_device_oppo_common"path="device/oppo/common"remote="github"/>
  <projectname="LineageOS/android_kernel_oneplus_msm8996"path="kernel/oneplus/msm8996"remote="github"/>
  <projectname="LineageOS/android_packages_resources_devicesettings"path="packages/resources/devicesettings"remote="github"/>
  <projectname="LineageOS/android_vendor_nxp-nfc_opensource_frameworks"path="vendor/nxp-nfc/opensource/frameworks"remote="github"/>
  <projectname="LineageOS/android_vendor_nxp-nfc_opensource_libnfc-nci"path="vendor/nxp-nfc/opensource/libnfc-nci"remote="github"/>
  <projectname="LineageOS/android_vendor_nxp-nfc_opensource_Nfc"path="vendor/nxp-nfc/opensource/Nfc"remote="github"/>
  <projectname="LineageOS/android_device_qcom_common"path="device/qcom/common"remote="github"/>
  <projectname="LineageOS/android_external_sony_boringssl-compat"path="external/sony/boringssl-compat"remote="github"revision="cm-14.1"/>
  <projectname="LineageOS/android_external_stlport"path="external/stlport"remote="github"revision="cm-14.1"/>
  <projectname="TheMuppets/proprietary_vendor_oneplus"path="vendor/oneplus"remote="github"revision="cm-14.1"/>
  <projectname="TheMuppets/proprietary_vendor_qcom_binaries"path="vendor/qcom/binaries"remote="github"revision="cm-14.1"/>
</manifest>

Google’s Android compilation guide suggest the user to enable gcc ccache, I prefer to keep it disabled because it can cause corrupted output (it already happened more than once to me).
Set jack server’s allocated memory (-Xmx flag) to as much RAM you can spare for it:

1
2
3
4
5
6
7
$ repo sync
#$ export USE_CCACHE=1
#$ prebuilts/misc/linux-x86/ccache/ccache -M 50G
$ exportANDROID_JACK_VM_ARGS="-Xmx8192m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"
#set this environmental variable to include su binaries
$ exportWITH_SU=true
$ brunch oneplus3

The compiled binaries can be found in ~/android/system/out/target/product/oneplus3/, it will all be compressed in an archive named “lineage-version-date-UNOFFICIAL-oneplus3” that can then be flashed from recovery.
The recovery everyone suggest to use for oneplus3 can be found here: https://forum.xda-developers.com/oneplus-3/development/recovery-twrp-3-0-2-0-touch-recovery-t3402999
This procedure can be extended to any other device, the only thing that needs adjustment are the repositories present in roomservice.xml file.
To compile LineageOS for a LG G3 for the european market (codename: d855) run repo sync, breakfast d855 and add the correct binary blob repository to roomservice.xml:

1
<projectname="TheMuppets/proprietary_vendor_lge"path="vendor/d855"remote="github"revision="cm-14.1"/>

d855 for some reason also needs lzma to compress the Linux kernel.


0 0
原创粉丝点击