闲来无事 打算亲自给手上的SM-J3109编译一次lineageos

Google如何编译并参考了一下博客之后(参考链接会放在最后)

折腾了三天终于是编译成功了

首先 需要一台装了Ubuntu系统的电脑(虚拟机也可以 但是还是建议电脑)

根据Ubuntu版本安装所需要的包

 For Ubuntu 23.10 (mantic), install libncurses5 from 23.04 (lunar) as follows:
    
    wget http://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.4-2_amd64.deb && sudo dpkg -i libtinfo5_6.4-2_amd64.deb && rm -f libtinfo5_6.4-2_amd64.deb
    wget http://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libncurses5_6.4-2_amd64.deb && sudo dpkg -i libncurses5_6.4-2_amd64.deb && rm -f libncurses5_6.4-2_amd64.deb
    
    While for Ubuntu versions older than 23.10 (mantic), simply install:
    
    lib32ncurses5-dev libncurses5 libncurses5-dev
    
    Additionally, for Ubuntu versions older than 20.04 (focal), install also:
    
    libwxgtk3.0-dev
    
    While for Ubuntu versions older than 16.04 (xenial), install:
    
    libwxgtk2.8-dev

我的Ubuntu版本是22.04 所以运行

    sudo apt update &&
    sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev  python-is-python3
    #下面根据Ubuntu版本安装所需的包
    sudo apt isntall lib32ncurses5-dev libncurses5 libncurses5-dev

接下来创建编译目录并下载所需要的repo工具添加到环境变量中

    mkdir -p ~/bin
    mkdir -p ~/android/lineage
    #可以直连Google的直接执行就好
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    #如果是在网络环境不好就从清华源下载repo镜像
    curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
    chmod a+x ~/bin/repo

添加~/bin目录到环境变量(Ubuntu22.04中已经自动添加了,这里是做演示)

    sudo vim ~/.profile
    #复制下面的代码 粘贴 保存并退出
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    #然后执行
    soucre ~/.profile

接下来配置git

    git config --global user.email "[email protected]"
    git config --global user.name "Your Name"

由于其大小,一些存储库配置为lfs或Large File Storage。为了确保您的发行版为此做好准备,请运行:

    git lfs install

开启编译缓存(加快反复编译的速度)

    vim ~/.bashrc
    #复制下面的代码
    export USE_CCACHE=1
    export CCACHE_EXEC=/usr/bin/ccache
    #保存后ccache设定最大缓存容量
    ccache -M 50G

初始化LineageOS源代码存储库

    cd ~/android/lineage
    repo init -u https://github.com/LineageOS/android.git -b lineage-17.1 --git-lfs
    #同样的网络环境不好可以使用清华源镜像
    repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/LineageOS/android.git -b lineage-17.1 --git-lfs

开始下载源代码

    #有代理的话直接拉取即可(否则先配置清华源镜像)
    repo sync
    #配置清华源镜像
    mkdir ~/android/lineage/.repo/manifests/ 
    vim   ~/android/lineage/.repo/manifests/default.xml
    将
    
      <remote  name="github"
               fetch=".."
               review="review.lineageos.org" />
    
    改成
    
      <remote  name="github"
               fetch="https://github.com/" />
    
      <remote  name="lineage"
               fetch="https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/"
               review="review.lineageos.org" />
    将
    
      <remote  name="aosp"
               fetch="https://android.googlesource.com"
    改成
    
      <remote  name="aosp"
               fetch="https://mirrors.tuna.tsinghua.edu.cn/git/AOSP"
    将
    
      <default revision="..."
               remote="github"
    改成
    
      <default revision="..."
               remote="lineage"

配置好镜像仓库后拉取源代码

repo sync

