生產(chǎn)環(huán)境:Ubuntu-18.04,已有工具:repo深寥、git江解、androidSDK。已有設(shè)備三星tab s5e
1.事先準(zhǔn)備
- 下載必需組件:
注意:apt-get install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
linux-libc-dev_4.15.0-188.199_amd64
在security.ubuntu.com倉庫已經(jīng)找不到脐彩,需要手動(dòng)下載安裝碎乃,下載地址: - 如果ubuntu版本低于20.04仍需要安裝:
sudo apt-get install libwxgtk3.0-dev
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é))
- 方法1:設(shè)備專有文件可以通過一個(gè)已經(jīng)刷入lineageOS的設(shè)備中導(dǎo)出:準(zhǔn)備一個(gè)可root 調(diào)試并且已刷入lineageOS的設(shè)備,連接電腦惠奸。然后在
-
構(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.img
9+
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 needpython-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 ./
- If you have a LineageOS build tree checked out already, you can just run the script to extract the payload:
- 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/