How to execute the install-recovery.sh script?
- 内容介绍
- 文章标签
- 相关推荐
本文共计513个文字,预计阅读时间需要3分钟。
在`init.rc`文件中添加以下内容以安装recovery并设置其启动:
shellservice flash_recovery /system/etc/install-recovery.shclass mainoneshot
将`/system/etc/install-recovery.sh`路径替换为实际路径。
install-recovery.sh&applypatch
install-recovery.sh & applypatch
android/system/core/rootdir/init.rc:
service flash_recovery /system/etc/install-recovery .sh
class main
oneshot
out/target/product/xxx/root/init.rc:
service flash_recovery /system/etc/install-recovery .sh
class main
oneshot
android\bootable\recovery\applypatch
android\build\tools\releasetools\ota_from_target_files
def MakeRecoveryPatch(output_zip, recovery_img, boot_img):
"""Generate a binary patch that creates the recovery image starting
with the boot image. (Most of the space in these images is just the
kernel, which is identical for the two, so the resulting patch
should be efficient.) Add it to the output zip, along with a shell
script that is run from init.rc on first boot to actually do the
patching and install the new recovery image.
recovery_img and boot_img should be File objects for the
corresponding images. info should be the dictionary returned by
common.LoadInfoDict() on the input target_files.
Returns an Item for the shell script, which must be made
executable.
"""
d = common.Difference(recovery_img, boot_img)
_, _, patch = d.ComputePatch()
common.ZipWriteStr(output_zip, "recovery/recovery-from-boot.p" , patch)
Item.Get( "system/recovery-from-boot.p" , dir = False )
boot_type, boot_device = common.GetTypeAndDevice( "/boot" , OPTIONS.info_dict)
recovery_type, recovery_device = common.GetTypeAndDevice( "/recovery" , OPTIONS.info_dict)
sh = """#!/system/bin/sh
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
log -t recovery "Installing new recovery image"
applypatch %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s %(recovery_type)s:%(recovery_device)s %(recovery_sha1)s %(recovery_size)d %(boot_sha1)s:/system/recovery-from-boot.p
else
log -t recovery "Recovery image already installed"
fi
""" % { 'boot_size' : boot_img.size,
'boot_sha1' : boot_img.sha1,
'recovery_size' : recovery_img.size,
'recovery_sha1' : recovery_img.sha1,
'boot_type' : boot_type,
'boot_device' : boot_device,
'recovery_type' : recovery_type,
'recovery_device' : recovery_device,
}
common.ZipWriteStr(output_zip, "recovery/etc/install-recovery.sh" , sh)
return Item.Get( "system/etc/install-recovery.sh" , dir = False )
5.ota.zip\recovery\etc\install-recovery.sh:
#!/system/bin/sh
if ! applypatch - c MTD:recovery: 3586808 :a1bdc75a0eaa8faf855807c3b60c43dbcfb1400a; then
log - t recovery "Installing new recovery image"
applypatch MTD:boot: 3776935 : 6cbe8dfacd08ba5cfa39b97e16de0d1f8176c0ed MTD:recovery a1bdc75a0eaa8faf855807c3b60c43dbcfb1400a 3586808 6cbe8dfacd08ba5cfa39b97e16de0d1f8176c0ed : / system / recovery - from - boot.p
else
log - t recovery "Recovery image already installed"
fi
Recoverywillneveroverwriteitself,insteaditwillinstalla/system/etc/install-recovery.shscripttoupdaterecoveryonthenextbootup;thisensuresthatthesystemisalwayscapableofbootingintorecoveryevenifthenormalbootupfails.Theinstall-recovery.shscriptworksbycombiningbootwithapatchandwritingtheresulttotherecoverypartition.
本文共计513个文字,预计阅读时间需要3分钟。
在`init.rc`文件中添加以下内容以安装recovery并设置其启动:
shellservice flash_recovery /system/etc/install-recovery.shclass mainoneshot
将`/system/etc/install-recovery.sh`路径替换为实际路径。
install-recovery.sh&applypatch
install-recovery.sh & applypatch
android/system/core/rootdir/init.rc:
service flash_recovery /system/etc/install-recovery .sh
class main
oneshot
out/target/product/xxx/root/init.rc:
service flash_recovery /system/etc/install-recovery .sh
class main
oneshot
android\bootable\recovery\applypatch
android\build\tools\releasetools\ota_from_target_files
def MakeRecoveryPatch(output_zip, recovery_img, boot_img):
"""Generate a binary patch that creates the recovery image starting
with the boot image. (Most of the space in these images is just the
kernel, which is identical for the two, so the resulting patch
should be efficient.) Add it to the output zip, along with a shell
script that is run from init.rc on first boot to actually do the
patching and install the new recovery image.
recovery_img and boot_img should be File objects for the
corresponding images. info should be the dictionary returned by
common.LoadInfoDict() on the input target_files.
Returns an Item for the shell script, which must be made
executable.
"""
d = common.Difference(recovery_img, boot_img)
_, _, patch = d.ComputePatch()
common.ZipWriteStr(output_zip, "recovery/recovery-from-boot.p" , patch)
Item.Get( "system/recovery-from-boot.p" , dir = False )
boot_type, boot_device = common.GetTypeAndDevice( "/boot" , OPTIONS.info_dict)
recovery_type, recovery_device = common.GetTypeAndDevice( "/recovery" , OPTIONS.info_dict)
sh = """#!/system/bin/sh
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
log -t recovery "Installing new recovery image"
applypatch %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s %(recovery_type)s:%(recovery_device)s %(recovery_sha1)s %(recovery_size)d %(boot_sha1)s:/system/recovery-from-boot.p
else
log -t recovery "Recovery image already installed"
fi
""" % { 'boot_size' : boot_img.size,
'boot_sha1' : boot_img.sha1,
'recovery_size' : recovery_img.size,
'recovery_sha1' : recovery_img.sha1,
'boot_type' : boot_type,
'boot_device' : boot_device,
'recovery_type' : recovery_type,
'recovery_device' : recovery_device,
}
common.ZipWriteStr(output_zip, "recovery/etc/install-recovery.sh" , sh)
return Item.Get( "system/etc/install-recovery.sh" , dir = False )
5.ota.zip\recovery\etc\install-recovery.sh:
#!/system/bin/sh
if ! applypatch - c MTD:recovery: 3586808 :a1bdc75a0eaa8faf855807c3b60c43dbcfb1400a; then
log - t recovery "Installing new recovery image"
applypatch MTD:boot: 3776935 : 6cbe8dfacd08ba5cfa39b97e16de0d1f8176c0ed MTD:recovery a1bdc75a0eaa8faf855807c3b60c43dbcfb1400a 3586808 6cbe8dfacd08ba5cfa39b97e16de0d1f8176c0ed : / system / recovery - from - boot.p
else
log - t recovery "Recovery image already installed"
fi
Recoverywillneveroverwriteitself,insteaditwillinstalla/system/etc/install-recovery.shscripttoupdaterecoveryonthenextbootup;thisensuresthatthesystemisalwayscapableofbootingintorecoveryevenifthenormalbootupfails.Theinstall-recovery.shscriptworksbycombiningbootwithapatchandwritingtheresulttotherecoverypartition.

