利用LineageOS構(gòu)建自己的android-12 ROM

生產(chǎn)環(huán)境:Ubuntu-18.04,已有工具:repo深寥、git江解、androidSDK。已有設(shè)備三星tab s5e

1.事先準(zhǔn)備

2.下載源碼

  • 創(chuàng)建代碼倉庫文件夾:mkdir ~/LineageOS
  • 初始化repo:repo init -u https://github.com/LineageOS/android.git -b lineage-19.1
  • 下載lineageos:repo sync
  • 初始化device: source build/envsetup.sh && breakfast gts4lvwifi

3.提取設(shè)備專有blob文件 & 構(gòu)建系統(tǒng)

  • 提取設(shè)備專有blob文件有兩種途徑可選:
    • 方法1:設(shè)備專有文件可以通過一個(gè)已經(jīng)刷入lineageOS的設(shè)備中導(dǎo)出:準(zhǔn)備一個(gè)可root 調(diào)試并且已刷入lineageOS的設(shè)備,連接電腦惠奸。然后在device/samsung/gts4lvwifi/文件夾下執(zhí)行./extract-files.sh梅誓,導(dǎo)出proprietary文件。
      (注意這個(gè)方式會有libantradio.lib等20個(gè)文件導(dǎo)出失敗佛南,可結(jié)合 https://github.com/TheMuppets/proprietary_vendor_samsung.git 倉庫補(bǔ)全丟失文件)
    • 方法2:從zip安裝包提取設(shè)備專有blob文件 (見第4節(jié))
  • 構(gòu)建系統(tǒng)(第一次需要好幾個(gè)小時(shí)):
    croot
    brunch gts4lvwifi
    

4.通過lineageOS的ROM包提取設(shè)備專有blob文件

在rom包中有三種不同類型的OTA:

  • block塊類型的OTA:系統(tǒng)分區(qū)內(nèi)容存儲在.dat或者.dat/br文件內(nèi)梗掰。
  • file文件類OTA:系統(tǒng)分區(qū)內(nèi)容存儲在一個(gè)名叫system的zip文件內(nèi)
  • payload類OTA:系統(tǒng)分區(qū)內(nèi)容存儲在payload.bin文件內(nèi)的img文件。

如何判別:

  • 如果zip壓縮包內(nèi)沒有System文件夾或者system文件夾幾乎是空的嗅回,并且在zip的根目錄存在一個(gè)system.transfer.list文件及穗,那么它就是一個(gè)block塊類型的OTA文件。
  • 如果zip文件內(nèi)沒有system.transfer.list文件绵载,而且system文件夾內(nèi)內(nèi)容很全面埂陆,那么它就是一個(gè)file類OTA
  • 如果設(shè)備使用了A/B分區(qū),那么需要一個(gè)payload類的OTA娃豹。
4.1:從block-based OTA導(dǎo)出設(shè)備專有文件(三星tab s5e用的此方案):
  • 創(chuàng)建臨時(shí)文件夾:Create a temporary directory and move there:

    mkdir ~/android/system_temp/ 
    cd ~/android/system_temp/
    
  • 解壓ROM里的system文件(注意path/to/替換為本地文件路徑):Extract system.transfer.list and system.new.dat.br or system.new.dat from the installable LineageOS zip:
    unzip path/to/lineage-*.zip system.transfer.list system.new.dat*

  • 解壓ROM里的vendor文件:If your OTA includes vendor.transfer.list and vendor.new.dat.br or vendor.new.dat (or others), extract them from the installable LineageOS zip as well:
    unzip path/to/lineage-*.zip vendor.transfer.list vendor.new.dat*

  • 將new.dat.br轉(zhuǎn)換成new.dat:In the case of system.new.dat.br/vendor.new.dat.br/super.new.dat.br/etc. (a brotli archive) exists, you will first need to decompress them using the brotli utility:

    sudo apt-get install brotli
    brotli --decompress --output=system.new.dat system.new.dat.br
    And if you have a vendor.dat.new.br (or others) file: 
    brotli --decompress --output=vendor.new.dat vendor.new.dat.br
    
  • 將new.dat轉(zhuǎn)換成鏡像文件:You now need to get a copy of sdat2img. This script can convert the content of block-based OTAs into dumps that can be mounted. sdat2img is available at the following git repository that you can clone with:
    git clone https://github.com/xpirt/sdat2img
    Once you have obtained sdat2img, use it to extract the system image:
    python sdat2img/sdat2img.py system.transfer.list system.new.dat system.img
    And if you have a vendor.dat.new (or others) file:
    python sdat2img/sdat2img.py vendor.transfer.list vendor.new.dat vendor.img

  • 掛載system鏡像和vendor鏡像:You should now have a file named system.img that you can mount as follows:
    mkdir system/ sudo mount system.img system/
    If you have a file named vendor.img, or similar, you can mount them as follows:

    sudo rm -r system/vendor 
    sudo mkdir system/vendor 
    sudo mount vendor.img system/vendor/ 
    

    Unlike the above, if you have a super.dat.new file: (如果不是上面那種情況焚虱,需要這個(gè))
    python sdat2img/sdat2img.py super.transfer.list super.new.dat super.img9+
    You will now have a file named super.img, You need to get a copy of lpunpack to extract images from it. This script can extract the content of the Super partition into it’s respective component partitions that can be mounted. Luckily, lpunpack is easily buildable, executing the following from a LineageOS 17.1 or greater tree:
    source build/envsetup.sh
    breakfast your_device_codename
    m lpunpack
    Once you have built lpunpack, use it to extract the super image:
    lpunpack super.img /output/dir
    You must also now mount any other image files that you have in their respective directories as shown above with vendor.img.

  • 導(dǎo)出文件:After you have mounted the image(s), move to the root directory of the sources of your device and run extract-files.sh as follows:(在LineageOS/device/samsung/gts4lvwifi 目錄下,不要再common目錄)
    ./extract-files.sh ~/android/system_temp/
    This will tell extract-files.sh to get the files from the mounted system dump rather than from a connected device.

  • 解除鏡像掛載:Once you have extracted all the proprietary files, unmount the vendor dump if you mounted it earlier:
    sudo umount ~/android/system_temp/system/vendor
    Then unmount the system dump:
    sudo umount ~/android/system_temp/system

  • 移除臨時(shí)文件夾:Finally, unmount any other images before deleting the no longer needed files:
    rm -rf ~/android/system_temp/

4.2:從file-based OTA導(dǎo)出設(shè)備專有文件:
  • Create a temporary directory to extract the content of the zip and move there:
    mkdir ~/android/system_temp/
    cd ~/android/system_temp/
    
  • Extract the system folder from the zip:
    unzip path/to/lineage-*.zip system/*
  • After you have extracted the system folder, move to the root directory of the sources of your device and run extract-files.sh as follows:
    ./extract-files.sh ~/android/system_temp/
    This will tell extract-files.sh to get the files from the extracted system dump rather than from a connected device.
  • Once you’ve extracted all the proprietary files, you can delete the files that were extracted from the zip:
    rm -rf ~/android/system_temp/
4.3:從payload-based OTA導(dǎo)出設(shè)備專有文件
  • Create a temporary directory to extract the content of the zip and move there:
    mkdir ~/android/system_temp/ 
    cd ~/android/system_temp/
    
  • Extract the payload.bin file from the LineageOS installation zip file (注意要把以下的path/to 替換為文件的真實(shí)路徑):
    unzip /path/to/lineage-*.zip payload.bin
    You will now need to use a tool called update-payload-extractor. To use the tool, you will need python-protobuf, if you do not already have it:
    sudo apt-get install python-protobuf
  • You can now extract the .img files from the payload:
    • If you have a LineageOS build tree checked out already, you can just run the script to extract the payload:
      python /path/to/lineage-tree/lineage/scripts/update-payload-extractor/extract.py payload.bin --output_dir ./
    • If you don’t have a LineageOS build tree checked out, you can clone our scripts repo, and then run the script to extract the payload:
      git clone https://github.com/LineageOS/scripts 
      python /path/to/scripts/update-payload-extractor/extract.py payload.bin --output_dir ./
      
  • It will take a few moments. Once it’s done, we will need to mount the system.img file, and the vendor.img and product.img and system_ext.img files if they exist, to obtain the complete set of proprietary blobs:
    mkdir system/ 
    sudo mount -o ro system.img system/ 
    sudo mount -o ro vendor.img system/vendor/ 
    sudo mount -o ro product.img system/product/ 
    sudo mount -o ro system_ext.img system/system_ext/ 
    
  • Move to the root directory of the sources of your device and run extract-files.sh as follows:
    ./extract-files.sh ~/android/system_temp/
    This will tell extract-files.sh to extract the proprietary blobs from the mounted system dump rather than a connected device.
  • Once it is done, unmount the system dump and remove the now unnecessary files:
    sudo umount -R ~/android/system_temp/system/
    rm -rf ~/android/system_temp/
    

參考:https://wiki.lineageos.org/devices/gts4lvwifi/build

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末懂版,一起剝皮案震驚了整個(gè)濱河市鹃栽,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌定续,老刑警劉巖谍咆,帶你破解...
    沈念sama閱讀 206,723評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異私股,居然都是意外死亡摹察,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,485評論 2 382
  • 文/潘曉璐 我一進(jìn)店門倡鲸,熙熙樓的掌柜王于貴愁眉苦臉地迎上來供嚎,“玉大人,你說我怎么就攤上這事】说危” “怎么了逼争?”我有些...
    開封第一講書人閱讀 152,998評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長劝赔。 經(jīng)常有香客問我誓焦,道長,這世上最難降的妖魔是什么着帽? 我笑而不...
    開封第一講書人閱讀 55,323評論 1 279
  • 正文 為了忘掉前任杂伟,我火速辦了婚禮,結(jié)果婚禮上仍翰,老公的妹妹穿的比我還像新娘赫粥。我一直安慰自己,他們只是感情好予借,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,355評論 5 374
  • 文/花漫 我一把揭開白布越平。 她就那樣靜靜地躺著,像睡著了一般灵迫。 火紅的嫁衣襯著肌膚如雪秦叛。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,079評論 1 285
  • 那天龟再,我揣著相機(jī)與錄音书闸,去河邊找鬼尼变。 笑死利凑,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的嫌术。 我是一名探鬼主播哀澈,決...
    沈念sama閱讀 38,389評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼度气!你這毒婦竟也來了割按?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,019評論 0 259
  • 序言:老撾萬榮一對情侶失蹤磷籍,失蹤者是張志新(化名)和其女友劉穎适荣,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體院领,經(jīng)...
    沈念sama閱讀 43,519評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡弛矛,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,971評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了比然。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片丈氓。...
    茶點(diǎn)故事閱讀 38,100評論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出万俗,到底是詐尸還是另有隱情湾笛,我是刑警寧澤,帶...
    沈念sama閱讀 33,738評論 4 324
  • 正文 年R本政府宣布闰歪,位于F島的核電站覆积,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏竹椒。R本人自食惡果不足惜叉信,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,293評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望于樟。 院中可真熱鬧公条,春花似錦、人聲如沸迂曲。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,289評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽路捧。三九已至关霸,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間杰扫,已是汗流浹背队寇。 一陣腳步聲響...
    開封第一講書人閱讀 31,517評論 1 262
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留章姓,地道東北人佳遣。 一個(gè)月前我還...
    沈念sama閱讀 45,547評論 2 354
  • 正文 我出身青樓,卻偏偏與公主長得像凡伊,于是被迫代替她去往敵國和親零渐。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,834評論 2 345

推薦閱讀更多精彩內(nèi)容