updater-script命令詳解教你寫刷機(jī)腳本

updater-script命令詳解涡匀,刷機(jī)腳本怎么寫盯腌,這些問(wèn)題都也算是安卓的入門知識(shí)了,今天就和大家講解一下陨瘩,講解人是深度論壇的Seeyou腕够,如果你想學(xué)習(xí)更多ROM制作安卓開(kāi)發(fā)方面的知識(shí),歡迎加入深度DRT團(tuán)隊(duì)舌劳,我們從初級(jí)到高級(jí)給大家系統(tǒng)的講解帚湘。
命令:mount
用法:mount(fs_type, partition_type, location, mount_point)
參數(shù)講解:
fs_type—————–“yaffs2” 或 “ext4”
partition_type———-“MTD” 或 “EMMC”
location—————–分區(qū)(partition) 或 驅(qū)動(dòng)器(device)
mount_poin————掛載文件系統(tǒng)的目標(biāo)文件夾(target folder to mount FS)
作用解釋: 掛載一個(gè)文件系統(tǒng)到指定的掛載點(diǎn)
返 回 值: 掛載成功則返回掛載點(diǎn),失敗返回null
函數(shù)示例: mount(“MTD”, “system”, “/system”);掛載system分區(qū)甚淡,設(shè)置返回指針”/system”
mount(“vfat”, “/dev/block/mmcblk1p2”, “/system”); 掛載/dev/block/mmcblk1p2大诸,返回指針”/system”

命令: format
用法: format(fs_type, partition_type, location)
參數(shù)詳解:
fs_type—————–字符串,數(shù)據(jù)為”yaffs2″ 或 “ext4”
partition_type———-字符串, “MTD” 或 “EMMC”
location—————–字符串, 分區(qū)(partition) 或 驅(qū)動(dòng)器(device)
作用解釋: 格式化為指定的文件系統(tǒng)
函數(shù)示例: format(“MTD”, “system”);格式化system分區(qū)

命令: delete
用法: delete(file1, file2, …, fileN)
參數(shù)詳解: 字符串,要?jiǎng)h除的文件
作用解釋: 刪除一個(gè)文件资柔。最少指定一個(gè)文件焙贷;多個(gè)文件可以做為多個(gè)參數(shù)指定
函數(shù)示例: delete(“/data/zipalign.log”);刪除文件/data/zipalign.log

命令: delete_recursive
用法: delete_recursive(dir1, dir2,…,dirN)
參數(shù)詳解: 字符串,要遞歸刪除的目錄
作用解釋: 刪除文件夾及其包含的所有內(nèi)容建邓。最少指定1個(gè)目錄盈厘;多個(gè)目錄可以做為多個(gè)參數(shù)指定
函數(shù)示例: delete_recursive(“/data/dalvik-cache”);刪除文件夾/data/dalvik-cache

命令: show_progress
用法: show_progress(frac, sec)
參數(shù)詳解:
frac———————-進(jìn)度完成數(shù)值
Sec———————-總秒數(shù)
作用解釋: 顯示在Recovery系統(tǒng)中進(jìn)度
函數(shù)示例: show_progress(0.1, 10);show_progress下面的操作可能進(jìn)行10s,完成后進(jìn)度條前進(jìn)0.1(也就是10%)

命令: set_progress
用法: set_prograss(frac)
參數(shù)詳解: frac———————進(jìn)度數(shù)值
函數(shù)示例:

命令: package_extract_dir
用法: package_extract_dir(package_path, destination_path)
參數(shù)詳解:
package_path———-字符串官边,升級(jí)包內(nèi)要提取的目錄
destination_path——–字符串沸手,提取文件的目標(biāo)目錄
作用解釋: 提取升級(jí)包內(nèi)目錄中的所有文件到指定的目標(biāo)目錄
函數(shù)示例: package_extract_dir(“system”, “/system”);釋放ROM包里system文件夾下所有文件和子文件夾至/system

命令: package_extract_file
用法: package_extract_file(package_path) 或 package_extract_file(package_path, destination_path)
參數(shù)詳解:
package_path———-字符串,升級(jí)包內(nèi)要提取的文件
destination_path——-字符串注簿,提取文件的目標(biāo)目錄
作用解釋: 提取升級(jí)包內(nèi)的單個(gè)文件到指定的目標(biāo)目錄
函數(shù)示例: package_extract_file(“my.zip”, “/system”);解壓ROM包里的my.zip文件至/system

