android 8.1上面验证,支持所有的android版本,直接放到sdk中执行即可。
 
img2sdat.py
#!/usr/bin/env python
#coding=utf-8
 
import sys
 
if sys.hexversion < 0x02070000:
  print >> sys.stderr, "Python 2.7 or newer is required."
  sys.exit(1)
 
from hashlib import sha1 as sha1
 
import common
import sparse_img
 
OPTIONS = common.OPTIONS
 
try:
    PARTITION_NAME = str(sys.argv[1])
    SYSTEM_IMG = str(sys.argv[2])
    OUTPUT_DIR = str(sys.argv[3])
    OPTIONS.outpath = OUTPUT_DIR
except IndexError:
    print('\nUsage: img2sdat.py <partiton_name> <system_img> <system_new_dir>\n')
    print('  eg:   img2sdat.py system system.img system_new\n')
    print('        <partiton_name>: input partition name')
    print('        <img_name>: input image name')
    print('        <new_dir>: image new dat dir')
    print('        Visit xda thread for more information.\n')
    try:
       input = raw_input
    except NameError: pass
    input('Press ENTER to exit...')
    sys.exit()
 
 
def main(argv):  
  system_tgt = sparse_img.SparseImage(SYSTEM_IMG);
  system_tgt.ResetFileMap()
  system_diff = common.BlockDifference(PARTITION_NAME, system_tgt, src=None, check_first_block=False, version=4)
 
 
if __name__ == '__main__':  
  main(sys.argv[1:])  
目前transfer.list已经最新的支持version=4, system.transfer.list版本进化,这里针对不同的android版本,传入不同的version=1/2/3/4即可
 
对common.py打patch
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 22d95a9..4b981e3 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1406,6 +1406,12 @@ class BlockDifference(object):
     b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads,
                                     version=self.version,
                                     disable_imgdiff=self.disable_imgdiff)
+
+    self.path = os.path.join(OPTIONS.outpath, partition)
+    print (self.path)
+    return
+
     tmpdir = tempfile.mkdtemp()
     OPTIONS.tempfiles.append(tmpdir)
     self.path = os.path.join(tmpdir, partition)
 
然后即可在android的根目录下面执行如下命令:
./build/tools/releasetools/img2sdat.py  system out/target/product/xxxx/system.img out/target/product/xxxx/sdat/
Total of 475136 4096-byte output blocks in 2302 input chunks.
Finding transfers...
Generating digraph...
Finding vertex sequence...
Reversing backward edges...
  0/0 dependencies (0.00%) were violated; 0 source blocks stashed.
Improving vertex order...
Reticulating splines...
940847104  940847104 (100.00%)     new __DATA 0-32765 32768-32769 32889-32890 65536-65537 66033-98301 98304-98305 98425-98426 98922-131070 131072-131073 131569-151714 163840-163841 163961-163962 164458-196605 196608-196609 229376-229377 229497-229498 229994-262141 262144-262145 294912-294913 295033-295034 295530-327677 327680-327681 360448-360449 393216-393217 425984-425985 458752-458753 459249-475135
max stashed blocks: 0  (0 bytes), limit: <unknown>
 
即可在目录out/target/product/xxxx/sdat看到有system.new.dat与system.transfer.list文件生成。
命令格式: img2sdat.py 分区名  img路径   new.dat路径

eg:img2sdat.py  system  system.img  system_out_dir

