From 601453ef848a00c67d05277b65930638552a1e4c Mon Sep 17 00:00:00 2001 From: cfig Date: Mon, 20 Jun 2016 00:01:04 +0800 Subject: [PATCH] add missing '--pagesize', fix '--board' bug --- README.md | 4 +++- abootimg/src/main/groovy/cfig/bootimg/CArgs.groovy | 2 ++ abootimg/src/main/groovy/cfig/bootimg/Packer.groovy | 9 +++++++-- abootimg/src/main/groovy/cfig/bootimg/Parser.groovy | 3 +++ .../src/main/groovy/cfig/bootimg/repack_with_cmd.groovy | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 74e9318..a8476ba 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Utilies for editing Nexus(or Nexus compatible) devices boot.img , then you don't ## Prerequisite #### Host OS requirement: -The recommended OS is Linux. +Linux or Mac. #### Target Android requirement: @@ -16,6 +16,7 @@ The recommended OS is Linux. - Marshmallow (API Level 23) - Lollipop (API Level 21,22) + - AOSP master You can get a full [Android version list](https://source.android.com/source/build-numbers.html) here. @@ -35,6 +36,7 @@ Your get the flattened kernel and /root filesystem under **$(CURDIR)/build/unzip build/unzip_boot/ ├── bootimg.json ├── kernel + ├── second └── root Then you can edit the actual file contents, like rootfs or kernel. diff --git a/abootimg/src/main/groovy/cfig/bootimg/CArgs.groovy b/abootimg/src/main/groovy/cfig/bootimg/CArgs.groovy index 805a584..94043e3 100644 --- a/abootimg/src/main/groovy/cfig/bootimg/CArgs.groovy +++ b/abootimg/src/main/groovy/cfig/bootimg/CArgs.groovy @@ -56,6 +56,8 @@ class CArgs { ret.add("--board"); ret.add(board); } + ret.add("--pagesize"); + ret.add(Integer.toString(pagesize)); ret.add("--cmdline"); ret.add(cmdline); if (null != os_version) { diff --git a/abootimg/src/main/groovy/cfig/bootimg/Packer.groovy b/abootimg/src/main/groovy/cfig/bootimg/Packer.groovy index 625f21b..d8a6420 100644 --- a/abootimg/src/main/groovy/cfig/bootimg/Packer.groovy +++ b/abootimg/src/main/groovy/cfig/bootimg/Packer.groovy @@ -145,8 +145,13 @@ class Packer { bf.putInt(0); bf.putInt((parse_os_version(inArgs.os_version) << 11) | parse_os_patch_level(inArgs.os_patch_level)) - bf.put(inArgs.board.getBytes()) - bf.put(new byte[16 - inArgs.board.length()]) + if (null == inArgs.board) { + bf.put(new byte[16]); + } else { + bf.put(inArgs.board.getBytes()) + bf.put(new byte[16 - inArgs.board.length()]) + } + bf.put(inArgs.cmdline.substring(0, Math.min(512, inArgs.cmdline.length())).getBytes()) bf.put(new byte[512 - Math.min(512, inArgs.cmdline.length())]) byte[] img_id = hashFile(inArgs.kernel, inArgs.ramdisk, inArgs.second) diff --git a/abootimg/src/main/groovy/cfig/bootimg/Parser.groovy b/abootimg/src/main/groovy/cfig/bootimg/Parser.groovy index 5f3b214..a92ddfd 100644 --- a/abootimg/src/main/groovy/cfig/bootimg/Parser.groovy +++ b/abootimg/src/main/groovy/cfig/bootimg/Parser.groovy @@ -78,6 +78,9 @@ class Parser { inImgInfo.os_patch_level = unparse_os_patch_level(os_and_patch & 0x7ff) } inImgInfo.board = new String(readBytes(is, 16), "UTF-8").trim(); + if (0 == inImgInfo.board.length()) { + inImgInfo.board = null; + } inImgInfo.cmdline = new String(readBytes(is, 512), "UTF-8") inImgInfo.hash = readBytes(is, 32); //hash inImgInfo.cmdline += new String(readBytes(is, 1024), "UTF-8") diff --git a/abootimg/src/main/groovy/cfig/bootimg/repack_with_cmd.groovy b/abootimg/src/main/groovy/cfig/bootimg/repack_with_cmd.groovy index 0cdc1db..8beccc4 100644 --- a/abootimg/src/main/groovy/cfig/bootimg/repack_with_cmd.groovy +++ b/abootimg/src/main/groovy/cfig/bootimg/repack_with_cmd.groovy @@ -8,7 +8,7 @@ void Run(List inCmd, String inWorkdir = null) { ProcessBuilder pb = new ProcessBuilder(inCmd) .directory(new File(inWorkdir)) .redirectErrorStream(true); - Process p = pb.start() + Process p = pb.start(); p.inputStream.eachLine {println it} p.waitFor(); assert 0 == p.exitValue()