命令: file_getprop
用法: file_getprop(file, key)
參數(shù)詳解:
file———————-字符串契吉,要檢查的文件名
Key———————-字符串,返回?cái)?shù)據(jù)中的文件的鍵名字
作用解釋: 在格式”key”=”value”的文件中取得文件屬性值
函數(shù)示例:

命令: symlink
用法: symlink(target, src1, src2, …, srcN)
參數(shù)詳解:
target——————-字符串诡渴,符號(hào)鏈接的目標(biāo)
srcX ———————字符串捐晶,要?jiǎng)?chuàng)建的符號(hào)鏈接的目標(biāo)點(diǎn)
作用解釋: 在創(chuàng)建新的符號(hào)鏈接之前,要斷開(kāi)已經(jīng)存在的符號(hào)鏈接
函數(shù)示例: symlink(“toolbox”, “/system/bin/ps”);建立指向toolbox的符號(hào)鏈接/system/bin/ps

命令: set_perm
用法: set_perm(uid, gid, mode, file1, file2, …, fileN)
參數(shù)詳解:
uid———————-用戶ID(user id)
Gid———————-用戶組ID(group id)
Mode——————–權(quán)限模式(permission mode)
fileX———————要設(shè)置許可的文件(file to set permission on)
作用解釋: 設(shè)置單個(gè)文件或一系列文件的權(quán)限妄辩,最少指定1個(gè)文件惑灵,前4個(gè)參數(shù)是必須的
函數(shù)示例: set_perm(0,2000,0550, “system/etc/init.goldfish.sh”);設(shè)置手機(jī)system中的etc/init.goldfish.sh的用戶為root眼耀,用戶組為shell英支,所有者以及所屬用戶組成員可以進(jìn)行讀取和執(zhí)行操作,其他用戶無(wú)操作權(quán)限)
這里0代表用戶為root
2000代表用戶組為shell
我們來(lái)說(shuō)明0550這組數(shù)據(jù)哮伟,這組數(shù)據(jù)的最后三位550干花,分別代表“所有者\(yùn)組用戶\其他用戶”的權(quán)限,也就是我們?cè)赗E管理中“用戶\群組\其他”三行楞黄。 我們以XXX來(lái)表示這三組權(quán)限池凄,其中:
×=4 讀的權(quán)限
×=2 寫的權(quán)限
×=1 執(zhí)行的權(quán)限
我們必須首先了解用數(shù)字表示的屬性的含義:0表示沒(méi)有權(quán)限,1表示可執(zhí)行權(quán)限鬼廓,2表示可寫權(quán)限肿仑,4表示可讀權(quán)限,然后將其相加碎税。所以數(shù)字屬性的格式應(yīng)為3個(gè)從0到7的八進(jìn)制數(shù)柏副。
例如,如果想讓某個(gè)文件的屬主有”讀/寫”二種權(quán)限蚣录,需要把4(可讀)+2(可寫)=6(讀/寫)割择。若要rwx屬性則4+2+1=7;若要rw-屬性則4+2=6萎河;若要r-x屬性則4+1=5荔泳。
常用修改權(quán)限的命令:
Set_perm 0 0 0600 ××× (只有所有者有讀和寫的權(quán)限)
Set_perm 0 0 0644 ××× (所有者有讀和寫的權(quán)限蕉饼,組用戶只有讀的權(quán)限)
Set_perm 0 0 0700 ××× (只有所有者有讀和寫以及執(zhí)行的權(quán)限)
Set_perm 0 0 0666 ××× (每個(gè)人都有讀和寫的權(quán)限)
Set_perm 0 0 0777 ××× (每個(gè)人都有讀和寫以及執(zhí)行的權(quán)限)

命令: set_perm_recursive
用法: set_perm_recursive(uid, gid, dirmode, filemode, dir1, dir2, …dirN)
參數(shù)詳解:
uid———————-用戶ID(user id)
Gid———————-用戶組ID(group id)
Dirmode—————-指定目錄內(nèi)的目錄的權(quán)限
Filemode—————指定目錄內(nèi)的文件的權(quán)限
dirX———————要設(shè)置權(quán)限的目標(biāo)
作用解釋: 設(shè)置單個(gè)目錄或一系列目錄的里面的所有文件的權(quán)限,最少指定1個(gè)目錄玛歌,5個(gè)參數(shù)都是必須的
函數(shù)示例: set_perm_recursive 0 0 0755 0644 SYSTEM:app昧港;設(shè)置手機(jī)system/app文件夾及其中文件的用戶為root,用戶組為root支子,app文件夾權(quán)限為所有者可以進(jìn)行讀创肥、寫、執(zhí)行操作值朋,其他用戶可以進(jìn)行讀取和執(zhí)行操作叹侄,其中的文件的權(quán)限為所有者可以進(jìn)行讀寫操作,其他用戶可以進(jìn)行讀取操作

