Skip to content

Commit

Permalink
add "slit" subcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
cfig committed Jul 31, 2024
1 parent b1a47ee commit bdadd58
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lazybox/src/main/kotlin/cfig/lazybox/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ fun main(args: Array<String>) {
log.error("Usage: tracecmd <report_file>")
}
}
if (args[0] == "split") {
if (args.size != 3) {
log.error("Usage: split <workdir> <part_name>")
}
CompileCommand().run(args[1], args[2])
}
}
25 changes: 24 additions & 1 deletion lazybox/src/main/kotlin/cfig/lazybox/CompileCommand.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
package cfig.lazybox

import cfig.helper.Helper
import java.io.File

class CompileCommand {
}
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")
}
}
2 changes: 1 addition & 1 deletion lazybox/src/main/kotlin/cfig/lazybox/TraceCmdParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit bdadd58

Please sign in to comment.