@@ -1561,6 +1561,7 @@ def packsuper(project):
15611561 supertype = 'AB'
15621562 else :
15631563 supertype = 'A_only'
1564+ isreadonly = input ("是否设置为只读分区?[1/0]" )
15641565 ifsparse = input ("是否打包为sparse镜像?[1/0]" )
15651566 if not os .listdir (project + os .sep + 'super' ):
15661567 print ("您似乎没有要打包的分区,要移动下列分区打包吗:" )
@@ -1593,10 +1594,11 @@ def packsuper(project):
15931594 supersize = input ("请输入super分区大小(字节数):" )
15941595 yecho ("打包到TI_out/super.img..." )
15951596 insuper (project + os .sep + 'super' , project + os .sep + 'TI_out' + os .sep + "super.img" , supersize , supertype ,
1596- ifsparse )
1597+ ifsparse , isreadonly )
15971598
15981599
1599- def insuper (Imgdir , outputimg , ssize , stype , sparse ):
1600+ def insuper (Imgdir , outputimg , ssize , stype , sparsev , isreadonly ):
1601+ attr = "readonly" if isreadonly == '1' else "none"
16001602 group_size_a = 0
16011603 group_size_b = 0
16021604 for root , dirs , files in os .walk (Imgdir ):
@@ -1613,15 +1615,15 @@ def insuper(Imgdir, outputimg, ssize, stype, sparse):
16131615 for imag in os .listdir (Imgdir ):
16141616 if imag .endswith ('.img' ):
16151617 image = imag .replace ("_a.img" , "" ).replace ("_b.img" , "" ).replace (".img" , "" )
1616- if f'partition { image } :readonly ' not in superpa and f'partition { image } _a:readonly ' not in superpa :
1618+ if f'partition { image } :{ attr } ' not in superpa and f'partition { image } _a:{ attr } ' not in superpa :
16171619 if stype in ['VAB' , 'AB' ]:
16181620 if os .path .isfile (Imgdir + os .sep + image + "_a.img" ) and os .path .isfile (
16191621 Imgdir + os .sep + image + "_b.img" ):
16201622 img_sizea = os .path .getsize (Imgdir + os .sep + image + "_a.img" )
16211623 img_sizeb = os .path .getsize (Imgdir + os .sep + image + "_b.img" )
16221624 group_size_a += img_sizea
16231625 group_size_b += img_sizeb
1624- superpa += f"--partition { image } _a:readonly :{ img_sizea } :{ settings .super_group } _a --image { image } _a={ Imgdir } { os .sep } { image } _a.img --partition { image } _b:readonly :{ img_sizeb } :{ settings .super_group } _b --image { image } _b={ Imgdir } { os .sep } { image } _b.img "
1626+ superpa += f"--partition { image } _a:{ attr } :{ img_sizea } :{ settings .super_group } _a --image { image } _a={ Imgdir } { os .sep } { image } _a.img --partition { image } _b:{ attr } :{ img_sizeb } :{ settings .super_group } _b --image { image } _b={ Imgdir } { os .sep } { image } _b.img "
16251627 else :
16261628 if not os .path .exists (Imgdir + os .sep + image + ".img" ) and os .path .exists (
16271629 Imgdir + os .sep + image + "_a.img" ):
@@ -1630,14 +1632,14 @@ def insuper(Imgdir, outputimg, ssize, stype, sparse):
16301632 img_size = os .path .getsize (Imgdir + os .sep + image + ".img" )
16311633 group_size_a += img_size
16321634 group_size_b += img_size
1633- superpa += f"--partition { image } _a:readonly :{ img_size } :{ settings .super_group } _a --image { image } _a={ Imgdir } { os .sep } { image } .img --partition { image } _b:readonly :0:{ settings .super_group } _b "
1635+ superpa += f"--partition { image } _a:{ attr } :{ img_size } :{ settings .super_group } _a --image { image } _a={ Imgdir } { os .sep } { image } .img --partition { image } _b:{ attr } :0:{ settings .super_group } _b "
16341636 else :
16351637 if not os .path .exists (Imgdir + os .sep + image + ".img" ) and os .path .exists (
16361638 Imgdir + os .sep + image + "_a.img" ):
16371639 os .rename (Imgdir + os .sep + image + "_a.img" , Imgdir + os .sep + image + ".img" )
16381640
16391641 img_size = os .path .getsize (Imgdir + os .sep + image + ".img" )
1640- superpa += f"--partition { image } :readonly :{ img_size } :{ settings .super_group } --image { image } ={ Imgdir } { os .sep } { image } .img "
1642+ superpa += f"--partition { image } :{ attr } :{ img_size } :{ settings .super_group } --image { image } ={ Imgdir } { os .sep } { image } .img "
16411643 group_size_a += img_size
16421644 print (f"已添加分区:{ image } " )
16431645 supersize = ssize
0 commit comments