diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e527600..a24b521a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,9 @@ jobs: - name: Unit Test run: ./gradlew check && ./gradlew clean || true + - name: enable gradle native + run: sed -i "s/bHackingMode = false/bHackingMode = true/g" build.gradle.kts + # Runs a set of commands using the runners shell - name: Integration Test run: | diff --git a/README.md b/README.md index 0ac8e210..275c3366 100644 --- a/README.md +++ b/README.md @@ -182,12 +182,12 @@ If you want to edit the device-tree blob in place: cp vendor_boot.img cp vbmeta.img ./gradlew unpack -==> now you can edit build/unzip_boot/dtb.src directly +==> now you can edit build/unzip_boot/dtb.dts directly ./gradlew pack ``` -During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.src`. -You can edit `dtb.src` directly, and it will be compiled to dtb duing repack stage. +During unpack stage, dtb will be dumped to file `build/unzip_boot/dtb`, dts will be decompiled to `build/unzip_boot/dtb.dts`. +You can edit `dtb.dts` directly, and it will be compiled to dtb duing repack stage. If you just want to replace the dtb with the one that is compiled outside this tool, please @@ -195,7 +195,7 @@ If you just want to replace the dtb with the one that is compiled outside this t cp vendor_boot.img cp vbmeta.img ./gradlew unpack -rm build/unzip_boot/dtb.src +rm build/unzip_boot/dtb.dts cp build/unzip_boot/dtb ./gradlew pack ``` diff --git a/bbootimg/src/main/kotlin/bootimg/Common.kt b/bbootimg/src/main/kotlin/bootimg/Common.kt index 879f11ac..6f82b007 100644 --- a/bbootimg/src/main/kotlin/bootimg/Common.kt +++ b/bbootimg/src/main/kotlin/bootimg/Common.kt @@ -182,7 +182,7 @@ class Common { Helper.extractFile(s.srcFile, s.dumpFile, s.offset.toLong(), s.length) //extract DTB if (EnvironmentVerifier().hasDtc) { - DTC().decompile(s.dumpFile, s.dumpFile + ".src") + DTC().decompile(s.dumpFile, s.dumpFile + "." + Helper.prop("config.dts_suffix")) } } diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt index 4985a2b4..4077017c 100644 --- a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt +++ b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt @@ -80,6 +80,7 @@ data class BootV2( private val log = LoggerFactory.getLogger(BootV2::class.java) private val workDir = Helper.prop("workDir") private val mapper = ObjectMapper() + private val dtsSuffix = Helper.prop("config.dts_suffix") fun parse(fileName: String): BootV2 { val ret = BootV2() @@ -305,8 +306,8 @@ data class BootV2( if (theDtb.size > 0) { it.addRule() it.addRow("dtb", theDtb.file) - if (File(theDtb.file + ".src").exists()) { - it.addRow("\\-- decompiled dts", theDtb.file + ".src") + if (File(theDtb.file + ".${dtsSuffix}").exists()) { + it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}") } } } @@ -386,8 +387,8 @@ data class BootV2( } //refresh dtb size dtb?.let { theDtb -> - if (File(theDtb.file!! + ".src").exists()) { - check(DTC().compile(theDtb.file!! + ".src", theDtb.file!!)) { "fail to compile dts" } + if (File(theDtb.file!! + ".${dtsSuffix}").exists()) { + check(DTC().compile(theDtb.file!! + ".${dtsSuffix}", theDtb.file!!)) { "fail to compile dts" } } theDtb.size = File(theDtb.file!!).length().toInt() } diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt index 1c72cbab..a98751bc 100644 --- a/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt +++ b/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt @@ -78,6 +78,7 @@ data class BootV2Dialects( companion object { private val log = LoggerFactory.getLogger(BootV2Dialects::class.java) private val workDir = Helper.prop("workDir") + private val dtsSuffix = Helper.prop("config.dts_suffix") fun parse(fileName: String): BootV2Dialects { val ret = BootV2Dialects() @@ -313,8 +314,8 @@ data class BootV2Dialects( if (theDtb.size > 0) { it.addRule() it.addRow("dtb", theDtb.file) - if (File(theDtb.file + ".src").exists()) { - it.addRow("\\-- decompiled dts", theDtb.file + ".src") + if (File(theDtb.file + ".${dtsSuffix}").exists()) { + it.addRow("\\-- decompiled dts", theDtb.file + ".${dtsSuffix}") } } } diff --git a/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt b/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt index a3c38377..a09ddfd5 100644 --- a/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt +++ b/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt @@ -158,6 +158,7 @@ data class VendorBoot( private val log = LoggerFactory.getLogger(VendorBoot::class.java) private val workDir = Helper.prop("workDir") private val mapper = ObjectMapper() + private val dtsSuffix = Helper.prop("config.dts_suffix") fun parse(fileName: String): VendorBoot { val ret = VendorBoot() FileInputStream(fileName).use { fis -> @@ -266,8 +267,8 @@ data class VendorBoot( } } //update dtb - if (File(this.dtb.file + ".src").exists()) { - check(DTC().compile(this.dtb.file + ".src", this.dtb.file)) { "fail to compile dts" } + if (File(this.dtb.file + ".${dtsSuffix}").exists()) { + check(DTC().compile(this.dtb.file + ".${dtsSuffix}", this.dtb.file)) { "fail to compile dts" } } this.dtb.size = File(this.dtb.file).length().toInt() //header @@ -421,8 +422,8 @@ data class VendorBoot( } it.addRule() it.addRow("dtb", this.dtb.file) - if (File(this.dtb.file + ".src").exists()) { - it.addRow("\\-- decompiled dts", dtb.file + ".src") + if (File(this.dtb.file + ".${dtsSuffix}").exists()) { + it.addRow("\\-- decompiled dts", dtb.file + ".${dtsSuffix}") } if (this.bootconfig.size > 0) { it.addRule() diff --git a/bbootimg/src/main/kotlin/packable/DtboParser.kt b/bbootimg/src/main/kotlin/packable/DtboParser.kt index 49f0143b..f1e3c39c 100644 --- a/bbootimg/src/main/kotlin/packable/DtboParser.kt +++ b/bbootimg/src/main/kotlin/packable/DtboParser.kt @@ -36,6 +36,7 @@ class DtboParser(val workDir: File) : IPackable { private val log = LoggerFactory.getLogger(DtboParser::class.java) private val envv = EnvironmentVerifier() private val dtboMaker = Helper.prop("dtboMaker") + private val dtsSuffix = Helper.prop("config.dts_suffix") override fun capabilities(): List { return listOf("^dtbo\\.img$") @@ -139,7 +140,7 @@ class DtboParser(val workDir: File) : IPackable { if (envv.hasDtc) { for (i in 0 until Integer.parseInt(props.getProperty("dt_entry_count"))) { val inputDtb = "$dtbPath.$i" - val outputSrc = File(outDir + "/" + File(inputDtb).name + ".src").path + val outputSrc = File(outDir + "/" + File(inputDtb).name + ".${dtsSuffix}").path DTC().decompile(inputDtb, outputSrc) } } else { diff --git a/bbootimg/src/main/kotlin/utils/Dtbo.kt b/bbootimg/src/main/kotlin/utils/Dtbo.kt index 024cdcf7..b3031fa4 100644 --- a/bbootimg/src/main/kotlin/utils/Dtbo.kt +++ b/bbootimg/src/main/kotlin/utils/Dtbo.kt @@ -152,6 +152,7 @@ class Dtbo( private val log = LoggerFactory.getLogger(Dtbo::class.java) private val outDir = Helper.prop("workDir") + private val dtsSuffix = Helper.prop("config.dts_suffix") } fun extractVBMeta(): Dtbo { @@ -186,7 +187,7 @@ class Dtbo( .toInt() // Part II - a for (index in 0 until dtEntries.size) { - DTC().compile("${outDir}dt/dt.${index}.src", "${outDir}dt/dt.${index}") + DTC().compile("${outDir}dt/dt.${index}.${dtsSuffix}", "${outDir}dt/dt.${index}") } // Part II - b var offset = DtboHeader.SIZE + (header.entryCount * DeviceTreeTableEntry.SIZE) @@ -221,7 +222,7 @@ class Dtbo( it.addRow("image info", outDir + info.output.removeSuffix(".img") + ".json") it.addRule() it.addRow("device-tree blob (${this.header.entryCount} blobs)", "${outDir}dt/dt.*") - it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.src") + it.addRow("\\-- device-tree source ", "${outDir}dt/dt.*.${dtsSuffix}") it.addRule() it.addRow("AVB info", Avb.getJsonFileName(info.output)) it.addRule() diff --git a/bbootimg/src/main/resources/general.cfg b/bbootimg/src/main/resources/general.cfg index 45c52592..ca6f271c 100644 --- a/bbootimg/src/main/resources/general.cfg +++ b/bbootimg/src/main/resources/general.cfg @@ -11,3 +11,4 @@ mkbootimg = aosp/system/tools/mkbootimg/mkbootimg.py dtboMaker = aosp/system/libufdt/utils/src/mkdtboimg.py payloadDir = build/payload/ config.allow_cpio_duplicate = true +config.dts_suffix = dts \ No newline at end of file diff --git a/integrationTest.py b/integrationTest.py index c622cb81..a5fc41e1 100755 --- a/integrationTest.py +++ b/integrationTest.py @@ -78,7 +78,7 @@ def verifySingleJson(jsonFile, func = None): subprocess.check_call(gradleWrapper + " pack", shell = True) for k, v in verifyItems["hash"].items(): log.info("%s : %s" % (k, v)) - unittest.TestCase().assertEqual(v, hashFile(k)) + unittest.TestCase().assertIn(hashFile(k), v.split()) try: subprocess.check_call(gradleWrapper + " clear", shell = True) except Exception as e: @@ -161,9 +161,8 @@ def main(): verifySingleJson("%s/issue_59/recovery.json" % resDir2, func = lambda: shutil.rmtree("build/unzip_boot/root", ignore_errors = False)) # Issue 71: dtbo if platform.system() != "Darwin": - pass - #verifySingleDir(resDir2, "issue_71") - #verifySingleDir(resDir2, "issue_71/redfin") + verifySingleDir(resDir2, "issue_71") + verifySingleDir(resDir2, "issue_71/redfin") else: log.info("dtbo not fully supported on MacOS, skip testing") # Issue 83: init_boot diff --git a/src/integrationTest/resources b/src/integrationTest/resources index 0f9f57cb..d683034c 160000 --- a/src/integrationTest/resources +++ b/src/integrationTest/resources @@ -1 +1 @@ -Subproject commit 0f9f57cb3b25ab299acfeb3d2e80b2ad488ff17a +Subproject commit d683034c3e83818b3a1264331b281df650fc2e6b diff --git a/src/integrationTest/resources_2 b/src/integrationTest/resources_2 index 03c9b422..be8c5a2f 160000 --- a/src/integrationTest/resources_2 +++ b/src/integrationTest/resources_2 @@ -1 +1 @@ -Subproject commit 03c9b422e4cc418e2484b7bfeef97d8f3e920db9 +Subproject commit be8c5a2fb19b43ba2b1a8c8d3e29b0d3bbaec958