@@ -135,6 +135,7 @@ class Common {
135135 )
136136 ZipHelper .zcat(s.dumpFile + " .gz" , s.dumpFile)
137137 }
138+
138139 ZipHelper .isXz(s.dumpFile) -> {
139140 log.info(" ramdisk is compressed xz" )
140141 Files .move(
@@ -144,15 +145,17 @@ class Common {
144145 ZipHelper .xzcat(s.dumpFile + " .xz" , s.dumpFile)
145146 ret = " xz"
146147 }
148+
147149 ZipHelper .isLzma(s.dumpFile) -> {
148150 log.info(" ramdisk is compressed lzma" )
149151 Files .move(
150- Paths .get(s.dumpFile), Paths .get(s.dumpFile + " .lzma" ),
151- java.nio.file.StandardCopyOption .REPLACE_EXISTING
152+ Paths .get(s.dumpFile), Paths .get(s.dumpFile + " .lzma" ),
153+ java.nio.file.StandardCopyOption .REPLACE_EXISTING
152154 )
153155 ZipHelper .lzcat(s.dumpFile + " .lzma" , s.dumpFile)
154156 ret = " lzma"
155157 }
158+
156159 ZipHelper .isLz4(s.dumpFile) -> {
157160 log.info(" ramdisk is compressed lz4" )
158161 Files .move(
@@ -162,6 +165,7 @@ class Common {
162165 ZipHelper .lz4cat(s.dumpFile + " .lz4" , s.dumpFile)
163166 ret = " lz4"
164167 }
168+
165169 ZipHelper .isAndroidCpio(s.dumpFile) -> {
166170 log.info(" ramdisk is uncompressed cpio" )
167171 Files .copy(
@@ -170,6 +174,7 @@ class Common {
170174 )
171175 ret = " cpio"
172176 }
177+
173178 else -> {
174179 throw IllegalArgumentException (" ramdisk is in unknown format" )
175180 }
@@ -248,9 +253,11 @@ class Common {
248253 ramdiskGz.endsWith(" .gz" ) -> {
249254 ZipHelper .minigzip(ramdiskGz, ByteArrayInputStream (outputStream.toByteArray()))
250255 }
256+
251257 ramdiskGz.endsWith(" .lz4" ) -> {
252258 ZipHelper .lz4(ramdiskGz, ByteArrayInputStream (outputStream.toByteArray()))
253259 }
260+
254261 else -> {
255262 throw IllegalArgumentException (" $ramdiskGz is not supported" )
256263 }
@@ -268,26 +275,31 @@ class Common {
268275 AndroidCpio ().pack(root, f, " ${f} _filelist.txt" )
269276 FileInputStream (f).use { ZipHelper .minigzip(ramdiskGz, it) }
270277 }
278+
271279 ramdiskGz.endsWith(" .lz4" ) -> {
272280 val f = ramdiskGz.removeSuffix(" .lz4" )
273281 AndroidCpio ().pack(root, f, " ${f} _filelist.txt" )
274282 FileInputStream (f).use { ZipHelper .lz4(ramdiskGz, it) }
275283 }
284+
276285 ramdiskGz.endsWith(" .lzma" ) -> {
277286 val f = ramdiskGz.removeSuffix(" .lzma" )
278287 AndroidCpio ().pack(root, f, " ${f} _filelist.txt" )
279288 FileInputStream (f).use { ZipHelper .lzma(ramdiskGz, it) }
280289 }
290+
281291 ramdiskGz.endsWith(" .xz" ) -> {
282292 val f = ramdiskGz.removeSuffix(" .xz" )
283293 AndroidCpio ().pack(root, f, " ${f} _filelist.txt" )
284294 FileInputStream (f).use { ZipHelper .xz(ramdiskGz, it, compressorArgs!! ) }
285295 }
296+
286297 ramdiskGz.endsWith(" .cpio" ) -> {
287298 val f = ramdiskGz.removeSuffix(" .cpio" )
288299 AndroidCpio ().pack(root, f, " ${f} _filelist.txt" )
289300 File (f).copyTo(File (ramdiskGz), true )
290301 }
302+
291303 else -> {
292304 throw IllegalArgumentException (" $ramdiskGz is not supported" )
293305 }
@@ -381,9 +393,11 @@ class Common {
381393 log.warn(" Os Major exceeds current max $MAX_ANDROID_VER " )
382394 MAX_ANDROID_VER
383395 }
396+
384397 ret < 10 -> {
385398 10
386399 }
400+
387401 else -> {
388402 ret
389403 }
@@ -405,7 +419,8 @@ class Common {
405419 com.github.freva.asciitable.Column ().header(" Where" )
406420 .headerAlign(HorizontalAlign .CENTER )
407421 .dataAlign(HorizontalAlign .LEFT )
408- .with { it.second }))
422+ .with { it.second })
423+ )
409424 }
410425
411426 fun printPackSummary (imageName : String ) {
@@ -441,5 +456,34 @@ class Common {
441456 log.info(" \n\t\t\t Pack Summary of ${imageName} \n {}\n {}" , tableHeader.render(), tab.render())
442457 }
443458 }
459+
460+ fun printPackSummaryInternal (imageName : String ) {
461+ val prints: MutableList <Pair <String , String >> = mutableListOf ()
462+ val tableHeader = de.vandermeer.asciitable.AsciiTable ().apply {
463+ addRule(); addRow(" What" , " Where" ); addRule()
464+ }
465+ val tab = de.vandermeer.asciitable.AsciiTable ().let {
466+ it.addRule()
467+ it.addRow(" re-packed $imageName " , Helper .prop(" out.file" ))
468+ prints.add(Pair (" re-packed $imageName " , Helper .prop(" out.file" )!! ))
469+ it.addRule()
470+ it
471+ }
472+ if (File (" vbmeta.img" ).exists()) {
473+ if (File (" vbmeta.img.signed" ).exists()) {
474+ tab.addRow(" re-packed vbmeta" , " vbmeta.img.signed" )
475+ prints.add(Pair (" re-packed vbmeta" , " vbmeta.img.signed" ))
476+ } else {
477+ tab.addRow(" re-packed vbmeta" , " -" )
478+ prints.add(Pair (" re-packed vbmeta" , " -" ))
479+ }
480+ tab.addRule()
481+ }
482+ if (EnvironmentVerifier ().isWindows) {
483+ log.info(" \n " + Common .table2String(prints))
484+ } else {
485+ log.info(" \n\t\t\t Pack Summary of ${imageName} \n {}\n {}" , tableHeader.render(), tab.render())
486+ }
487+ }
444488 }
445489}
0 commit comments