J3LTECEC尚未进入LineageOS官方储存库,状态是unofficial,这里需要手动修改要下载的储存库。!(必须有代理才可以哦,不然会出现拉取失败的情况)

    mkdir -p ~/android/lineage/.repo/local_manifests/
    vim ~/android/lineage/.repo/local_manifests/roomservice.xml
    #复制粘贴下面的内容 
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
      <project path="vendor/samsung"                 remote="github" name="Galaxy-MSM8916/proprietary_vendor_samsung"                revision="lineage-17.1" />
      <project path="device/samsung/j3-common"       remote="github" name="Galaxy-MSM8916/android_device_samsung_j3-common"          revision="lineage-17.1" />
      <project path="device/samsung/j3ltectc"        remote="github" name="Galaxy-MSM8916/android_device_samsung_j3ltectc"           revision="lineage-17.1" />
      <project path="device/samsung/msm8916-common"  remote="github" name="Galaxy-MSM8916/android_device_samsung_msm8916-common"     revision="lineage-17.1" />
      <project path="device/samsung/qcom-common"     remote="github" name="LineageOS/android_device_samsung_qcom-common"             revision="lineage-17.1" />
      <project path="hardware/samsung"               remote="github" name="LineageOS/android_hardware_samsung"                       revision="lineage-17.1" />
      <project path="kernel/samsung/msm8916"         remote="github" name="Galaxy-MSM8916/android_kernel_samsung_msm8916"            revision="lineage-17.1" />      
</manifest>

因为这并非lineageOS官方库,所以没有网络代理的话

只能手动git拉取项目文件了(这里使用的是我搭建的github镜像站)

    #拉取私有驱动
    cd ~/android/lineage/vendor/samsung
    git clone -b lineage-17.1 https://git.gtian.cf/Galaxy-MSM8916/proprietary_vendor_samsung.git
    mv proprietary_vendor_samsung/j3-common . 
    mv proprietary_vendor_samsung/j3ltectc . 
    mv proprietary_vendor_samsung/msm8916-common .
    rm -rf proprietary_vendor_samsung
    
    #拉取android_device_samsung_qcom-common
    cd ~/android/lineage/device/samsung/qcom-common
    git clone -b lineage-17.1 https://git.gtian.cf/LineageOS/android_device_samsung_qcom-common.git
    mv android_device_samsung_qcom-common/* .
    rm -rf android_device_samsung_qcom-common
    
    #拉取android_device_samsung_msm8916-common
    cd ~/android/lineage/device/samsung/msm8916-common
    git clone -b lineage-17.1 https://git.gtian.cf/Galaxy-MSM8916/android_device_samsung_msm8916-common.git
    mv android_device_samsung_msm8916-common/* .
    rm -rf android_device_samsung_msm8916-common
    
    #拉取android_device_samsung_j3-common
    cd ~/android/lineage/device/samsung/j3-common
    git clone -b lineage-17.1 https://git.gtian.cf/Galaxy-MSM8916/android_device_samsung_j3-common.git
    mv android_device_samsung_j3-common/* .
    rm -rf android_device_samsung_j3-common
    
    #拉取android_device_samsung_j3ltectc
    cd ~/android/lineage/device/samsung/j3ltectc
    git clone -b lineage-17.1 https://git.gtian.cf/Galaxy-MSM8916/android_device_samsung_j3ltectc.git
    mv android_device_samsung_j3-common/* .
    rm -rf android_device_samsung_j3-common
    
    #拉取android_hardware_samsung
    cd ~/android/lineage/hardware_samsung
    git clone -b lineage-17.1 https://git.gtian.cf/LineageOS/android_hardware_samsung.git
    mv android_hardware_samsung/* .
    rm -rf android_hardware_samsung
    
    #拉取android_kernel_samsung_msm8916
    cd ~/android/lineage/device/kernel/samsung/msm8916
    git clone -b lineage-17.1 https://git.gtian.cf/Galaxy-MSM8916/android_kernel_samsung_msm8916.git
    mv android_kernel_samsung_msm8916/* .
    rm -rf android_kernel_samsung_msm8916

开始编译ROM以及核心

    source build/envsetup.sh
    breakfast j3ltectc
    croot
    brunch j3ltectc

编译成功之后 打包好的ROM和boot.img在~/android/lineage/out/target/product

参考链接:

https://ivonblog.com/posts/build-lineageos-20-sony-xperia-5-ii/

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

标签: none

添加新评论