Skip to content

Create devcontainer.json #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {}
}
2 changes: 1 addition & 1 deletion bbootimg/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "2.0.20"
kotlin("jvm") version "2.1.0"
application
}

Expand Down
2 changes: 1 addition & 1 deletion helper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "2.0.0"
kotlin("jvm") version "2.1.0"
`java-library`
application
}
Expand Down
2 changes: 1 addition & 1 deletion lazybox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "2.0.20"
kotlin("jvm") version "2.1.0"
application
}

Expand Down
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 @@ -70,7 +70,13 @@ fun main(args: Array<String>) {
if (args[0] == "apps") {
//AppList.retrieveList()
}
if (args[0] == "rel") {
ImageRelease.run()
}
if (args[0] == "x") {
AMS.computeRankAndBucket(AMS.getProcRank(), AMS.getStandbyBucket2())
}
if (args[0] == "mount") {
MountAnalyzer().run()
}
}
67 changes: 67 additions & 0 deletions lazybox/src/main/kotlin/cfig/lazybox/ImageRelease.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package cfig.lazybox

import cfig.helper.Helper
import cfig.helper.Helper.Companion.check_call
import org.slf4j.LoggerFactory
import java.io.File
import java.nio.file.Files
import java.nio.file.Paths

class ImageRelease {
companion object {
private val log = LoggerFactory.getLogger(ImageRelease::class.java)
fun run() {
val buildId = Helper.adbCmd("getprop ro.build.id").lowercase()
val variant = Helper.adbCmd("getprop ro.build.type")
val product = Helper.adbCmd("getprop ro.build.product")
val rel = Helper.adbCmd("getprop ro.build.version.release")
val increment = Helper.adbCmd("getprop ro.build.version.incremental")
val fp = Helper.adbCmd("getprop ro.build.fingerprint")

val computFacDir = "$product-factory-$buildId"
val computFacZip = "$product-factory-$buildId-$increment.zip"
val computOtaZip = "$product-ota-$buildId-$increment.zip"
val computEmmcZip = "$product-eMMCimg-$buildId-$increment.zip"

log.info("fingerprint: $fp")
log.info("$product-factory-$buildId-$increment -> $product-factory-$buildId")
log.info("$product-ota-$buildId-$increment")
log.info("$product-eMMCimg-$buildId-$increment")

//factory
if (File("factory.zip").exists()) {
"rm -fr factory_image factory_img $computFacDir $computFacZip".check_call()
"unzip factory.zip".check_call()
val facDir = if (File("factory_img").exists()) {
//user
"factory_img"
} else if (File("factory_image").exists()) {
//userdebug
"factory_image"
} else {
throw IllegalStateException("can not find factory image folder")
}
File(facDir).listFiles()?.filter { it.name.endsWith(".sh") }?.forEach { it.delete() }
"cp -v /tftp/flash_platypus.sh $facDir/flash.sh".check_call()
"mv -v $facDir $computFacDir".check_call()
"zip $computFacZip -r $computFacDir".check_call()
"rm -fr $computFacDir".check_call()
}

File("factory.zip").delete()
if (File("ota.zip").exists()) {
Files.move(Paths.get("ota.zip"), Paths.get(computOtaZip))
}
if (File("emmc.zip").exists()) {
Files.move(Paths.get("emmc.zip"), Paths.get(computEmmcZip))
}

log.info("fingerprint: $fp")
log.info("$product-factory-$buildId-$increment -> $product-factory-$buildId")
log.info(computFacZip)
log.info(computOtaZip)
log.info(computEmmcZip)
}
}

}
148 changes: 148 additions & 0 deletions lazybox/src/main/kotlin/cfig/lazybox/MountAnalyzer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package cfig.lazybox

import org.slf4j.LoggerFactory
import java.io.BufferedWriter
import java.io.File
import java.io.FileOutputStream
import java.io.FileWriter

