From c55f584f2e5c53d6c0a83531e76b1b66657a9827 Mon Sep 17 00:00:00 2001
From: cfig <yuyezhong@gmail.com>
Date: Tue, 3 Jun 2025 15:04:53 +0800
Subject: [PATCH] windows: install gzip, 7zip

disable c++ modules in settings.gradle.kts
add copyright.kts
---
 .github/workflows/main.yml                    |   2 +-
 README.md                                     |   2 +-
 bbootimg/src/main/kotlin/avb/AVBInfo.kt       |   2 +-
 bbootimg/src/main/kotlin/avb/Avb.kt           |   2 +-
 bbootimg/src/main/kotlin/avb/alg/Algorithm.kt |   2 +-
 .../src/main/kotlin/avb/alg/Algorithms.kt     |   2 +-
 bbootimg/src/main/kotlin/avb/blob/AuthBlob.kt |   2 +-
 bbootimg/src/main/kotlin/avb/blob/AuxBlob.kt  |   2 +-
 bbootimg/src/main/kotlin/avb/blob/Footer.kt   |   2 +-
 bbootimg/src/main/kotlin/avb/blob/Header.kt   |   2 +-
 .../avb/desc/ChainPartitionDescriptor.kt      |   2 +-
 .../src/main/kotlin/avb/desc/Descriptor.kt    |   2 +-
 .../main/kotlin/avb/desc/HashDescriptor.kt    |   2 +-
 .../kotlin/avb/desc/HashTreeDescriptor.kt     |   2 +-
 .../avb/desc/KernelCmdlineDescriptor.kt       |   2 +-
 .../kotlin/avb/desc/PropertyDescriptor.kt     |   2 +-
 .../main/kotlin/avb/desc/UnknownDescriptor.kt |   2 +-
 bbootimg/src/main/kotlin/bootimg/Common.kt    |   2 +-
 bbootimg/src/main/kotlin/bootimg/Signer.kt    |   2 +-
 .../main/kotlin/bootimg/cpio/AndroidCpio.kt   |   2 +-
 .../kotlin/bootimg/cpio/AndroidCpioEntry.kt   |   2 +-
 .../main/kotlin/bootimg/cpio/NewAsciiCpio.kt  |   2 +-
 .../main/kotlin/bootimg/v2/BootHeaderV2.kt    |   2 +-
 bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt |  17 +-
 .../main/kotlin/bootimg/v2/BootV2Dialects.kt  |   2 +-
 .../main/kotlin/bootimg/v3/BootHeaderV3.kt    |   2 +-
 bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt |  74 +++-----
 .../src/main/kotlin/bootimg/v3/VendorBoot.kt  |   2 +-
 .../kotlin/bootimg/v3/VendorBootHeader.kt     |   2 +-
 bbootimg/src/main/kotlin/init/BootReason.kt   |  14 ++
 bbootimg/src/main/kotlin/init/Reboot.kt       |   2 +-
 .../src/main/kotlin/ota/DeltaGenerator.kt     |   2 +-
 bbootimg/src/main/kotlin/ota/Payload.kt       |   2 +-
 .../src/main/kotlin/ota/PayloadGenerator.kt   |   2 +-
 .../src/main/kotlin/packable/BootImgParser.kt |  61 +------
 .../main/kotlin/packable/DeviceTreeParser.kt  |  14 ++
 .../src/main/kotlin/packable/DtboParser.kt    |   2 +-
 .../src/main/kotlin/packable/IPackable.kt     |   2 +-
 .../src/main/kotlin/packable/MiscImgParser.kt |   2 +-
 .../src/main/kotlin/packable/OTAzipParser.kt  |   2 +-
 .../main/kotlin/packable/PackableLauncher.kt  |   2 +-
 .../main/kotlin/packable/PayloadBinParser.kt  |   2 +-
 .../src/main/kotlin/packable/VBMetaParser.kt  |   2 +-
 .../main/kotlin/packable/VendorBootParser.kt  |   2 +-
 bbootimg/src/main/kotlin/rom/fdt/DTC.kt       |   2 +-
 bbootimg/src/main/kotlin/rom/fdt/Dtbo.kt      |  14 ++
 .../src/main/kotlin/rom/misc/BootControl.kt   |   2 +-
 .../src/main/kotlin/rom/misc/MiscImage.kt     |  14 ++
 .../main/kotlin/rom/sparse/BaseGenerator.kt   |  14 ++
 .../main/kotlin/rom/sparse/ErofsGenerator.kt  |  14 ++
 .../main/kotlin/rom/sparse/Ext4Generator.kt   |  14 ++
 .../src/main/kotlin/rom/sparse/SparseImage.kt |  25 ++-
 .../main/kotlin/rom/sparse/SparseImgParser.kt |   7 +-
 .../main/kotlin/utils/EnvironmentVerifier.kt  |   2 +-
 .../src/main/kotlin/utils/KernelExtractor.kt  |   2 +-
 .../main/kotlin/cfig/helper/CryptoHelper.kt   |  14 ++
 .../src/main/kotlin/cfig/helper/Dumpling.kt   |  14 ++
 helper/src/main/kotlin/cfig/helper/Helper.kt  |   2 +-
 .../src/main/kotlin/cfig/helper/Launcher.kt   |  14 ++
 .../main/kotlin/cfig/helper/OpenSslHelper.kt  |  14 ++
 .../src/main/kotlin/cfig/helper/ZipHelper.kt  |   2 +-
 settings.gradle.kts                           |   6 +-
 src/integrationTest/resources_2               |   2 +-
 tools/copyright.kts                           | 166 ++++++++++++++++++
 64 files changed, 428 insertions(+), 174 deletions(-)
 create mode 100644 tools/copyright.kts

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 16d54c5..9388cb2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -87,7 +87,7 @@ jobs:
         run: python -c "import sys; print(sys.version)"
 
       - name: choco