命令: getprop
用法: getprop(key)
參數(shù)詳解: key———————字符串昨登,想要系統(tǒng)返回的屬性
作用解釋: 這個(gè)函數(shù)是用來(lái)返指定的屬性的值趾代。它是用來(lái)從build.props文件中查詢手機(jī)的信息的。
函數(shù)示例:

命令: write_raw_image
用法: write_raw_image(file, partition)
參數(shù)詳解:
file———————-字符串丰辣,要讀取的Img源文件
Partition—————–字符串撒强,要寫入Img文件的目標(biāo)分區(qū)
作用解釋: 這個(gè)函數(shù)是用來(lái)寫Img文件到分區(qū)
函數(shù)示例: write_raw_image(“/tmp/boot.img”, “boot”)將yaffs2格式的boot包直接寫入boot分區(qū)

命令: apply_patch
用法: apply_patch(srcfile, tgtfile, tgtsha1, tgtsize, sha1_1, patch_1, …, sha1_x, patch1_x)
參數(shù)詳解:
srcfile——————-字符串,要打補(bǔ)丁的源文件(要讀入的文件)
Tgtfile——————-字符串笙什,補(bǔ)丁文件要寫入的目標(biāo)文件
tgtsha1—————–字符串飘哨,寫入補(bǔ)丁文件的目標(biāo)文件的sha1哈希值
sha1_x——————字符串,要寫入目標(biāo)文件的補(bǔ)丁數(shù)據(jù)的sha1哈希值 patch1_x—————-字符串琐凭,實(shí)際上應(yīng)用到目標(biāo)文件的補(bǔ)丁
作用解釋: 這個(gè)函數(shù)是用來(lái)打補(bǔ)丁到文件芽隆。
函數(shù)示例:

命令: apply_patch_check
用法: apply_patch_check(file, sha1_1, …, sha1_x)
參數(shù)詳解:
file———————-字符串,要檢查的文件
sha1_x——————要檢查的哈希值
作用解釋: 檢查文件是否已經(jīng)被打補(bǔ)丁淘正,或者能不能被打補(bǔ)丁。需要檢查“applypatch_check ”函數(shù)調(diào)用的源代碼臼闻。

命令: apply_patch_space
用法: apply_patch_space(bytes)
參數(shù)詳解: bytes——————-檢查的字節(jié)的數(shù)字
作用解釋: 檢查緩存來(lái)確定是否有足夠的空間來(lái)寫入補(bǔ)丁文件并返回一些數(shù)據(jù)辞做。
函數(shù)示例:

命令: read_file
用法: read_file(filename)
參數(shù)詳解: filename—————-字符串蛉幸,要讀取內(nèi)容的文件名
作用解釋: 這個(gè)函數(shù)返回文件的內(nèi)容
函數(shù)示例:

命令: sha1_check
用法: sha1_check(data) 或 sha1_check(data, sha1_hex, …, sha1_hexN)
參數(shù)詳解:
data———————要計(jì)算sha1哈希值的文件的內(nèi)容-必須是只讀文件格式
sha1_hexN————–文件數(shù)據(jù)要匹配的特定的十六進(jìn)制sha1_hex哈希值字符串
作用解釋: 如果只指定data參數(shù),這個(gè)函數(shù)返回data參數(shù)的十六進(jìn)制sha1_hex哈希值字符串。其他參數(shù)用來(lái)確認(rèn)你檢查的文件是不是列表中的哈希值的一個(gè)惫撰。 它返回匹配的哈希值,或者在沒(méi)有匹配任何哈希值時(shí)返回空商源。
函數(shù)示例:

命令: ui_print
用法: ui_print(msg1, …, msgN)
參數(shù)詳解: msg———————-字符串萨驶,要處理過(guò)程中輸出給用戶的信息
作用解釋: 在腳本運(yùn)行的時(shí)候,在控制臺(tái)顯示的信息进肯。最少要指定1個(gè)參數(shù)激蹲,你可以指定額外的msg參數(shù),并且它們會(huì)連接起來(lái)輸了
函數(shù)示例: ui_print(“It’s ready!”);屏幕打印It’s ready!