class MountAnalyzer {
data class MountInfo(
var dev: String = "",
var mountPoint: String = "",
var fsType: String = "",
var flags: String? = null,
)

class MiComparator : Comparator<MountInfo> {
override fun compare(p1: MountInfo, p2: MountInfo): Int {
var ret = p1.fsType.compareTo(p2.fsType) * 100
ret += p1.dev.compareTo(p2.dev) * 10
ret += p1.mountPoint.compareTo(p2.mountPoint) * 1
return ret
}
}

fun run() {
val loopApex = mutableListOf<MountInfo>()
val dmApex = mutableListOf<MountInfo>()
val tmpApex = mutableListOf<MountInfo>()
val bootApex = mutableListOf<MountInfo>()
val fuseInfo = mutableListOf<MountInfo>()
val sysInfo = mutableListOf<MountInfo>()
val androidRo = mutableListOf<MountInfo>()
val androidRw = mutableListOf<MountInfo>()
val otherRw = mutableListOf<MountInfo>()
val unknownMi = mutableListOf<MountInfo>()
val lines = File("mount.log").readLines()
lines.forEachIndexed { n, line ->
val regex = Regex("(\\S+)\\s+on\\s+(\\S+)\\s+type\\s+(\\w+)\\s+\\(([^)]*)\\)") // Capture flags
val matchResult = regex.find(line)
if (matchResult != null) {
val dev = matchResult.groupValues[1]
val mountPoint = matchResult.groupValues[2]
val fsType = matchResult.groupValues[3]
val flags =
if (matchResult.groupValues.size > 4) matchResult.groupValues[4] else null // Handle no flags
val mi = MountInfo(dev, mountPoint, fsType, flags)
if (mi.mountPoint.startsWith("/apex") || mi.mountPoint.startsWith("/bootstrap-apex")) {
if (mi.mountPoint.startsWith("/bootstrap-apex")) {
bootApex.add(mi)
} else if (mi.dev.startsWith("/dev/block/loop")) {
loopApex.add(mi)
} else if (mi.dev.startsWith("/dev/block/dm")) {
dmApex.add(mi)
} else if (mi.dev.startsWith("tmpfs")) {
tmpApex.add(mi)
} else {
log.info("$fsType: $dev -> $mountPoint")
throw IllegalStateException("X1")
}
} else if (mi.mountPoint.startsWith("/sys/") || mi.mountPoint == "/sys") {
sysInfo.add(mi)
} else if (mi.fsType == "fuse") {
fuseInfo.add(mi)
} else {
log.info("$fsType: $dev -> $mountPoint")
if (mi.flags!!.contains("ro,") or mi.flags!!.contains("ro)")) {
androidRo.add(mi)
} else if (mi.flags!!.contains("rw,") or mi.flags!!.contains("rw)")) {
if (mi.dev.startsWith("/dev/")) {
androidRw.add(mi)
} else {
otherRw.add(mi)
}
} else {
throw IllegalStateException("X2")
}
}
} else { //For lines without flags
val regexNoFlags = Regex("(\\S+)\\s+on\\s+(\\S+)\\s+type\\s+(\\w+)")
val matchResultNoFlags = regexNoFlags.find(line)
if (matchResultNoFlags != null) {
val dev = matchResultNoFlags.groupValues[1]
val mountPoint = matchResultNoFlags.groupValues[2]
val fsType = matchResultNoFlags.groupValues[3]
val mi = MountInfo(dev, mountPoint, fsType, null)
unknownMi.add(mi)
} else {
throw IllegalStateException("X3")
}
}
} // end-of-lines
//sanity check, make sure consistent
check(
listOf(
loopApex,
dmApex,
tmpApex,
bootApex,
fuseInfo,
sysInfo,
androidRo,
androidRw,
otherRw,
unknownMi
).sumOf { it.size } == lines.size)
//dump
val infoNames = listOf(
"fusefs",
"sysfs",
"Android RO",
"Android RW",
"other Rw",
"loop apex",
"dm apex",
"tmp apex",
"boot apex",
"unknown"
)
BufferedWriter(FileWriter(File("sorted_mount.log"))).use { fos ->
listOf(
fuseInfo,
sysInfo,
androidRo,
androidRw,
otherRw,
loopApex,
dmApex,
tmpApex,
bootApex,
unknownMi
).forEachIndexed { n, mis ->
mis.sortWith(MiComparator())
log.info(infoNames.get(n))
fos.write(infoNames.get(n) + "\n")
mis.forEachIndexed { index, it ->
log.info("[$index] ${it.fsType} : ${it.dev} -> ${it.mountPoint} (${it.flags})")
fos.write("#$index | ${it.fsType} | ${it.dev} | ${it.mountPoint} | (${it.flags})\n")
}
fos.write("\n")
}
}
}

companion object {
private val log = LoggerFactory.getLogger(MountAnalyzer::class.java)
}
}