From bdadd5828ce2d211c71c716a98a24f2e04e449b2 Mon Sep 17 00:00:00 2001 From: cfig Date: Wed, 31 Jul 2024 10:26:58 +0800 Subject: [PATCH] add "slit" subcmd --- lazybox/src/main/kotlin/cfig/lazybox/App.kt | 6 +++++ .../kotlin/cfig/lazybox/CompileCommand.kt | 25 ++++++++++++++++++- .../kotlin/cfig/lazybox/TraceCmdParser.kt | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lazybox/src/main/kotlin/cfig/lazybox/App.kt b/lazybox/src/main/kotlin/cfig/lazybox/App.kt index 97d8076a..6dbdd556 100644 --- a/lazybox/src/main/kotlin/cfig/lazybox/App.kt +++ b/lazybox/src/main/kotlin/cfig/lazybox/App.kt @@ -59,4 +59,10 @@ fun main(args: Array) { log.error("Usage: tracecmd ") } } + if (args[0] == "split") { + if (args.size != 3) { + log.error("Usage: split ") + } + CompileCommand().run(args[1], args[2]) + } } diff --git a/lazybox/src/main/kotlin/cfig/lazybox/CompileCommand.kt b/lazybox/src/main/kotlin/cfig/lazybox/CompileCommand.kt index f6cca970..28b30674 100644 --- a/lazybox/src/main/kotlin/cfig/lazybox/CompileCommand.kt +++ b/lazybox/src/main/kotlin/cfig/lazybox/CompileCommand.kt @@ -1,4 +1,27 @@ package cfig.lazybox +import cfig.helper.Helper +import java.io.File + class CompileCommand { -} \ No newline at end of file + fun run(workDir: String, stem: String) { + val simg2simg = "simg2simg" + val cmd = "$simg2simg $workDir/$stem.subimg $workDir/$stem.subimg 524288000" + Helper.powerRun(cmd, null) + val emmcImageListFile = File(workDir, "emmc_image_list") + val theLines = emmcImageListFile.readLines().toMutableList() + val stemLine = (theLines.filter { it.startsWith("$stem.subimg,") }).get(0).split(",") + check(stemLine.size == 2) + val stemPart = stemLine[1] + theLines.apply { + removeIf { it.startsWith("$stem.subimg") } + val superImageFiles = File(workDir).listFiles { file -> file.name.startsWith("$stem.subimg.") } + superImageFiles.forEach { + val newLine = "${it.name},$stemPart" + println("Adding $newLine") + add(newLine) + } + } + emmcImageListFile.writeText(theLines.joinToString("\n") + "\n") + } +} diff --git a/lazybox/src/main/kotlin/cfig/lazybox/TraceCmdParser.kt b/lazybox/src/main/kotlin/cfig/lazybox/TraceCmdParser.kt index ea8848f8..1129c42b 100644 --- a/lazybox/src/main/kotlin/cfig/lazybox/TraceCmdParser.kt +++ b/lazybox/src/main/kotlin/cfig/lazybox/TraceCmdParser.kt @@ -37,7 +37,7 @@ class TraceCmdParser { val timestampString = parts[2].split(':')[0] val timestamp = timestampString.toDouble() val eventType = parts[3].removeSuffix(":") - var info = line.trim().substring(line.trim().indexOf(parts[4])) + val info = line.trim().substring(line.trim().indexOf(parts[4])) log.debug(info) info.split(" ").forEachIndexed { index, s -> log.debug("info#$index: $s")