命令: run_program
用法: run_program(prog, arg1, .., argN)
參數(shù)詳解:
prog——————–字符串江掩,要執(zhí)行的程序
argN——————–字符串学辱,要執(zhí)行的程序的運(yùn)行參數(shù)
作用解釋: 以指定的參執(zhí)行程序
函數(shù)示例: run_program(“/system/xbin/installbusybox.sh”);運(yùn)行installbusybox.sh腳本文件

命令: ifelse
用法: ifelse(condition, truecondition, falsecondition)
參數(shù)詳解:
condition—————-要運(yùn)算的表達(dá)式
Truecondition———–當(dāng)值為True時(shí)執(zhí)行的 Edify腳本塊
Falsecodnition———–當(dāng)值為False時(shí)執(zhí)行的 Edify腳本塊
作用解釋: 這是If-then結(jié)構(gòu)的 Edify腳本語(yǔ)言乘瓤。在真條件或非條件下語(yǔ)句可以是單條Edify命令或者腳本塊。腳本塊可以用圓括號(hào)來(lái)界定策泣,用分號(hào)來(lái)隔開(kāi)衙傀。
函數(shù)示例:

命令: abort
用法: abort()
參數(shù)詳解: 沒(méi)有參數(shù)
作用解釋: 中止腳本執(zhí)行
函數(shù)示例:

命令: assert
用法: assert(condition)
參數(shù)詳解: condition—————boolean
作用解釋: 如果condition參數(shù)的計(jì)算結(jié)果為False,則停止腳本執(zhí)行萨咕,否則繼續(xù)執(zhí)行腳本
函數(shù)示例:assert(package_extract_file(“boot.img”,”/tmp/boot.img”),write_raw_image(“/tmp/boot.img”,”boot”),delete(“/tmp/boot.img”))
執(zhí)行package_extract_file统抬,如果不返回錯(cuò)誤則執(zhí)行write_raw_image,如果write_raw_image不出錯(cuò)則執(zhí)行delete

【深度Drt教材】 之 Android刷機(jī)腳本updater-script實(shí)例講解

在這里引用的是c8812的深度os刷機(jī)腳本

assert(getprop(“ro.product.device”) == “c8812” || getprop(“ro.build.product”) == “c8812” ||
getprop(“ro.product.device”) == “C8812” || getprop(“ro.build.product”) == “C8812” ||
getprop(“ro.product.device”) == “hwc8812” || getprop(“ro.build.product”) == “hwc8812” ||
getprop(“ro.product.device”) == “msm7627a” || getprop(“ro.build.product”) == “msm7627a”);

這個(gè)是對(duì)于build.prop機(jī)型名稱進(jìn)行校驗(yàn)危队,校驗(yàn)設(shè)備是否為c8812或者c8812的一些別名聪建,

校驗(yàn)成功的話繼續(xù)刷機(jī)操作,失敗的話終止刷機(jī)交掏,只要是起到一個(gè)保護(hù)的作用妆偏,一面刷錯(cuò)機(jī)器

mount(“ext4”, “EMMC”, “/dev/block/mmcblk0p12”, “/system”);

這個(gè)是掛載system分區(qū),方便后面進(jìn)行讀寫盅弛,用到的參數(shù)在命令講解中都有說(shuō)钱骂,這里需要注意的就是分區(qū)不能寫錯(cuò)了,

掛載出錯(cuò)的話就會(huì)導(dǎo)致刷寫到錯(cuò)誤的分區(qū)上挪鹏,如果是無(wú)關(guān)緊要的分區(qū)可能只是溢出见秽,要是把引導(dǎo)分區(qū)刷了,就變磚了

package_extract_file(“system/bin/backuptool.sh”, “/tmp/backuptool.sh”);
package_extract_file(“system/bin/backuptool.functions”, “/tmp/backuptool.functions”);

這個(gè)是復(fù)制文件到另一個(gè)位置讨盒,可以重新命名

set_perm(0, 0, 0777, “/tmp/backuptool.sh”);
set_perm(0, 0, 0644, “/tmp/backuptool.functions”);

文件的權(quán)限設(shè)定解取,如果文件沒(méi)有權(quán)限的話將不能夠執(zhí)行

run_program(“/tmp/backuptool.sh”, “backup”);

運(yùn)行指定的這個(gè)backuptool.sh shell文件,進(jìn)行backup操作返顺,這個(gè)一般用不到禀苦,都是一些有特殊的要求的第三方

