Browse Source

clean up uicache calls in postinst when repackaging

Kevin Bradley 4 years ago
parent
commit
63ad615766

BIN
bootstrapTool.xcodeproj/project.xcworkspace/xcuserdata/kevinbradley.xcuserdatad/UserInterfaceState.xcuserstate


+ 46 - 1
bootstrapTool/Classes/InputPackage.m

@@ -400,11 +400,56 @@
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
     
+    //clean up any calls to uicache
+    
+    NSString *postinst = [debian stringByAppendingPathComponent:@"postinst"];
+    
+    //DLog(@"post inst: %@", postinst);
+    
+    if ([FM fileExistsAtPath:postinst]){
+        NSString *postinstSource = [NSString stringWithContentsOfFile:postinst encoding:NSUTF8StringEncoding error:nil];
+        if (postinstSource.length > 0){
+            if ([postinstSource rangeOfString:@"uicache"].location != NSNotFound){
+                
+                NSMutableArray *lines = [[postinstSource componentsSeparatedByString:@"\n"] mutableCopy];
+                
+                //DLog(@"lines: %@", lines);
+                
+                __block NSInteger markedForDeath = NSNotFound;
+                [lines enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+                   
+                  //  DLog(@"obj: %@", obj);
+                    
+                    if ([obj rangeOfString:@"uicache"].location != NSNotFound){
+                        
+                        if ([obj rangeOfString:@"echo"].location == NSNotFound){
+                            DLog(@"\n");
+                            DLog(@"found uicache instance '%@' on line: %lu", obj, idx);
+                            markedForDeath = idx;
+                        }
+                        *stop = TRUE;
+                        
+                    }
+                    
+                }];
+                
+                if (markedForDeath != NSNotFound){
+                
+                    [lines removeObjectAtIndex:markedForDeath];
+                    NSString *newString = [lines componentsJoinedByString:@"\n"];
+                    [newString writeToFile:postinst atomically:TRUE];
+                    
+                }
+                
+            }
+        }
+        
+        
+    }
     
     if (newArch != nil) {
         
         NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
-        
         NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
         //@"appletvos-arm64"