11# SPDX-License-Identifier: MIT
2- import os , plistlib , shutil , sys , stat , subprocess , urlcache , zipfile
2+ import os , os . path , plistlib , shutil , sys , stat , subprocess , urlcache , zipfile , logging
33import osenum
44from util import split_ver
55
@@ -18,13 +18,15 @@ def __init__(self, sysinfo, dutil, osinfo, ipsw_info):
1818 print ()
1919
2020 def prepare_volume (self , part ):
21+ logging .info (f"StubInstaller.prepare_volume({ part .name = !r} )" )
2122 self .part = part
2223
2324 by_role = {}
2425
2526 ctref = self .part .container ["ContainerReference" ]
2627
2728 print ("Preparing target volumes..." )
29+ logging .info ("Preparing target volumes" )
2830
2931 for volume in self .part .container ["Volumes" ]:
3032 by_role .setdefault (tuple (volume ["Roles" ]), []).append (volume )
@@ -62,13 +64,13 @@ def prepare_volume(self, part):
6264 self .dutil .addVolume (ctref , "Recovery" , role = "R" )
6365
6466 self .dutil .refresh_part (self .part )
65- if self .verbose :
66- print ()
6767
6868 def check_volume (self , part = None ):
6969 if part :
7070 self .part = part
7171
72+ logging .info (f"StubInstaller.check_volume({ self .part .name = !r} )" )
73+
7274 print ("Checking volumes..." )
7375 os = self .osinfo .collect_part (self .part )
7476
@@ -133,14 +135,19 @@ def extract_tree(self, src, dest):
133135 self .ucache .flush_progress ()
134136
135137 def chflags (self , flags , path ):
138+ logging .info (f"chflags { flags } { path } " )
136139 subprocess .run (["chflags" , flags , path ], check = True )
137140
138141 def install_files (self , cur_os ):
142+ logging .info ("StubInstaller.install_files()" )
143+ logging .info (f"VGID: { self .osi .vgid } " )
144+ logging .info (f"OS info: { self .osi } " )
145+
139146 print ("Beginning stub OS install..." )
140147 ipsw = self .ipsw
141148
142- if self . verbose :
143- print ( "Parsing metadata..." )
149+ logging . info ( "Parsing metadata..." )
150+
144151 sysver = plistlib .load (ipsw .open ("SystemVersion.plist" ))
145152 manifest = plistlib .load (ipsw .open ("BuildManifest.plist" ))
146153 bootcaches = plistlib .load (ipsw .open ("usr/standalone/bootcaches.plist" ))
@@ -157,13 +164,12 @@ def install_files(self, cur_os):
157164 else :
158165 raise Exception ("Failed to locate a usable build identity for this device" )
159166
160- if self .verbose :
161- print (f'Using OS build { identity ["Info" ]["BuildNumber" ]} for { self .sysinfo .device_class } ' )
162- print ()
167+ logging .info (f'Using OS build { identity ["Info" ]["BuildNumber" ]} for { self .sysinfo .device_class } ' )
163168
164169 manifest ["BuildIdentities" ] = [identity ]
165170
166171 print ("Setting up System volume..." )
172+ logging .info ("Setting up System volume" )
167173
168174 self .extract ("usr/standalone/bootcaches.plist" , self .osi .system )
169175 shutil .copy ("logo.icns" , os .path .join (self .osi .system , ".VolumeIcon.icns" ))
@@ -178,6 +184,7 @@ def install_files(self, cur_os):
178184
179185 # Make the icon work
180186 try :
187+ logging .info (f"xattr -wx com.apple.FinderInfo .... { self .osi .system } " )
181188 subprocess .run (["xattr" , "-wx" , "com.apple.FinderInfo" ,
182189 "0000000000000000040000000000000000000000000000000000000000000000" ,
183190 self .osi .system ], check = True )
@@ -198,12 +205,12 @@ def install_files(self, cur_os):
198205 if self .verbose :
199206 print ()
200207 print ("Setting up Data volume..." )
208+ logging .info ("Setting up Data volume" )
201209
202210 os .makedirs (os .path .join (self .osi .data , "private/var/db/dslocal" ), exist_ok = True )
203211
204- if self .verbose :
205- print ()
206212 print ("Setting up Preboot volume..." )
213+ logging .info ("Setting up Preboot volume" )
207214
208215 pb_vgid = os .path .join (self .osi .preboot , self .osi .vgid )
209216 os .makedirs (pb_vgid , exist_ok = True )
@@ -255,21 +262,20 @@ def install_files(self, cur_os):
255262 os .unlink (sys_restore_bundle )
256263 os .symlink (restore_bundle , sys_restore_bundle )
257264
258- if self .verbose :
259- print ()
260265 print ("Setting up Recovery volume..." )
266+ logging .info ("Setting up Recovery volume" )
261267
262268 rec_vgid = os .path .join (self .osi .recovery , self .osi .vgid )
263269 os .makedirs (rec_vgid , exist_ok = True )
264270
265271 basesystem_path = os .path .join (rec_vgid , "usr/standalone/firmware" )
266272 os .makedirs (basesystem_path , exist_ok = True )
267273
274+ logging .info ("Extracting arm64eBaseSystem.dmg" )
268275 self .extract_file (identity ["Manifest" ]["BaseSystem" ]["Info" ]["Path" ],
269276 os .path .join (basesystem_path , "arm64eBaseSystem.dmg" ))
270277 self .ucache .flush_progress ()
271278
272- if self .verbose :
273- print ()
274279 print ("Stub OS installation complete." )
280+ logging .info ("Stub OS installed" )
275281 print ()
0 commit comments