在做rom的時(shí)候,寫一些需要實(shí)現(xiàn)某些功能的腳本文件遂鹊,刷機(jī)的時(shí)候自動(dòng)運(yùn)行振乏,

unmount(“/system”);

卸載system分區(qū)

show_progress(0.500000, 0);

這個(gè)是刷機(jī)進(jìn)度條的設(shè)定

format(“ext4”, “EMMC”, “/dev/block/mmcblk0p12”, “0”, “/system”);

格式化system分區(qū),注意這里是需要5個(gè)參數(shù)秉扑,有的recovery對(duì)參數(shù)又要求慧邮,可能導(dǎo)致刷機(jī)終止

mount(“ext4”, “EMMC”, “/dev/block/mmcblk0p13”, “/data”);

掛載data分區(qū),方便后面進(jìn)行讀寫操作

package_extract_dir(“data”, “/data”);

將rom包中的data文件夾刷寫到手機(jī)的data分區(qū)中

mount(“ext4”, “EMMC”, “/dev/block/mmcblk0p12”, “/system”);

掛載系統(tǒng)分區(qū)舟陆,方便后面進(jìn)行讀寫操作

package_extract_dir(“system”, “/system”);

將rom包中的sys文件夾刷寫到system分區(qū)中

symlink(“Roboto-Bold.ttf”, “/system/fonts/DroidSans-Bold.ttf”);
symlink(“Roboto-Regular.ttf”, “/system/fonts/DroidSans.ttf”);
symlink(“busybox”, “/system/xbin/[“, “/system/xbin/[[“,
“/system/xbin/adjtimex”, “/system/xbin/arp”, “/system/xbin/ash”,
“/system/xbin/awk”, “/system/xbin/base64”, “/system/xbin/basename”,
“/system/xbin/bbconfig”, “/system/xbin/blkid”, “/system/xbin/blockdev”,
“/system/xbin/brctl”, “/system/xbin/bunzip2”, “/system/xbin/bzcat”,
“/system/xbin/bzip2”, “/system/xbin/cal”, “/system/xbin/cat”,
“/system/xbin/catv”, “/system/xbin/chattr”, “/system/xbin/chgrp”,
“/system/xbin/chmod”, “/system/xbin/chown”, “/system/xbin/chroot”,
“/system/xbin/clear”, “/system/xbin/cmp”, “/system/xbin/comm”,
“/system/xbin/cp”, “/system/xbin/cpio”, “/system/xbin/crond”,
“/system/xbin/crontab”, “/system/xbin/cut”, “/system/xbin/date”,
“/system/xbin/dc”, “/system/xbin/dd”, “/system/xbin/depmod”,
“/system/xbin/devmem”, “/system/xbin/df”, “/system/xbin/diff”,
“/system/xbin/dirname”, “/system/xbin/dmesg”, “/system/xbin/dnsd”,
“/system/xbin/dos2unix”, “/system/xbin/du”, “/system/xbin/echo”,
“/system/xbin/ed”, “/system/xbin/egrep”, “/system/xbin/env”,
“/system/xbin/expand”, “/system/xbin/expr”, “/system/xbin/false”,
“/system/xbin/fdisk”, “/system/xbin/fgrep”, “/system/xbin/find”,
“/system/xbin/flash_lock”, “/system/xbin/flash_unlock”,
“/system/xbin/flashcp”, “/system/xbin/flock”, “/system/xbin/fold”,
“/system/xbin/free”, “/system/xbin/freeramdisk”, “/system/xbin/fsync”,
“/system/xbin/ftpget”, “/system/xbin/ftpput”, “/system/xbin/fuser”,
“/system/xbin/getopt”, “/system/xbin/grep”, “/system/xbin/groups”,
“/system/xbin/gunzip”, “/system/xbin/gzip”, “/system/xbin/halt”,
“/system/xbin/head”, “/system/xbin/hexdump”, “/system/xbin/id”,
“/system/xbin/ifconfig”, “/system/xbin/inetd”, “/system/xbin/insmod”,
“/system/xbin/install”, “/system/xbin/iostat”, “/system/xbin/ip”,
“/system/xbin/kill”, “/system/xbin/killall”, “/system/xbin/killall5”,
“/system/xbin/length”, “/system/xbin/less”, “/system/xbin/ln”,
“/system/xbin/losetup”, “/system/xbin/ls”, “/system/xbin/lsattr”,
“/system/xbin/lsmod”, “/system/xbin/lsusb”, “/system/xbin/lzcat”,
“/system/xbin/lzma”, “/system/xbin/lzop”, “/system/xbin/lzopcat”,
“/system/xbin/man”, “/system/xbin/md5sum”, “/system/xbin/mesg”,
“/system/xbin/mkdir”, “/system/xbin/mke2fs”, “/system/xbin/mkfifo”,
“/system/xbin/mkfs.ext2”, “/system/xbin/mkfs.vfat”,
“/system/xbin/mknod”, “/system/xbin/mkswap”, “/system/xbin/mktemp”,
“/system/xbin/modinfo”, “/system/xbin/modprobe”, “/system/xbin/more”,
“/system/xbin/mount”, “/system/xbin/mountpoint”, “/system/xbin/mpstat”,
“/system/xbin/mv”, “/system/xbin/nanddump”, “/system/xbin/nandwrite”,
“/system/xbin/netstat”, “/system/xbin/nice”, “/system/xbin/nohup”,
“/system/xbin/nslookup”, “/system/xbin/ntpd”, “/system/xbin/od”,
“/system/xbin/patch”, “/system/xbin/pgrep”, “/system/xbin/pidof”,
“/system/xbin/ping”, “/system/xbin/pkill”, “/system/xbin/pmap”,
“/system/xbin/poweroff”, “/system/xbin/printenv”, “/system/xbin/printf”,
“/system/xbin/ps”, “/system/xbin/pstree”, “/system/xbin/pwd”,
“/system/xbin/pwdx”, “/system/xbin/rdev”, “/system/xbin/readlink”,
“/system/xbin/realpath”, “/system/xbin/renice”, “/system/xbin/reset”,
“/system/xbin/resize”, “/system/xbin/rev”, “/system/xbin/rm”,
“/system/xbin/rmdir”, “/system/xbin/rmmod”, “/system/xbin/route”,
“/system/xbin/run-parts”, “/system/xbin/rx”, “/system/xbin/sed”,
“/system/xbin/seq”, “/system/xbin/setconsole”, “/system/xbin/setserial”,
“/system/xbin/setsid”, “/system/xbin/sh”, “/system/xbin/sha1sum”,
“/system/xbin/sha256sum”, “/system/xbin/sha512sum”,
“/system/xbin/sleep”, “/system/xbin/sort”, “/system/xbin/split”,
“/system/xbin/stat”, “/system/xbin/strings”, “/system/xbin/stty”,
“/system/xbin/sum”, “/system/xbin/swapoff”, “/system/xbin/swapon”,
“/system/xbin/sync”, “/system/xbin/sysctl”, “/system/xbin/tac”,
“/system/xbin/tail”, “/system/xbin/tar”, “/system/xbin/taskset”,
“/system/xbin/tee”, “/system/xbin/telnet”, “/system/xbin/telnetd”,
“/system/xbin/test”, “/system/xbin/tftp”, “/system/xbin/tftpd”,
“/system/xbin/time”, “/system/xbin/timeout”, “/system/xbin/top”,
“/system/xbin/touch”, “/system/xbin/tr”, “/system/xbin/traceroute”,
“/system/xbin/true”, “/system/xbin/ttysize”, “/system/xbin/tune2fs”,
“/system/xbin/umount”, “/system/xbin/uname”, “/system/xbin/uncompress”,
“/system/xbin/unexpand”, “/system/xbin/uniq”, “/system/xbin/unix2dos”,
“/system/xbin/unlzma”, “/system/xbin/unlzop”, “/system/xbin/unxz”,
“/system/xbin/unzip”, “/system/xbin/uptime”, “/system/xbin/usleep”,
“/system/xbin/uudecode”, “/system/xbin/uuencode”, “/system/xbin/vi”,
“/system/xbin/watch”, “/system/xbin/wc”, “/system/xbin/wget”,
“/system/xbin/which”, “/system/xbin/whoami”, “/system/xbin/xargs”,
“/system/xbin/xz”, “/system/xbin/xzcat”, “/system/xbin/yes”,
“/system/xbin/zcat”);
symlink(“mksh”, “/system/bin/sh”);
symlink(“toolbox”, “/system/bin/cat”, “/system/bin/chmod”,
“/system/bin/chown”, “/system/bin/cmp”, “/system/bin/date”,
“/system/bin/dd”, “/system/bin/df”, “/system/bin/dmesg”,
“/system/bin/getevent”, “/system/bin/getprop”, “/system/bin/hd”,
“/system/bin/id”, “/system/bin/ifconfig”, “/system/bin/iftop”,
“/system/bin/insmod”, “/system/bin/ioctl”, “/system/bin/ionice”,
“/system/bin/kill”, “/system/bin/ln”, “/system/bin/log”,
“/system/bin/ls”, “/system/bin/lsmod”, “/system/bin/lsof”,
“/system/bin/md5”, “/system/bin/mkdir”, “/system/bin/mount”,
“/system/bin/mv”, “/system/bin/nandread”, “/system/bin/netstat”,
“/system/bin/newfs_msdos”, “/system/bin/notify”, “/system/bin/printenv”,
“/system/bin/ps”, “/system/bin/r”, “/system/bin/reboot”,
“/system/bin/renice”, “/system/bin/rm”, “/system/bin/rmdir”,
“/system/bin/rmmod”, “/system/bin/route”, “/system/bin/schedtop”,
“/system/bin/sendevent”, “/system/bin/setconsole”,
“/system/bin/setprop”, “/system/bin/sleep”, “/system/bin/smd”,
“/system/bin/start”, “/system/bin/stop”, “/system/bin/sync”,
“/system/bin/top”, “/system/bin/touch”, “/system/bin/umount”,
“/system/bin/uptime”, “/system/bin/vmstat”, “/system/bin/watchprops”,
“/system/bin/wipe”);

以上是創(chuàng)建toolbox和busybox工具集的符號(hào)鏈接操作误澳,toolbox和busybox都是工具集,

我們?cè)谑褂玫臅r(shí)候都是終端輸入 $busybox ls 這樣才能使用里面包含的ls工具
創(chuàng)建符號(hào)鏈接的意思就是秦躯,將工具集里面的小工具都引用出來(lái)忆谓,我們可以直接在終端輸入工具的名字,然后符號(hào)鏈接會(huì)自動(dòng)找到工具集中的小工具運(yùn)行
這樣方便了工具集的使用

set_perm_recursive(0, 0, 0755, 0644, “/system”);
set_perm_recursive(0, 0, 0755, 0755, “/system/addon.d”);
set_perm_recursive(0, 2000, 0755, 0755, “/system/bin”);
set_perm(0, 3003, 02750, “/system/bin/netcfg”);
set_perm(0, 3004, 02755, “/system/bin/ping”);
set_perm(0, 2000, 06750, “/system/bin/run-as”);
set_perm_recursive(1002, 1002, 0755, 0440, “/system/etc/bluetooth”);
set_perm(0, 0, 0755, “/system/etc/bluetooth”);
set_perm(0, 0, 0644, “/system/etc/bluetooth/BCM4330.hcd”);
set_perm(1000, 1000, 0640, “/system/etc/bluetooth/auto_pairing.conf”);
set_perm(3002, 3002, 0444, “/system/etc/bluetooth/blacklist.conf”);
set_perm(0, 0, 0644, “/system/etc/bluetooth/init.bcm.bt.sh”);
set_perm(1002, 1002, 0440, “/system/etc/dbus.conf”);
set_perm(1014, 2000, 0550, “/system/etc/dhcpcd/dhcpcd-run-hooks”);
set_perm_recursive(0, 2000, 0755, 0755, “/system/etc/init.d”);
set_perm(0, 0, 0755, “/system/etc/init.d”);
set_perm(0, 2000, 0550, “/system/etc/init.goldfish.sh”);
set_perm_recursive(0, 0, 0755, 0555, “/system/etc/ppp”);
set_perm_recursive(0, 2000, 0755, 0644, “/system/vendor”);
set_perm(0, 0, 0644, “/system/vendor/etc/audio_effects.conf”);
set_perm_recursive(0, 2000, 0755, 0755, “/system/xbin”);
set_perm(0, 0, 06755, “/system/xbin/librank”);
set_perm(0, 0, 06755, “/system/xbin/procmem”);
set_perm(0, 0, 06755, “/system/xbin/procrank”);
set_perm(0, 0, 06755, “/system/xbin/su”);

這里是進(jìn)行權(quán)限的設(shè)定踱承,最后一條需要大家注意一下陪毡,這個(gè)是和root權(quán)限有著密切聯(lián)系的米母,su文件就是獲取root權(quán)限的,如果他的權(quán)限設(shè)置的不對(duì)的話可能就會(huì)導(dǎo)致root不成功毡琉,還有一個(gè)需要大家注意的地方就是铁瞒,你賦予權(quán)限的文件一定要存在,否則可能導(dǎo)致刷機(jī)失敗

show_progress(0.200000, 0);
show_progress(0.200000, 10);
package_extract_file(“system/bin/backuptool.sh”, “/tmp/backuptool.sh”);
package_extract_file(“system/bin/backuptool.functions”, “/tmp/backuptool.functions”);
set_perm(0, 0, 0777, “/tmp/backuptool.sh”);
set_perm(0, 0, 0644, “/tmp/backuptool.functions”);
run_program(“/tmp/backuptool.sh”, “restore”);

這些之前講過(guò)了

delete(“/system/bin/backuptool.sh”);
delete(“/system/bin/backuptool.functions”);

這個(gè)是刪除指定的文件

package_extract_file(“system/bin/modelid_cfg.sh”, “/tmp/modelid_cfg.sh”);
set_perm(0, 0, 0777, “/tmp/modelid_cfg.sh”);
run_program(“/tmp/modelid_cfg.sh”, “”);
show_progress(0.200000, 10);

這些之前都講過(guò)了

package_extract_file(“boot.img”, “/dev/block/mmcblk0p15”);

這里是刷寫內(nèi)核boot.img的桅滋,主要需要注意的還是分區(qū)這里

show_progress(0.100000, 0);
unmount(“/data”);
unmount(“/system”);

最后卸載data和system分區(qū)慧耍,用完之后就要卸載,這個(gè)習(xí)慣大家要養(yǎng)成丐谋,尤其是在linux下

如果不卸載的話芍碧,可能會(huì)因?yàn)橐粫r(shí)的疏忽導(dǎo)致數(shù)據(jù)的損壞和丟失。

轉(zhuǎn)載請(qǐng)注明:半夏月 ? updater-script命令詳解教你寫刷機(jī)腳本

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末号俐,一起剝皮案震驚了整個(gè)濱河市泌豆,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌吏饿,老刑警劉巖踪危,帶你破解...
    沈念sama閱讀 217,185評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異猪落,居然都是意外死亡贞远,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,652評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門笨忌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)蓝仲,“玉大人,你說(shuō)我怎么就攤上這事官疲「そ幔” “怎么了?”我有些...
    開(kāi)封第一講書人閱讀 163,524評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵途凫,是天一觀的道長(zhǎng)垢夹。 經(jīng)常有香客問(wèn)我,道長(zhǎng)颖榜,這世上最難降的妖魔是什么棚饵? 我笑而不...
    開(kāi)封第一講書人閱讀 58,339評(píng)論 1 293
  • 正文 為了忘掉前任煤裙,我火速辦了婚禮掩完,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘硼砰。我一直安慰自己且蓬,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,387評(píng)論 6 391
  • 文/花漫 我一把揭開(kāi)白布题翰。 她就那樣靜靜地躺著恶阴,像睡著了一般诈胜。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上冯事,一...
    開(kāi)封第一講書人閱讀 51,287評(píng)論 1 301
  • 那天焦匈,我揣著相機(jī)與錄音,去河邊找鬼昵仅。 笑死缓熟,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的摔笤。 我是一名探鬼主播够滑,決...
    沈念sama閱讀 40,130評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼吕世!你這毒婦竟也來(lái)了彰触?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 38,985評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤命辖,失蹤者是張志新(化名)和其女友劉穎况毅,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體吮龄,經(jīng)...
    沈念sama閱讀 45,420評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡俭茧,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,617評(píng)論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了漓帚。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片母债。...
    茶點(diǎn)故事閱讀 39,779評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖尝抖,靈堂內(nèi)的尸體忽然破棺而出毡们,到底是詐尸還是另有隱情,我是刑警寧澤昧辽,帶...
    沈念sama閱讀 35,477評(píng)論 5 345
  • 正文 年R本政府宣布衙熔,位于F島的核電站,受9級(jí)特大地震影響搅荞,放射性物質(zhì)發(fā)生泄漏红氯。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,088評(píng)論 3 328
  • 文/蒙蒙 一咕痛、第九天 我趴在偏房一處隱蔽的房頂上張望痢甘。 院中可真熱鬧,春花似錦茉贡、人聲如沸塞栅。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,716評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)放椰。三九已至作烟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間砾医,已是汗流浹背拿撩。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,857評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留如蚜,地道東北人绷雏。 一個(gè)月前我還...
    沈念sama閱讀 47,876評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像怖亭,于是被迫代替她去往敵國(guó)和親涎显。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,700評(píng)論 2 354

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