-        run: choco install openssl dtc-msys2 zip vim
+        run: choco install openssl dtc-msys2 zip vim gzip 7zip
 
       - name: Unit Test
         run: ./gradlew.bat check && ./gradlew.bat clean || true
diff --git a/README.md b/README.md
index 679c0d6..0404578 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Make sure you have [JDK11+](https://www.oracle.com/java/technologies/downloads/#
 * Mac: `brew install lz4 xz dtc`
 
 * Windows: Install openssl and device-tree compiler with [chocolate](https://chocolatey.org/install)
-`choco install openssl dtc-msys2 zip vim`
+`choco install openssl dtc-msys2 zip vim gzip 7zip`
 
 ## Getting Started
 Put your boot.img to current directory, then start gradle 'unpack' task:
diff --git a/bbootimg/src/main/kotlin/avb/AVBInfo.kt b/bbootimg/src/main/kotlin/avb/AVBInfo.kt
index 8adf031..48e883d 100644
--- a/bbootimg/src/main/kotlin/avb/AVBInfo.kt
+++ b/bbootimg/src/main/kotlin/avb/AVBInfo.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/Avb.kt b/bbootimg/src/main/kotlin/avb/Avb.kt
index 2185a08..9cb24a4 100644
--- a/bbootimg/src/main/kotlin/avb/Avb.kt
+++ b/bbootimg/src/main/kotlin/avb/Avb.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/alg/Algorithm.kt b/bbootimg/src/main/kotlin/avb/alg/Algorithm.kt
index 03308ff..c25feb6 100644
--- a/bbootimg/src/main/kotlin/avb/alg/Algorithm.kt
+++ b/bbootimg/src/main/kotlin/avb/alg/Algorithm.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2021 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt b/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
index 9663f1d..5604bb7 100644
--- a/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
+++ b/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/blob/AuthBlob.kt b/bbootimg/src/main/kotlin/avb/blob/AuthBlob.kt
index b7fa72e..e8435bb 100644
--- a/bbootimg/src/main/kotlin/avb/blob/AuthBlob.kt
+++ b/bbootimg/src/main/kotlin/avb/blob/AuthBlob.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/blob/AuxBlob.kt b/bbootimg/src/main/kotlin/avb/blob/AuxBlob.kt
index 7a5ca83..67aed29 100644
--- a/bbootimg/src/main/kotlin/avb/blob/AuxBlob.kt
+++ b/bbootimg/src/main/kotlin/avb/blob/AuxBlob.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/blob/Footer.kt b/bbootimg/src/main/kotlin/avb/blob/Footer.kt
index c33701d..252fd69 100644
--- a/bbootimg/src/main/kotlin/avb/blob/Footer.kt
+++ b/bbootimg/src/main/kotlin/avb/blob/Footer.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/blob/Header.kt b/bbootimg/src/main/kotlin/avb/blob/Header.kt
index 6275c5d..94b1048 100644
--- a/bbootimg/src/main/kotlin/avb/blob/Header.kt
+++ b/bbootimg/src/main/kotlin/avb/blob/Header.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
index 6733280..8a64a47 100644
--- a/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt b/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
index 3521b4d..eba8493 100644
--- a/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2021 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
index a6bfe87..d7364ee 100644
--- a/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
index ebdb353..06267b9 100644
--- a/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
index a71cc92..663f905 100644
--- a/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
index 50df4ee..2354788 100644
--- a/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
index b1954ea..2d8c56c 100644
--- a/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2018-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/Common.kt b/bbootimg/src/main/kotlin/bootimg/Common.kt
index 6a58cea..91ae21f 100644
--- a/bbootimg/src/main/kotlin/bootimg/Common.kt
+++ b/bbootimg/src/main/kotlin/bootimg/Common.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/Signer.kt b/bbootimg/src/main/kotlin/bootimg/Signer.kt
index 600a29a..2ea15d4 100644
--- a/bbootimg/src/main/kotlin/bootimg/Signer.kt
+++ b/bbootimg/src/main/kotlin/bootimg/Signer.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpio.kt b/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpio.kt
index 59e5925..4ab7021 100644
--- a/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpio.kt
+++ b/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpio.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpioEntry.kt b/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpioEntry.kt
index 0afbd5b..ca35efd 100644
--- a/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpioEntry.kt
+++ b/bbootimg/src/main/kotlin/bootimg/cpio/AndroidCpioEntry.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2021 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/cpio/NewAsciiCpio.kt b/bbootimg/src/main/kotlin/bootimg/cpio/NewAsciiCpio.kt
index 6d9e47b..4895531 100644
--- a/bbootimg/src/main/kotlin/bootimg/cpio/NewAsciiCpio.kt
+++ b/bbootimg/src/main/kotlin/bootimg/cpio/NewAsciiCpio.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootHeaderV2.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootHeaderV2.kt
index f242b5a..5fbf667 100644
--- a/bbootimg/src/main/kotlin/bootimg/v2/BootHeaderV2.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v2/BootHeaderV2.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt
index 9530d06..52a72da 100644
--- a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -345,16 +345,18 @@ data class BootV2(
             this.secondBootloader?.let { theSecondBootloader ->
                 if (theSecondBootloader.size > 0) {
                     it.addRule()
-                    it.addRow("second bootloader", theSecondBootloader.file)
-                    prints.add(Pair("second bootloader", theSecondBootloader.file.toString()))
+                    val tmp = theSecondBootloader.file?.let { file -> shortenPath(file) } ?: "NONE"
+                    it.addRow("second bootloader", tmp)
+                    prints.add(Pair("second bootloader", tmp))
                 }
             }
             //dtbo
             this.recoveryDtbo?.let { theDtbo ->
                 if (theDtbo.size > 0) {
                     it.addRule()
-                    it.addRow("recovery dtbo", theDtbo.file)
-                    prints.add(Pair("recovery dtbo", theDtbo.file.toString()))
+                    val tmp = theDtbo.file.toString()
+                    it.addRow("recovery dtbo", tmp)
+                    prints.add(Pair("recovery dtbo", tmp))
                 }
             }
             //dtb
@@ -362,8 +364,9 @@ data class BootV2(
                 if (theDtb.size > 0) {
                     val dtbCount = this.dtb!!.dtbList.size
                     it.addRule()
-                    it.addRow("dtb", theDtb.file?.let { fullPath -> shortenPath(fullPath) })
-                    prints.add(Pair("dtb", shortenPath(theDtb.file.toString())))
+                    val tmp = shortenPath(shortenPath(theDtb.file!!))
+                    it.addRow("dtb", tmp)
+                    prints.add(Pair("dtb", tmp))
                     if (File(theDtb.file + ".0.${dtsSuffix}").exists()) {
                         it.addRow("\\-- decompiled dts [$dtbCount]", shortenPath(theDtb.file!!) + ".*.${dtsSuffix}")
                         prints.add(Pair("\\-- decompiled dts [$dtbCount]", shortenPath(theDtb.file!!) + ".*.${dtsSuffix}"))
diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt
index de8b396..fca106c 100644
--- a/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v2/BootV2Dialects.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2021-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/v3/BootHeaderV3.kt b/bbootimg/src/main/kotlin/bootimg/v3/BootHeaderV3.kt
index d346a4f..1bce184 100644
--- a/bbootimg/src/main/kotlin/bootimg/v3/BootHeaderV3.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v3/BootHeaderV3.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt b/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt
index 0f2dfd1..2e2aafa 100644
--- a/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -214,57 +214,21 @@ data class BootV3(
         return this
     }
 
-    fun sign(fileName: String): BootV3 {
-        var bSigningNeeded = false
-        if (File(Avb.getJsonFileName(info.role)).exists()) {
-            bSigningNeeded = true
-            Signer.signAVB(
-                Helper.joinPath(Helper.prop("intermediateDir")!!, info.role),
-                this.info.imageSize,
-                String.format(Helper.prop("avbtool")!!, "v1.2")
-            )
+    fun sign(outputFile: String): BootV3 {
+        val bSigningNeeded = File(Avb.getJsonFileName(info.role)).exists()
+        val origOutFile = Helper.joinPath(Helper.prop("intermediateDir")!!, info.role)
+        val clearOutFile = Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".clear")
+        val signedOutFile = Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".signed")
+        if (bSigningNeeded) {
+            Signer.signAVB(origOutFile, this.info.imageSize, String.format(Helper.prop("avbtool")!!, "v1.2"))
+            File(signedOutFile).copyTo(File(outputFile), true)
+            log.info("Signed image saved as $outputFile")
         } else {
-            bSigningNeeded = false
             log.warn("no AVB info found, assume it's clear image")
+            File(clearOutFile).copyTo(File(outputFile), true)
+            log.info("Unsigned image saved as $outputFile")
         }
-
-        if (fileName != info.role) {
-            if (bSigningNeeded) {
-                log.info("x1")
-                Helper.setProp("out.file", "$fileName.signed")
-                //@formatter:off
-                File(Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".signed"))
-                    .copyTo(File(Helper.prop("out.file")!!), true)
-                //@formatter:on
-                log.info("Signed image saved as " + Helper.prop("out.file"))
-            } else {
-                log.info("x2")
-                Helper.setProp("out.file", fileName)
-                //@formatter:off
-                File(Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".clear"))
-                    .copyTo(File(Helper.prop("out.file")!!), true)
-                //@formatter:on
-                log.info("Unsigned image saved as " + Helper.prop("out.file"))
-            }
-        } else {
-            if (bSigningNeeded) {
-                log.info("x3")
-                Helper.setProp("out.file", info.role + ".signed")
-                //@formatter:off
-                File(Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".signed"))
-                    .copyTo(File(info.role + ".signed"), true)
-                //@formatter:on
-                log.info("Signed image saved as ${info.role}.signed")
-            } else {
-                log.info("x4")
-                Helper.setProp("out.file", info.role + ".clear")
-                //@formatter:off
-                File(Helper.joinPath(Helper.prop("intermediateDir")!!, info.role + ".clear"))
-                    .copyTo(File(info.role + ".clear"), true)
-                //@formatter:on
-                log.info("Unsigned image saved as ${info.role}.clear")
-            }
-        }
+        Helper.setProp("out.file", outputFile)
         return this
     }
 
@@ -392,14 +356,22 @@ data class BootV3(
         val tab = AsciiTable().let {
             it.addRule()
             it.addRow("image info", shortenPath(Helper.joinPath(workDir!!, info.role.removeSuffix(".img") + ".json")))
-            prints.add(Pair("image info", shortenPath(Helper.joinPath(workDir, info.role.removeSuffix(".img") + ".json"))))
+            prints.add(
+                Pair(
+                    "image info",
+                    shortenPath(Helper.joinPath(workDir, info.role.removeSuffix(".img") + ".json"))
+                )
+            )
             it.addRule()
             if (this.kernel.size > 0) {
                 it.addRow("kernel", shortenPath(this.kernel.file))
                 prints.add(Pair("kernel", shortenPath(this.kernel.file)))
                 File(Helper.joinPath(workDir, Helper.prop("kernelVersionStem")!!)).let { kernelVersionFile ->
                     if (kernelVersionFile.exists()) {
-                        it.addRow("\\-- version " + kernelVersionFile.readLines().toString(), shortenPath( kernelVersionFile.path))
+                        it.addRow(
+                            "\\-- version " + kernelVersionFile.readLines().toString(),
+                            shortenPath(kernelVersionFile.path)
+                        )
                         prints.add(
                             Pair(
                                 "\\-- version " + kernelVersionFile.readLines().toString(),
diff --git a/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt b/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt
index 8d8c957..61680af 100644
--- a/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v3/VendorBoot.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/bootimg/v3/VendorBootHeader.kt b/bbootimg/src/main/kotlin/bootimg/v3/VendorBootHeader.kt
index ad7c5d5..d31aa64 100644
--- a/bbootimg/src/main/kotlin/bootimg/v3/VendorBootHeader.kt
+++ b/bbootimg/src/main/kotlin/bootimg/v3/VendorBootHeader.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2022 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/init/BootReason.kt b/bbootimg/src/main/kotlin/init/BootReason.kt
index 61afe17..97413b0 100644
--- a/bbootimg/src/main/kotlin/init/BootReason.kt
+++ b/bbootimg/src/main/kotlin/init/BootReason.kt
@@ -1,3 +1,17 @@
+// Copyright 2022 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package init
 
 class BootReason {
diff --git a/bbootimg/src/main/kotlin/init/Reboot.kt b/bbootimg/src/main/kotlin/init/Reboot.kt
index 4a0e229..6754cf0 100644
--- a/bbootimg/src/main/kotlin/init/Reboot.kt
+++ b/bbootimg/src/main/kotlin/init/Reboot.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2023 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/ota/DeltaGenerator.kt b/bbootimg/src/main/kotlin/ota/DeltaGenerator.kt
index d5623bf..14ebe49 100644
--- a/bbootimg/src/main/kotlin/ota/DeltaGenerator.kt
+++ b/bbootimg/src/main/kotlin/ota/DeltaGenerator.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2022-2023 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/ota/Payload.kt b/bbootimg/src/main/kotlin/ota/Payload.kt
index e7cea30..c6b4217 100644
--- a/bbootimg/src/main/kotlin/ota/Payload.kt
+++ b/bbootimg/src/main/kotlin/ota/Payload.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2022-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/ota/PayloadGenerator.kt b/bbootimg/src/main/kotlin/ota/PayloadGenerator.kt
index 7f6cee9..3fafec9 100644
--- a/bbootimg/src/main/kotlin/ota/PayloadGenerator.kt
+++ b/bbootimg/src/main/kotlin/ota/PayloadGenerator.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2022-2023 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/BootImgParser.kt b/bbootimg/src/main/kotlin/packable/BootImgParser.kt
index 4123292..05c7eab 100644
--- a/bbootimg/src/main/kotlin/packable/BootImgParser.kt
+++ b/bbootimg/src/main/kotlin/packable/BootImgParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -96,7 +96,6 @@ class BootImgParser : IPackable {
     fun packInternal(workspace: String, outFileName: String) {
         log.info("packInternal($workspace, $outFileName)")
         Helper.setProp("workDir", workspace)
-        val targetFile = outFileName
         val iniRole = Common.loadProperties(File(workspace, "workspace.ini").canonicalPath).getProperty("role")
         val cfgFile = File(workspace, iniRole.removeSuffix(".img") + ".json").canonicalPath
         log.info("Loading config from $cfgFile")
@@ -137,61 +136,7 @@ class BootImgParser : IPackable {
             is BootV3 -> {
                 worker
                     .pack()
-                    .sign(targetFile)
-                    .updateVbmeta()
-                    .printPackSummary(worker.info.role)
-            }
-
-            else -> {
-                log.error("unsupported boot image format")
-                exitProcess(2)
-            }
-        }
-    }
-
-    fun packInternalLegacy(targetFile: String, workspace: String, fileName: String) {
-        log.info("packInternal(targetFile: $targetFile, fileName: $fileName, workspace: $workspace)")
-        Helper.setProp("workDir", workspace)
-        val cfgFile = Helper.joinPath(outDir, targetFile.removeSuffix(".img") + ".json")
-        log.info("Loading config from $cfgFile")
-        if (!File(cfgFile).exists()) {
-            val tab = AsciiTable().let {
-                it.addRule()
-                it.addRow("'$cfgFile' doesn't exist, did you forget to 'unpack' ?")
-                it.addRule()
-                it
-            }
-            log.info("\n{}", tab.render())
-            return
-        }
-
-        val worker =
-            try {
-                ObjectMapper().readValue(File(cfgFile), BootV2::class.java)
-            } catch (e: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException) {
-                try {
-                    ObjectMapper().readValue(File(cfgFile), BootV3::class.java)
-                } catch (e: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException) {
-                    null
-                }
-            }
-        if (worker == null) {
-            log.error("no worker available")
-            exitProcess(2)
-        }
-        when (worker) {
-            is BootV2 -> {
-                worker
-                    .pack()
-                    .sign()
-                    .updateVbmeta()
-                    .printPackSummary()
-            }
-
-            is BootV3 -> {
-                worker
-                    .pack()
-                    .sign(fileName)
+                    .sign(outFileName)
                     .updateVbmeta()
                     .printPackSummary(worker.info.role)
             }
@@ -231,7 +176,7 @@ class BootImgParser : IPackable {
     }
 
     override fun `@verify`(fileName: String) {
-        File(Helper.prop("workDir")!!).let {
+        File(outDir).let {
             if (!it.exists()) {
                 it.mkdirs()
             }
diff --git a/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt b/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt
index db14255..4a9bd0d 100644
--- a/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt
+++ b/bbootimg/src/main/kotlin/packable/DeviceTreeParser.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2025 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package packable
 
 import cfig.bootimg.Common
diff --git a/bbootimg/src/main/kotlin/packable/DtboParser.kt b/bbootimg/src/main/kotlin/packable/DtboParser.kt
index 1613c3b..03fa6ee 100644
--- a/bbootimg/src/main/kotlin/packable/DtboParser.kt
+++ b/bbootimg/src/main/kotlin/packable/DtboParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/IPackable.kt b/bbootimg/src/main/kotlin/packable/IPackable.kt
index 8e098c3..e9d9143 100644
--- a/bbootimg/src/main/kotlin/packable/IPackable.kt
+++ b/bbootimg/src/main/kotlin/packable/IPackable.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/MiscImgParser.kt b/bbootimg/src/main/kotlin/packable/MiscImgParser.kt
index 7d61fc0..3753f98 100644
--- a/bbootimg/src/main/kotlin/packable/MiscImgParser.kt
+++ b/bbootimg/src/main/kotlin/packable/MiscImgParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2022-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/OTAzipParser.kt b/bbootimg/src/main/kotlin/packable/OTAzipParser.kt
index 60d4da1..f888cef 100644
--- a/bbootimg/src/main/kotlin/packable/OTAzipParser.kt
+++ b/bbootimg/src/main/kotlin/packable/OTAzipParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
index 1d3b734..81a03f9 100644
--- a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
+++ b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/PayloadBinParser.kt b/bbootimg/src/main/kotlin/packable/PayloadBinParser.kt
index a6fbd13..59905f8 100644
--- a/bbootimg/src/main/kotlin/packable/PayloadBinParser.kt
+++ b/bbootimg/src/main/kotlin/packable/PayloadBinParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2022 yuyezhong@gmail.com
+// Copyright 2022-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
index 92ce4da..833f5c8 100644
--- a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
+++ b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2019-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/packable/VendorBootParser.kt b/bbootimg/src/main/kotlin/packable/VendorBootParser.kt
index 5779686..ba61cf5 100644
--- a/bbootimg/src/main/kotlin/packable/VendorBootParser.kt
+++ b/bbootimg/src/main/kotlin/packable/VendorBootParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2020-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/rom/fdt/DTC.kt b/bbootimg/src/main/kotlin/rom/fdt/DTC.kt
index dd27053..ec85629 100644
--- a/bbootimg/src/main/kotlin/rom/fdt/DTC.kt
+++ b/bbootimg/src/main/kotlin/rom/fdt/DTC.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/rom/fdt/Dtbo.kt b/bbootimg/src/main/kotlin/rom/fdt/Dtbo.kt
index ac263cb..f29223d 100644
--- a/bbootimg/src/main/kotlin/rom/fdt/Dtbo.kt
+++ b/bbootimg/src/main/kotlin/rom/fdt/Dtbo.kt
@@ -1,3 +1,17 @@
+// Copyright 2024 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.fdt
 
 import avb.AVBInfo
diff --git a/bbootimg/src/main/kotlin/rom/misc/BootControl.kt b/bbootimg/src/main/kotlin/rom/misc/BootControl.kt
index 5609eba..eb9f501 100644
--- a/bbootimg/src/main/kotlin/rom/misc/BootControl.kt
+++ b/bbootimg/src/main/kotlin/rom/misc/BootControl.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2023 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/rom/misc/MiscImage.kt b/bbootimg/src/main/kotlin/rom/misc/MiscImage.kt
index ec17d84..82f2019 100644
--- a/bbootimg/src/main/kotlin/rom/misc/MiscImage.kt
+++ b/bbootimg/src/main/kotlin/rom/misc/MiscImage.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2024 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.misc
 
 import cc.cfig.io.Struct
diff --git a/bbootimg/src/main/kotlin/rom/sparse/BaseGenerator.kt b/bbootimg/src/main/kotlin/rom/sparse/BaseGenerator.kt
index 2e7dc83..6338e77 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/BaseGenerator.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/BaseGenerator.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2024 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.sparse
 
 import cfig.helper.Helper
diff --git a/bbootimg/src/main/kotlin/rom/sparse/ErofsGenerator.kt b/bbootimg/src/main/kotlin/rom/sparse/ErofsGenerator.kt
index 1644b85..da4b2a0 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/ErofsGenerator.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/ErofsGenerator.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2024 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.sparse
 
 import avb.AVBInfo
diff --git a/bbootimg/src/main/kotlin/rom/sparse/Ext4Generator.kt b/bbootimg/src/main/kotlin/rom/sparse/Ext4Generator.kt
index 1baad37..d7f300c 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/Ext4Generator.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/Ext4Generator.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2024 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.sparse
 
 import avb.AVBInfo
diff --git a/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt b/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
index 9bdbbe5..04864e4 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
@@ -1,3 +1,17 @@
+// Copyright 2023-2025 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package rom.sparse
 
 import avb.AVBInfo
@@ -139,7 +153,7 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
     companion object {
         private val SPARSE_MAGIC: UInt = 0x3aff26edu
         private val log = LoggerFactory.getLogger(SparseImage::class.java)
-        private val workDir = Helper.prop("workDir")!!
+        private val workDir get() = Helper.prop("workDir")!!
         private val simg2imgBin = "simg2img"
         private val img2simgBin = "img2simg"
 
@@ -188,8 +202,8 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
                     log.warn("unsuported image type: ${ret.info.innerFsType}")
                 }
             }
-            ObjectMapper().writerWithDefaultPrettyPrinter().writeValue(File("${workDir}/${ret.info.json}"), ret)
-            File("${workDir}mount").mkdir()
+            ObjectMapper().writerWithDefaultPrettyPrinter().writeValue(File(workDir, ret.info.json), ret)
+            File(workDir, "mount").mkdir()
             extractVBMeta(ret.info.pulp)
             generateFileContexts()
 
@@ -216,8 +230,9 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
         private fun extractExt4(fileName: String) {
             if (EnvironmentVerifier().has7z) {
                 val stem = File(fileName).nameWithoutExtension
-                val outStr = "7z x $fileName -y -o${workDir}$stem".check_output()
-                File("${workDir}/$stem.log").writeText(outStr)
+                val outFilePath = Helper.joinPath(workDir, stem)
+                val outStr = "7z x $fileName -y -o$outFilePath".check_output()
+                File(workDir, "$stem.log").writeText(outStr)
             } else {
                 log.warn("Please install 7z for ext4 extraction")
             }
diff --git a/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt b/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
index 0848e7c..373cac9 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2023-2025 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ class SparseImgParser : IPackable {
 
     override fun unpack(fileName: String) {
         log.info("unpack(fileName: $fileName)")
-        unpackInternal(fileName, Helper.prop("workDir")!!)
+        unpackInternal(fileName, outDir)
     }
 
     fun unpackInternal(fileName: String, unpackDir: String) {
@@ -59,7 +59,7 @@ class SparseImgParser : IPackable {
 
     override fun pack(fileName: String) {
         //TODO("not implemented: refer to https://github.com/cfig/Android_boot_image_editor/issues/133")
-        packInternal(Helper.prop("workDir")!!, fileName)
+        packInternal(outDir, fileName)
     }
 
     fun packInternal(workspace: String, outFileName: String) {
@@ -121,7 +121,6 @@ class SparseImgParser : IPackable {
 
 
     companion object {
-        private val workDir = Helper.prop("workDir")
         private var outerFsType = "raw"
         private var innerFsType = "raw"
     }
diff --git a/bbootimg/src/main/kotlin/utils/EnvironmentVerifier.kt b/bbootimg/src/main/kotlin/utils/EnvironmentVerifier.kt
index 53815f6..63ef4e3 100644
--- a/bbootimg/src/main/kotlin/utils/EnvironmentVerifier.kt
+++ b/bbootimg/src/main/kotlin/utils/EnvironmentVerifier.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2021-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/bbootimg/src/main/kotlin/utils/KernelExtractor.kt b/bbootimg/src/main/kotlin/utils/KernelExtractor.kt
index 2b82677..244ab6d 100644
--- a/bbootimg/src/main/kotlin/utils/KernelExtractor.kt
+++ b/bbootimg/src/main/kotlin/utils/KernelExtractor.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2021-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt b/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt
index e82d519..d0cf7c7 100644
--- a/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt
+++ b/helper/src/main/kotlin/cfig/helper/CryptoHelper.kt
@@ -1,3 +1,17 @@
+// Copyright 2021-2023 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 @file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
 
 package cfig.helper
diff --git a/helper/src/main/kotlin/cfig/helper/Dumpling.kt b/helper/src/main/kotlin/cfig/helper/Dumpling.kt
index 9bad00b..c4991d2 100644
--- a/helper/src/main/kotlin/cfig/helper/Dumpling.kt
+++ b/helper/src/main/kotlin/cfig/helper/Dumpling.kt
@@ -1,3 +1,17 @@
+// Copyright 2022-2023 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package cfig.helper
 
 import java.io.ByteArrayInputStream
diff --git a/helper/src/main/kotlin/cfig/helper/Helper.kt b/helper/src/main/kotlin/cfig/helper/Helper.kt
index 4cbe087..4ddb52d 100644
--- a/helper/src/main/kotlin/cfig/helper/Helper.kt
+++ b/helper/src/main/kotlin/cfig/helper/Helper.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2021-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/helper/src/main/kotlin/cfig/helper/Launcher.kt b/helper/src/main/kotlin/cfig/helper/Launcher.kt
index 8f690ec..f0929f7 100644
--- a/helper/src/main/kotlin/cfig/helper/Launcher.kt
+++ b/helper/src/main/kotlin/cfig/helper/Launcher.kt
@@ -1,3 +1,17 @@
+// Copyright 2021-2023 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 @file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
 
 package cfig.helper
diff --git a/helper/src/main/kotlin/cfig/helper/OpenSslHelper.kt b/helper/src/main/kotlin/cfig/helper/OpenSslHelper.kt
index 33c00ea..7c3a9fc 100644
--- a/helper/src/main/kotlin/cfig/helper/OpenSslHelper.kt
+++ b/helper/src/main/kotlin/cfig/helper/OpenSslHelper.kt
@@ -1,3 +1,17 @@
+// Copyright 2021-2022 yuyezhong@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package cfig.helper
 
 import org.apache.commons.exec.CommandLine
diff --git a/helper/src/main/kotlin/cfig/helper/ZipHelper.kt b/helper/src/main/kotlin/cfig/helper/ZipHelper.kt
index 81c5cf8..08da10b 100644
--- a/helper/src/main/kotlin/cfig/helper/ZipHelper.kt
+++ b/helper/src/main/kotlin/cfig/helper/ZipHelper.kt
@@ -1,4 +1,4 @@
-// Copyright 2021 yuyezhong@gmail.com
+// Copyright 2021-2024 yuyezhong@gmail.com
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 9a7b5fc..84fc56a 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -9,9 +9,9 @@ include("aosp:apksigner")
 include("aosp:boot_signer")
 include("aosp:bouncycastle:bcpkix")
 include("aosp:bouncycastle:bcprov")
-include("aosp:libavb1.1")
-include("aosp:libavb1.2")
-include("avbImpl")
+//include("aosp:libavb1.1")
+//include("aosp:libavb1.2")
+//include("avbImpl")
 include("helper")
 include("lazybox")
 
diff --git a/src/integrationTest/resources_2 b/src/integrationTest/resources_2
index 012bda6..b534ff8 160000
--- a/src/integrationTest/resources_2
+++ b/src/integrationTest/resources_2
@@ -1 +1 @@
-Subproject commit 012bda615f1c02f16064c30b828f2307f08a6730
+Subproject commit b534ff8f20a167682526c248cdf1ddc25dfb3f99
diff --git a/tools/copyright.kts b/tools/copyright.kts
new file mode 100644
index 0000000..b345d71
--- /dev/null
+++ b/tools/copyright.kts
@@ -0,0 +1,166 @@
+import java.io.File
+import java.time.LocalDateTime
+import java.time.format.DateTimeFormatter
+import java.util.concurrent.TimeUnit
+
+fun main(args: Array<String>) {
+    if (args.isEmpty()) {
+        println("Usage: kotlin copyright_updater.kts <directory_or_file_path>")
+        return
+    }
+
+    val path = args[0]
+    val file = File(path)
+
+    if (!file.exists()) {
+        println("Error: Path '$path' does not exist")
+        return
+    }
+
+    if (file.isFile()) {
+        updateCopyrightForFile(file)
+    } else if (file.isDirectory()) {
+        updateCopyrightForDirectory(file)
+    }
+}
+
+fun updateCopyrightForDirectory(directory: File) {
+    println("Processing directory: ${directory.absolutePath}")
+
+    directory.walkTopDown()
+        .filter { it.isFile() && isSourceFile(it) }
+        .forEach { file ->
+            println("Processing file: ${file.relativeTo(directory)}")
+            updateCopyrightForFile(file)
+        }
+}
+
+fun updateCopyrightForFile(file: File) {
+    try {
+        val (firstCommitYear, lastCommitYear) = getCommitYears(file)
+        if (firstCommitYear == null || lastCommitYear == null) {
+            println("  Warning: Could not determine git history for ${file.name}")
+            return
+        }
+
+        val content = file.readText()
+        val updatedContent = updateCopyright(content, firstCommitYear, lastCommitYear)
+
+        if (content != updatedContent) {
+            file.writeText(updatedContent)
+            println("  Updated copyright: $firstCommitYear-$lastCommitYear")
+        } else {
+            println("  No changes needed")
+        }
+    } catch (e: Exception) {
+        println("  Error processing ${file.name}: ${e.message}")
+    }
+}
+
+fun isSourceFile(file: File): Boolean {
+    val sourceExtensions = setOf("kt", "java", "scala", "groovy", "js", "ts", "cpp", "c", "h", "hpp")
+    return sourceExtensions.contains(file.extension.lowercase())
+}
+
+fun getCommitYears(file: File): Pair<Int?, Int?> {
+    return try {
+        // Get first commit year
+        val firstCommitProcess = ProcessBuilder(
+            "git", "log", "--reverse", "--format=%ci", "--", file.absolutePath
+        ).directory(file.parentFile).start()
+
+        val firstCommitOutput = firstCommitProcess.inputStream.bufferedReader().use { it.readText() }
+        firstCommitProcess.waitFor(10, TimeUnit.SECONDS)
+
+        // Get last commit year
+        val lastCommitProcess = ProcessBuilder(
+            "git", "log", "-1", "--format=%ci", "--", file.absolutePath
+        ).directory(file.parentFile).start()
+
+        val lastCommitOutput = lastCommitProcess.inputStream.bufferedReader().use { it.readText() }
+        lastCommitProcess.waitFor(10, TimeUnit.SECONDS)
+
+        val firstYear = extractYearFromGitDate(firstCommitOutput.lines().firstOrNull() ?: "")
+        val lastYear = extractYearFromGitDate(lastCommitOutput.lines().firstOrNull() ?: "")
+
+        Pair(firstYear, lastYear)
+    } catch (e: Exception) {
+        println("  Git command failed: ${e.message}")
+        Pair(null, null)
+    }
+}
+
+fun extractYearFromGitDate(dateString: String): Int? {
+    return try {
+        if (dateString.isBlank()) return null
+        // Git date format: "2022-03-15 10:30:45 +0000"
+        val year = dateString.substring(0, 4).toInt()
+        year
+    } catch (e: Exception) {
+        null
+    }
+}
+
+fun updateCopyright(content: String, firstYear: Int, lastYear: Int): String {
+    val lines = content.lines().toMutableList()
+    val copyrightLineIndex = findCopyrightLine(lines)
+
+    return if (copyrightLineIndex != -1) {
+        // Update existing copyright
+        val updatedCopyrightLine = updateExistingCopyright(lines[copyrightLineIndex], firstYear, lastYear)
+        lines[copyrightLineIndex] = updatedCopyrightLine
+        lines.joinToString("\n")
+    } else {
+        // Add new copyright header
+        val copyrightHeader = createCopyrightHeader(firstYear, lastYear)
+        (copyrightHeader + lines).joinToString("\n")
+    }
+}
+
+fun findCopyrightLine(lines: List<String>): Int {
+    return lines.indexOfFirst { line ->
+        line.contains("Copyright", ignoreCase = true) &&
+        line.contains("yuyezhong@gmail.com", ignoreCase = true)
+    }
+}
+
+fun updateExistingCopyright(copyrightLine: String, firstYear: Int, lastYear: Int): String {
+    val yearRange = if (firstYear == lastYear) {
+        firstYear.toString()
+    } else {
+        "$firstYear-$lastYear"
+    }
+
+    // Replace the year pattern in the existing copyright line
+    return copyrightLine.replaceFirst(
+        Regex("""\b\d{4}(-\d{4})?\b"""),
+        yearRange
+    )
+}
+
+fun createCopyrightHeader(firstYear: Int, lastYear: Int): List<String> {
+    val yearRange = if (firstYear == lastYear) {
+        firstYear.toString()
+    } else {
+        "$firstYear-$lastYear"
+    }
+
+    return listOf(
+        "// Copyright $yearRange yuyezhong@gmail.com",
+        "//",
+        "// Licensed under the Apache License, Version 2.0 (the \"License\");",
+        "// you may not use this file except in compliance with the License.",
+        "// You may obtain a copy of the License at",
+        "//",
+        "//      http://www.apache.org/licenses/LICENSE-2.0",
+        "//",
+        "// Unless required by applicable law or agreed to in writing, software",
+        "// distributed under the License is distributed on an \"AS IS\" BASIS,",
+        "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
+        "// See the License for the specific language governing permissions and",
+        "// limitations under the License.",
+        ""
+    )
+}
+
+main(args)