system.img镜像转换为system.new.dat + system.transfer.list的更多相关文章

  1. Android镜像文件ramdisk.img,system.img,userdata.img介绍

    Android 源码编译后,在out目录下生成的三个镜像文件:ramdisk.img,system.img,userdata.img以及它们对应的目录树root,system,data. ramdis ...

  2. NotSupportedException-无法将类型“System.DateTime”强制转换为类型“System.Object”

    几张图就可以说明一切 2015-03-29 21:54:09,206 [77] ERROR log - System.NotSupportedException: 无法将类型“System.DateT ...

  3. System.Data.Dbtype转换为System.Data.SqlDbType

    最近在做一些OM Mapping的准备工作,新学了一招. 如果要将System.Data.Dbtype转换为System.Data.SqlDbType,以前以为要写Switch Case语句.其实有很 ...

  4. 将System.Drawing.Bitmap转换为Direct2D.D2DBitmap

    最近在尝试Direct2D编程,挺好玩的. 但是有时候还是会用到GDI+来生成图片,但D2D绘图需要用到自己的D2DBitmap类. 因此需要转换,查阅了下网上的资料,写了这么一个方法: using ...

  5. C# 特性 System.ComponentModel 命名空间属性方法大全,System.ComponentModel 命名空间的特性

    目录: System.ComponentModel 特性命名空间与常用类 System.ComponentModel.DataAnnotations ComponentModel - Classes ...

  6. System.Security.SecurityException The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

    [15/08/19 00:03:10] [DataManager-7292-ERROR] System.Reflection.TargetInvocationException: Exception ...

  7. BootStrap入门教程 (一) :手脚架Scaffolding(全局样式(Global Style),格网系统(Grid System),流式格网(Fluid grid System),自定义(Customing),布局(Layouts))

    2011年,twitter的“一小撮”工程师为了提高他们内部的分析和管理能力,用业余时间为他们的产品构建了一套易用.优雅.灵活.可扩展的前端工具集--BootStrap.Bootstrap由MARK ...

  8. 基类包括字段“ScriptManager1”,但其类型(System.Web.UI.ScriptManager)与控件(System.Web.UI.ScriptManager)的类型不兼容

    首先说下原先的情况,就是原本老项目的Web解决方案是使用.net framework 2.0的老版本, 所以机器也安装过Microsoft ASP.NET 2.0 AJAX Extensions..A ...

  9. java 标准输出与标准错误 out与 err 区别 用法 联系 java中的out与err区别 System.out和System.err的区别 System.out.println和System.err.println的区别 Java重定向System.out和System.err

    本文关键词: java 标准输出与标准错误    out与 err 区别 用法 联系  java中的out与err区别  System.out和System.err的区别 System.out.pri ...

随机推荐

  1. 5月份值得一看的 Java 技术干货!

    5月又即将要离我们远去了,这个月有小长假51劳动节,有54青年节,有513母亲节,更有坑爹的520神马节?!! 废话不说,又到了总结上个月干货的时候了,这个月我们带来了各种Java技术干货,都是不得不 ...

  2. Liferay7 BPM门户开发之5: Activiti和Spring集成

    参考文档: https://github.com/jbarrez/spring-boot-with-activiti-examplehttps://github.com/sxyx2008/spring ...

  3. web自动化测试---css方式定位页面元素

    css方式定位的方法也有很多,相较于xpath更灵活一点,下面就介绍下使用方法(以百度输入框为例) 1.通过tag来定位,可以写成如下: driver.find_element_by_css_sele ...

  4. DDD实战进阶第一波(三):开发一般业务的大健康行业直销系统(搭建支持DDD的轻量级框架二)

    了解了DDD的好处与基本的核心组件后,我们先不急着进入支持DDD思想的轻量级框架开发,也不急于直销系统需求分析和具体代码实现,我们还少一块, 那就是经典DDD的架构,只有了解了经典DDD的架构,你才能 ...

  5. 远程连接服务器或云数据库上的mysql服务 - 赖大大

    主要问题有两种: 1.mysql的权限问题. 2.服务器的防火墙和数据库的安全组没设好的问题. 1.权限问题: 首先登录上mysql mysql> use mysql;      #使用mysq ...

  6. Python 虚拟环境 | Mac/Linux下如何避坑安装配置Virtualenv

    1.为什么要使用虚拟环境 在Python中,不同的应用可能需要用到不同版本的第三方包,而这些第三方包被统一存放到目录site-packages中,不同版本的包容易相互覆盖,如安装Django 2.1时 ...

  7. nginx介绍(三) - 虚拟主机

    前言 前面提到过, 由nginx来分发请求到tomcat中, 那么怎么来区分这些tomcat呢? 我们一般访问网站的时候, 是不是可以使用 ip : port (127.0.0.1:8080)的方式来 ...

  8. phpStorm使用技巧总结

    工欲善其事,必先利其器. 拥有一个好的工具不仅可以事半功倍,而且也令人神清气爽. 在编辑器上,我所走过的路是这样的:notepad(对,就是最原始的WIN下的note) -> editplus ...

  9. Python机器学习笔记:sklearn库的学习

    网上有很多关于sklearn的学习教程,大部分都是简单的讲清楚某一方面,其实最好的教程就是官方文档. 官方文档地址:https://scikit-learn.org/stable/ (可是官方文档非常 ...

  10. CSS Font文字样式

    font-style: /* 文字样式 italic(倾斜) | normal */ font-weight: /* 文字是否加粗 bold | normal(正常) */ font-size: /* ...