11package packable
22
33import cfig.bootimg.Common
4+ import cfig.bootimg.v3.VendorBoot
45import cfig.helper.Helper
56import cfig.helper.Helper.Companion.check_call
67import cfig.helper.Helper.Companion.check_output
@@ -15,13 +16,24 @@ class DeviceTreeParser : IPackable {
1516 override fun capabilities (): List <String > {
1617 return listOf (" ^.*\\ .dtb$" )
1718 }
19+
1820 override val loopNo: Int
1921 get() = 1
2022
2123 override fun unpack (fileName : String ) {
22- super .clear()
23- log.info(" unpacking $fileName " )
24- val outFile = workDir + fileName.removeSuffix(" .dtb" ) + " ." + Helper .prop(" config.dts_suffix" )
24+ unpackInternal(fileName, Helper .prop(" workDir" )!! )
25+ }
26+
27+ fun unpackInternal (fileName : String , unpackDir : String ) {
28+ // set workdir
29+ log.info(" unpackInternal(fileName: $fileName , unpackDir: $unpackDir )" )
30+ Helper .setProp(" workDir" , unpackDir)
31+ clear()
32+ // create workspace file
33+ Common .createWorkspaceIni(fileName)
34+ // create workspace file done
35+
36+ val outFile = File (workDir, File (fileName).nameWithoutExtension + " ." + Helper .prop(" config.dts_suffix" )).path
2537 DTC ().decompile(fileName, outFile)
2638
2739 // print summary
@@ -32,15 +44,26 @@ class DeviceTreeParser : IPackable {
3244 }
3345
3446 override fun pack (fileName : String ) {
35- log.info(" packing $fileName " )
36- val outFile = workDir + fileName.removeSuffix(" .dtb" ) + " ." + Helper .prop(" config.dts_suffix" )
37- check(DTC ().compile(outFile, " $fileName .new" )) { " fail to compile dts" }
47+ packInternal(Helper .prop(" workDir" )!! , fileName)
48+ }
49+
50+ fun packInternal (workspace : String , outFileName : String ) {
51+ log.info(" packInternal($workspace , $outFileName )" )
52+ Helper .setProp(" workDir" , workspace)
53+ // workspace+cfg
54+ val iniRole = Common .loadProperties(File (workspace, " workspace.ini" ).canonicalPath).getProperty(" role" )
55+ val dtsSrc = File (workDir, File (iniRole).nameWithoutExtension + " ." + Helper .prop(" config.dts_suffix" )).path
56+
57+ val origFile = File (workDir, File (outFileName).name + " .orig" ).path
58+ log.info(" COPY $outFileName -> $origFile " )
59+ File (outFileName).copyTo(File (origFile), overwrite = true )
60+ check(DTC ().compile(dtsSrc, outFileName)) { " fail to compile dts" }
3861
3962 // print summary
4063 val prints: MutableList <Pair <String , String >> = mutableListOf ()
41- prints.add(Pair (" DTS" , outFile ))
42- prints.add(Pair (" updated DTB" , " $fileName .new " ))
43- log.info(" \n\t\t\t Pack Summary of {}\n {}\n " , fileName , Common .table2String(prints))
64+ prints.add(Pair (" DTS" , dtsSrc ))
65+ prints.add(Pair (" updated DTB" , outFileName ))
66+ log.info(" \n\t\t\t Pack Summary of {}\n {}\n " , outFileName , Common .table2String(prints))
4467 }
4568
4669 fun pull (fileName : String ) {
0 commit comments