Browse Source

tighten up the spacing and some minor refactoring

Kevin Bradley 3 years ago
parent
commit
dd1096f632
3 changed files with 26 additions and 256 deletions
  1. 19 134
      bootstrapTool/Classes/InputPackage.m
  2. 0 10
      bootstrapTool/Classes/InputPackageFile.m
  3. 7 112
      bootstrapTool/main.m

+ 19 - 134
bootstrapTool/Classes/InputPackage.m

@@ -98,10 +98,9 @@
     
     
     NSString *pwd = [[HelperClass returnForProcess:@"/bin/pwd"] componentsJoinedByString:@"\n"];
     NSString *pwd = [[HelperClass returnForProcess:@"/bin/pwd"] componentsJoinedByString:@"\n"];
     
     
-    NSFileManager *man = [NSFileManager defaultManager];
     NSString *tmpPath = [pwd stringByAppendingPathComponent:self.packageName];
     NSString *tmpPath = [pwd stringByAppendingPathComponent:self.packageName];
     NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
     NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
-    [man createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
+    [FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
     DLog(@"\nExtracting deb for processing...\n");
     DLog(@"\nExtracting deb for processing...\n");
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, tmpPath]];
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, tmpPath]];
     
     
@@ -133,7 +132,7 @@
     
     
     //[outputs writeToFile:md5s atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
     //[outputs writeToFile:md5s atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
     */
     */
-    [man createDirectoryAtPath:debian withIntermediateDirectories:TRUE attributes:nil error:nil];
+    [FM createDirectoryAtPath:debian withIntermediateDirectories:TRUE attributes:nil error:nil];
     
     
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     
     
@@ -144,23 +143,20 @@
     
     
     __block NSString *postInstFile = nil;
     __block NSString *postInstFile = nil;
     
     
-    NSArray *files = [man contentsOfDirectoryAtPath:debian error:nil];
+    NSArray *files = [FM contentsOfDirectoryAtPath:debian error:nil];
     [files enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
     [files enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
         
         
         NSString *fullPath = [debian stringByAppendingPathComponent:obj];
         NSString *fullPath = [debian stringByAppendingPathComponent:obj];
         if (![obj isEqualToString:@"control"]){
         if (![obj isEqualToString:@"control"]){
-            
             if ([obj isEqualToString:@"postinst"]){
             if ([obj isEqualToString:@"postinst"]){
-                
                 postInstFile = fullPath;
                 postInstFile = fullPath;
-                
             }
             }
             DLog(@"Copying file... %@\n\n", fullPath);
             DLog(@"Copying file... %@\n\n", fullPath);
             NSString *fileName = [NSString stringWithFormat:@"%@.%@", self.packageName, obj];
             NSString *fileName = [NSString stringWithFormat:@"%@.%@", self.packageName, obj];
             NSString *newPath = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/info"];
             NSString *newPath = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/info"];
             newPath = [newPath stringByAppendingPathComponent:fileName];
             newPath = [newPath stringByAppendingPathComponent:fileName];
             //DLog(@"newPath: %@", newPath);
             //DLog(@"newPath: %@", newPath);
-            [man copyItemAtPath:fullPath toPath:newPath error:nil];
+            [FM copyItemAtPath:fullPath toPath:newPath error:nil];
             
             
         } else {
         } else {
             
             
@@ -179,66 +175,38 @@
             NSMutableString *statusContents = [[NSMutableString alloc] initWithContentsOfFile:statusFile encoding:NSASCIIStringEncoding error:nil];
             NSMutableString *statusContents = [[NSMutableString alloc] initWithContentsOfFile:statusFile encoding:NSASCIIStringEncoding error:nil];
             
             
             if (model) { //we found the package model, just replace the old string with our new one
             if (model) { //we found the package model, just replace the old string with our new one
-                
-                
                 DLog(@"Updating status file for new package version...\n\n");
                 DLog(@"Updating status file for new package version...\n\n");
                 
                 
                 [statusContents replaceOccurrencesOfString:model.rawString withString:controlFile options:NSLiteralSearch range:NSMakeRange(0, [statusContents length])];
                 [statusContents replaceOccurrencesOfString:model.rawString withString:controlFile options:NSLiteralSearch range:NSMakeRange(0, [statusContents length])];
-                
                 //[statusContents writeToFileWithoutAttributes:statusFile];
                 //[statusContents writeToFileWithoutAttributes:statusFile];
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
-                
-                
             } else {
             } else {
-                
-                
-                
                 DLog(@"Updating status file for new package...\n\n");
                 DLog(@"Updating status file for new package...\n\n");
                 
                 
                 //DLog(@"down here??: -%@-\n", controlFile);
                 //DLog(@"down here??: -%@-\n", controlFile);
-                
                 [statusContents appendFormat:@"%@\n", controlFile];
                 [statusContents appendFormat:@"%@\n", controlFile];
-                
                 //DLog(@"\nnew status file: %@\n", statusContents);
                 //DLog(@"\nnew status file: %@\n", statusContents);
-                
                 //[statusContents writeToFileWithoutAttributes:statusFile];
                 //[statusContents writeToFileWithoutAttributes:statusFile];
-                
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
-                
             }
             }
-            
-            
         }
         }
-        
-        
     }];
     }];
     
     
     //finally actually install the package onto the bootstrap
     //finally actually install the package onto the bootstrap
     
     
     DLog(@"Extracting package onto bootstrap folder...\n");
     DLog(@"Extracting package onto bootstrap folder...\n");
-    
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, bootstrapPath]];
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, bootstrapPath]];
-    
     if (postInstFile) {
     if (postInstFile) {
-        
         DLog(@"\n [WARNING] We found a postinst file, will not run this due to potential unexpected consequences in your run environment! Displaying contents so you can determine if any additional steps are necessary. Contents will be delimited by a line -----\n");
         DLog(@"\n [WARNING] We found a postinst file, will not run this due to potential unexpected consequences in your run environment! Displaying contents so you can determine if any additional steps are necessary. Contents will be delimited by a line -----\n");
-        
         DLog(@"\n%@ Contents:\n\n---------------------\n\n%@\n\n---------------------\n\n", postInstFile, [NSString stringWithContentsOfFile:postInstFile encoding:NSASCIIStringEncoding error:nil]);
         DLog(@"\n%@ Contents:\n\n---------------------\n\n%@\n\n---------------------\n\n", postInstFile, [NSString stringWithContentsOfFile:postInstFile encoding:NSASCIIStringEncoding error:nil]);
-        
-        
     }
     }
-    
     [FM removeItemAtPath:tmpPath error:nil];
     [FM removeItemAtPath:tmpPath error:nil];
-    
     DLog(@"Done!\n\n");
     DLog(@"Done!\n\n");
     return 0;
     return 0;
-    
-    
 }
 }
 
 
 - (BOOL)fileIsSymbolicLink:(NSString *)file {
 - (BOOL)fileIsSymbolicLink:(NSString *)file {
-    
-    NSString *fileType = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:nil][NSFileType];
+    NSString *fileType = [FM attributesOfItemAtPath:file error:nil][NSFileType];
     return ([fileType isEqualToString:NSFileTypeSymbolicLink] || [fileType isEqualToString:NSFileTypeDirectory]);
     return ([fileType isEqualToString:NSFileTypeSymbolicLink] || [fileType isEqualToString:NSFileTypeDirectory]);
 }
 }
 
 
@@ -247,15 +215,13 @@
         DLog(@"skipping symbolic link: %@", file);
         DLog(@"skipping symbolic link: %@", file);
         return;
         return;
     }
     }
-    NSFileManager *man = [NSFileManager defaultManager];
     NSString *fat = [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -info %@",file]];
     NSString *fat = [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -info %@",file]];
     if ([fat containsString:@"Architectures"]){
     if ([fat containsString:@"Architectures"]){
         NSString *newFile = [file stringByAppendingPathExtension:@"thin"];
         NSString *newFile = [file stringByAppendingPathExtension:@"thin"];
         [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -thin arm64 %@ -output %@",file, newFile]];
         [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -thin arm64 %@ -output %@",file, newFile]];
-        if ([man fileExistsAtPath:newFile]){
-            
-            [man removeItemAtPath:file error:nil];
-            [man moveItemAtPath:newFile toPath:file error:nil];
+        if ([FM fileExistsAtPath:newFile]){
+            [FM removeItemAtPath:file error:nil];
+            [FM moveItemAtPath:newFile toPath:file error:nil];
         }
         }
         int uni = [Universalize universalize:file];
         int uni = [Universalize universalize:file];
         if (uni == 1){
         if (uni == 1){
@@ -268,47 +234,33 @@
     }
     }
 }
 }
 
 
+//FIXME: change to ldid
 - (void)codesignRetainingSignature:(NSString *)file {
 - (void)codesignRetainingSignature:(NSString *)file {
-    
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     if (jtp){
     if (jtp){
-        
-        [[NSFileManager defaultManager] removeItemAtPath:@"/tmp/ent.plist" error:nil];
+        [FM removeItemAtPath:@"/tmp/ent.plist" error:nil];
         [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"%@ %@ --ent > /tmp/ent.plist", jtp, file]];
         [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"%@ %@ --ent > /tmp/ent.plist", jtp, file]];
         NSString *ents = [HelperClass singleLineReturnForProcess:@"/bin/cat /tmp/ent.plist"];
         NSString *ents = [HelperClass singleLineReturnForProcess:@"/bin/cat /tmp/ent.plist"];
         DLog(@"ents: %@", ents);
         DLog(@"ents: %@", ents);
         NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --ent /tmp/ent.plist --inplace", jtp, file];
         NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --ent /tmp/ent.plist --inplace", jtp, file];
-        
         DLog(@"running codesign command: %@", runCommand);
         DLog(@"running codesign command: %@", runCommand);
-        
         NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
         NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
-        
         DLog(@"returnValue: %@", returnValue);
         DLog(@"returnValue: %@", returnValue);
-        
     }
     }
 }
 }
 
 
 - (void)codesignIfNecessary:(NSString *)file {
 - (void)codesignIfNecessary:(NSString *)file {
-    
     if (![[[file pathExtension] lowercaseString] isEqualToString:@"dylib"]){
     if (![[[file pathExtension] lowercaseString] isEqualToString:@"dylib"]){
         return;
         return;
     }
     }
-    
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     if (jtp){
     if (jtp){
-        
         NSString *proc = [[HelperClass arrayReturnForTask:jtp withArguments:@[@"--sig", file]] componentsJoinedByString:@"\n"];
         NSString *proc = [[HelperClass arrayReturnForTask:jtp withArguments:@[@"--sig", file]] componentsJoinedByString:@"\n"];
-        
         NSLog(@"proc: %@", proc);
         NSLog(@"proc: %@", proc);
-        
         if ([proc containsString:@"No Code Signing blob detected in this file"]){
         if ([proc containsString:@"No Code Signing blob detected in this file"]){
-            
             NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --inplace", jtp, file];
             NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --inplace", jtp, file];
-            
             NSLog(@"running codesign command: %@", runCommand);
             NSLog(@"running codesign command: %@", runCommand);
-            
             NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
             NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
-            
             NSLog(@"returnValue: %@", returnValue);
             NSLog(@"returnValue: %@", returnValue);
         }
         }
     }
     }
@@ -356,10 +308,7 @@
     [FM createDirectoryAtPath:debian withIntermediateDirectories:TRUE attributes:nil error:nil];
     [FM createDirectoryAtPath:debian withIntermediateDirectories:TRUE attributes:nil error:nil];
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
-    
-    
     NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
     NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
-    
     NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
     NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
     //@"appletvos-arm64"
     //@"appletvos-arm64"
     [controlFile replaceOccurrencesOfString:self.version withString:[self.version nextVersionNumber] options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
     [controlFile replaceOccurrencesOfString:self.version withString:[self.version nextVersionNumber] options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
@@ -376,12 +325,9 @@
     
     
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
-            
             //DLog(@"processing path: %@", obj.path);
             //DLog(@"processing path: %@", obj.path);
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
-                
                 NSString *badPath = [tmpPath stringByAppendingPathComponent:obj.path];
                 NSString *badPath = [tmpPath stringByAppendingPathComponent:obj.path];
                 NSString *newPath = [tmpPath stringByAppendingPathComponent:@"Applications"];
                 NSString *newPath = [tmpPath stringByAppendingPathComponent:@"Applications"];
                 DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
                 DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
@@ -391,12 +337,9 @@
             }
             }
             
             
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
-            
             if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
             if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
-                
                 DLog(@"in ignore file list, purge");
                 DLog(@"in ignore file list, purge");
                 [FM removeItemAtPath:fullPath error:nil];
                 [FM removeItemAtPath:fullPath error:nil];
-                
             }
             }
             
             
             if (self.appendedPrefix.length > 0 && [obj.path properPathComponents].count == 1) {
             if (self.appendedPrefix.length > 0 && [obj.path properPathComponents].count == 1) {
@@ -444,9 +387,7 @@
     NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
     NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
     DLog(@"\nProcessing file: %@\n", self.path);
     DLog(@"\nProcessing file: %@\n", self.path);
     InputPackage *output = self;
     InputPackage *output = self;
-    
     DLog(@"\nFound package: '%@' at version: '%@'...\n", output.packageName, output.version );
     DLog(@"\nFound package: '%@' at version: '%@'...\n", output.packageName, output.version );
-    
     NSString *tmpPath = [pwd stringByAppendingPathComponent:output.packageName];
     NSString *tmpPath = [pwd stringByAppendingPathComponent:output.packageName];
     NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
     NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
     NSString *newRoot = nil;
     NSString *newRoot = nil;
@@ -463,25 +404,17 @@
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
     
     
     //clean up any calls to uicache
     //clean up any calls to uicache
-    
     NSString *postinst = [debian stringByAppendingPathComponent:@"postinst"];
     NSString *postinst = [debian stringByAppendingPathComponent:@"postinst"];
-    
     //DLog(@"post inst: %@", postinst);
     //DLog(@"post inst: %@", postinst);
-    
     if ([FM fileExistsAtPath:postinst]){
     if ([FM fileExistsAtPath:postinst]){
         NSString *postinstSource = [NSString stringWithContentsOfFile:postinst encoding:NSUTF8StringEncoding error:nil];
         NSString *postinstSource = [NSString stringWithContentsOfFile:postinst encoding:NSUTF8StringEncoding error:nil];
         if (postinstSource.length > 0){
         if (postinstSource.length > 0){
             if ([postinstSource rangeOfString:@"uicache"].location != NSNotFound){
             if ([postinstSource rangeOfString:@"uicache"].location != NSNotFound){
-                
                 NSMutableArray *lines = [[postinstSource componentsSeparatedByString:@"\n"] mutableCopy];
                 NSMutableArray *lines = [[postinstSource componentsSeparatedByString:@"\n"] mutableCopy];
-                
                 //DLog(@"lines: %@", lines);
                 //DLog(@"lines: %@", lines);
-                
                 __block NSInteger markedForDeath = NSNotFound;
                 __block NSInteger markedForDeath = NSNotFound;
                 [lines enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 [lines enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                    
                     //  DLog(@"obj: %@", obj);
                     //  DLog(@"obj: %@", obj);
-                    
                     if ([obj rangeOfString:@"uicache"].location != NSNotFound){
                     if ([obj rangeOfString:@"uicache"].location != NSNotFound){
                         
                         
                         if ([obj rangeOfString:@"echo"].location == NSNotFound){
                         if ([obj rangeOfString:@"echo"].location == NSNotFound){
@@ -490,35 +423,23 @@
                             markedForDeath = idx;
                             markedForDeath = idx;
                         }
                         }
                         *stop = TRUE;
                         *stop = TRUE;
-                        
                     }
                     }
-                    
                 }];
                 }];
-                
                 if (markedForDeath != NSNotFound){
                 if (markedForDeath != NSNotFound){
-                    
                     [lines removeObjectAtIndex:markedForDeath];
                     [lines removeObjectAtIndex:markedForDeath];
                     NSString *newString = [lines componentsJoinedByString:@"\n"];
                     NSString *newString = [lines componentsJoinedByString:@"\n"];
                     [newString writeToFile:postinst atomically:TRUE];
                     [newString writeToFile:postinst atomically:TRUE];
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
                 }
                 }
-                
             }
             }
         }
         }
-        
-        
     }
     }
-    
     if (newArch != nil) {
     if (newArch != nil) {
-        
         NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
         NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
         NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
         NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
         //@"appletvos-arm64"
         //@"appletvos-arm64"
-        
         //this is hacky but should be fine, only one of the two should exist so only one will get overwritten.
         //this is hacky but should be fine, only one of the two should exist so only one will get overwritten.
-        
         [controlFile replaceOccurrencesOfString:@"iphoneos-arm" withString:newArch options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
         [controlFile replaceOccurrencesOfString:@"iphoneos-arm" withString:newArch options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
-        
         [controlFile replaceOccurrencesOfString:@"darwin-arm64" withString:newArch options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
         [controlFile replaceOccurrencesOfString:@"darwin-arm64" withString:newArch options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
         
         
 #pragma clang diagnostic push
 #pragma clang diagnostic push
@@ -528,15 +449,12 @@
     }
     }
     
     
     //at this point we have the files extracted, time to determine what needs to be changed
     //at this point we have the files extracted, time to determine what needs to be changed
-    
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
     [self flattenInPath:tmpPath];
     [self flattenInPath:tmpPath];
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
-            
             //DLog(@"processing path: %@", obj.path);
             //DLog(@"processing path: %@", obj.path);
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
                 
                 
@@ -547,34 +465,26 @@
                 [FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
                 [FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
                 *stop = TRUE;
                 *stop = TRUE;
             }
             }
-            
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
-            
-            if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
-                
+            if ([ignoreFiles containsObject:obj.path.lastPathComponent]) {
                 DLog(@"in ignore file list, purge");
                 DLog(@"in ignore file list, purge");
                 [FM removeItemAtPath:fullPath error:nil];
                 [FM removeItemAtPath:fullPath error:nil];
-                
             }
             }
             if (self.appendedPrefix.length > 0) {
             if (self.appendedPrefix.length > 0) {
-                if (![obj.path containsString:self.appendedPrefix]){
+                if (![obj.path containsString:self.appendedPrefix]) {
                     DLog(@"[INFO] %@ doesnt have the prefix!", obj.path);
                     DLog(@"[INFO] %@ doesnt have the prefix!", obj.path);
                     [moveRoot addObject:obj.path];
                     [moveRoot addObject:obj.path];
                 }
                 }
             }
             }
             NSArray *pathComponents = [obj.path pathComponents];
             NSArray *pathComponents = [obj.path pathComponents];
-            if ([pathComponents count] > 1)
-            {
-                
+            if ([pathComponents count] > 1) {
                 NSString *rootPath = [pathComponents objectAtIndex:1];
                 NSString *rootPath = [pathComponents objectAtIndex:1];
                 //DLog(@"\n Checking root path: %@ for file %@\n", rootPath, obj.path);
                 //DLog(@"\n Checking root path: %@ for file %@\n", rootPath, obj.path);
-                if ([forbiddenRoots containsObject:rootPath])
-                {
+                if ([forbiddenRoots containsObject:rootPath]) {
                     DLog(@"\n [WARNING] package file: '%@' would overwrite symbolic link at '%@'\n", obj.path, rootPath);
                     DLog(@"\n [WARNING] package file: '%@' would overwrite symbolic link at '%@'\n", obj.path, rootPath);
                     NSString *privateDir = [tmpPath stringByAppendingPathComponent:@"private"];
                     NSString *privateDir = [tmpPath stringByAppendingPathComponent:@"private"];
-                    if (![FM fileExistsAtPath:privateDir]){
+                    if (![FM fileExistsAtPath:privateDir]) {
                         [FM createDirectoryAtPath:privateDir withIntermediateDirectories:TRUE attributes:nil error:nil];
                         [FM createDirectoryAtPath:privateDir withIntermediateDirectories:TRUE attributes:nil error:nil];
-                        
                     }
                     }
                     //take <package_name>/[rootPath] (could be etc, var, tmp) and move to <package_name>/private/[rootPath]
                     //take <package_name>/[rootPath] (could be etc, var, tmp) and move to <package_name>/private/[rootPath]
                     NSString *badPath = [tmpPath stringByAppendingPathComponent:rootPath];
                     NSString *badPath = [tmpPath stringByAppendingPathComponent:rootPath];
@@ -592,67 +502,42 @@
         [FM moveItemAtPath:oldPath toPath:newPath error:nil];
         [FM moveItemAtPath:oldPath toPath:newPath error:nil];
     }];
     }];
     NSString *depArchiveInfo = [NSString stringWithFormat:@"/usr/local/bin/dpkg -b %@", self.packageName];
     NSString *depArchiveInfo = [NSString stringWithFormat:@"/usr/local/bin/dpkg -b %@", self.packageName];
-    
     if (fakeRoot) {
     if (fakeRoot) {
-        
         depArchiveInfo = [NSString stringWithFormat:@"%@ /usr/local/bin/dpkg -b %@", fakeRoot, self.packageName];
         depArchiveInfo = [NSString stringWithFormat:@"%@ /usr/local/bin/dpkg -b %@", fakeRoot, self.packageName];
-        
-        
     }
     }
-    
     [[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
     [[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
-    
-    
-    
     DLog(@"\nDone!\n\n");
     DLog(@"\nDone!\n\n");
-    
-    //return er;
 }
 }
 
 
-- (ErrorReturn *)errorReturnForBootstrap:(NSString *)bootstrapPath
-{
+- (ErrorReturn *)errorReturnForBootstrap:(NSString *)bootstrapPath {
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
-    NSFileManager *man = [NSFileManager defaultManager];
     __block NSInteger returnValue = 0; //0 = good to go 1 = over write warning, 2 = no go
     __block NSInteger returnValue = 0; //0 = good to go 1 = over write warning, 2 = no go
     __block NSMutableArray *_overwriteArray = [NSMutableArray new];
     __block NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if ([obj.fileType isEqualToString:@"file"]){
         if ([obj.fileType isEqualToString:@"file"]){
-            
             NSString *fullPath = [bootstrapPath stringByAppendingPathComponent:obj.path];
             NSString *fullPath = [bootstrapPath stringByAppendingPathComponent:obj.path];
-            if ([man fileExistsAtPath:fullPath] && ![ignoreFiles containsObject:obj.basename]){
-                
+            if ([FM fileExistsAtPath:fullPath] && ![ignoreFiles containsObject:obj.basename]){
                 //DLog(@"[WARNING] overwriting a file that already exists and isn't DS_Store or .fauxsu: %@", fullPath);
                 //DLog(@"[WARNING] overwriting a file that already exists and isn't DS_Store or .fauxsu: %@", fullPath);
                 [_overwriteArray addObject:obj.path];
                 [_overwriteArray addObject:obj.path];
                 //*stop = TRUE;//return FALSE;
                 //*stop = TRUE;//return FALSE;
                 returnValue = 1;
                 returnValue = 1;
             }
             }
-            
             NSArray *pathComponents = [obj.path pathComponents];
             NSArray *pathComponents = [obj.path pathComponents];
-            if ([pathComponents count] > 1)
-            {
+            if ([pathComponents count] > 1) {
                 NSString *rootPath = [pathComponents objectAtIndex:1];
                 NSString *rootPath = [pathComponents objectAtIndex:1];
-                if ([forbiddenRoots containsObject:rootPath])
-                {
+                if ([forbiddenRoots containsObject:rootPath]) {
                     DLog(@"\n [ERROR] package file: '%@' would overwrite symbolic link at '%@'! Exiting!\n\n", obj.path, rootPath);
                     DLog(@"\n [ERROR] package file: '%@' would overwrite symbolic link at '%@'! Exiting!\n\n", obj.path, rootPath);
                     *stop = TRUE;
                     *stop = TRUE;
                     returnValue = 2;
                     returnValue = 2;
                 }
                 }
             }
             }
-            
-            
         }
         }
-        
-        
     }];
     }];
-    
     ErrorReturn *er = [ErrorReturn new];
     ErrorReturn *er = [ErrorReturn new];
     er.returnStatus = returnValue;
     er.returnStatus = returnValue;
     er.overwriteFiles = _overwriteArray;
     er.overwriteFiles = _overwriteArray;
-    
     return er;
     return er;
 }
 }
 
 
-
 @end
 @end

+ 0 - 10
bootstrapTool/Classes/InputPackageFile.m

@@ -22,9 +22,7 @@
  */
  */
 
 
 + (NSString* )readableFileTypeForRawMode:(NSString *)fileTypeChar {
 + (NSString* )readableFileTypeForRawMode:(NSString *)fileTypeChar {
-    
     NSString *fileType = nil;
     NSString *fileType = nil;
-    
     if ([fileTypeChar isEqualToString:@"-"])
     if ([fileTypeChar isEqualToString:@"-"])
     { fileType = @"file"; }
     { fileType = @"file"; }
     else if ([fileTypeChar isEqualToString:@"d"])
     else if ([fileTypeChar isEqualToString:@"d"])
@@ -39,15 +37,11 @@
     { fileType = @"pipe"; }
     { fileType = @"pipe"; }
     else if ([fileTypeChar isEqualToString:@"s"])
     else if ([fileTypeChar isEqualToString:@"s"])
     { fileType = @"socket"; }
     { fileType = @"socket"; }
-    
     return fileType;
     return fileType;
-    
 }
 }
 
 
 + (BSPackageFileType)fileTypeForRawMode:(NSString *)fileTypeChar {
 + (BSPackageFileType)fileTypeForRawMode:(NSString *)fileTypeChar {
-    
     BSPackageFileType type = BSPackageFileTypeUnknown;
     BSPackageFileType type = BSPackageFileTypeUnknown;
-    
     if ([fileTypeChar isEqualToString:@"-"])
     if ([fileTypeChar isEqualToString:@"-"])
     { type = BSPackageFileTypeFile; }
     { type = BSPackageFileTypeFile; }
     else if ([fileTypeChar isEqualToString:@"d"])
     else if ([fileTypeChar isEqualToString:@"d"])
@@ -68,20 +62,16 @@
 }
 }
 
 
 - (NSString*) description {
 - (NSString*) description {
-    
     NSString *orig = [super description];
     NSString *orig = [super description];
     NSMutableDictionary *details = [NSMutableDictionary new];
     NSMutableDictionary *details = [NSMutableDictionary new];
     NSArray *props = [self properties];
     NSArray *props = [self properties];
     [props enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
     [props enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         NSString *cv = [self valueForKey:obj];
         NSString *cv = [self valueForKey:obj];
         if (cv){
         if (cv){
             details[obj] = cv;
             details[obj] = cv;
         }
         }
-        
     }];
     }];
     return [NSString stringWithFormat:@"%@ = %@", orig, details];
     return [NSString stringWithFormat:@"%@ = %@", orig, details];
-    
 }
 }
 
 
 @end
 @end

+ 7 - 112
bootstrapTool/main.m

@@ -13,15 +13,11 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <getopt.h>
-
 #import <sys/utsname.h>
 #import <sys/utsname.h>
-
 #import "HelperClass.h"
 #import "HelperClass.h"
 
 
-
 #define OPTION_FLAGS "o:i:ld:hcrbp:s"
 #define OPTION_FLAGS "o:i:ld:hcrbp:s"
 
 
-
 char *progname;
 char *progname;
 char *path;
 char *path;
 
 
@@ -80,33 +76,26 @@ int main(int argc, char **argv) {
                     break;
                     break;
                     
                     
                 case 'i':
                 case 'i':
-                    
                     debFile = [NSString stringWithUTF8String:optarg];
                     debFile = [NSString stringWithUTF8String:optarg];
                     break;
                     break;
                     
                     
                 case 'l':
                 case 'l':
-                    
                     listPackage = TRUE;
                     listPackage = TRUE;
                     break;
                     break;
                     
                     
                 case 'd':
                 case 'd':
-                    
                     deletePackage = [NSString stringWithUTF8String:optarg];
                     deletePackage = [NSString stringWithUTF8String:optarg];
                     break;
                     break;
                     
                     
                 case 'b':
                 case 'b':
-                    
                     bump = TRUE;
                     bump = TRUE;
-                    
                     break;
                     break;
                     
                     
                 case 'r':
                 case 'r':
-                    
                     repackage = TRUE;
                     repackage = TRUE;
                     break;
                     break;
                     
                     
                 case 'c':
                 case 'c':
-                    
                     clean = TRUE;
                     clean = TRUE;
                     break;
                     break;
                     
                     
@@ -121,21 +110,18 @@ int main(int argc, char **argv) {
                 default:
                 default:
                     cmd_help();
                     cmd_help();
                     return -1;
                     return -1;
-                    
             }
             }
         }
         }
         
         
         if (argc-optind == 1) {
         if (argc-optind == 1) {
             argc -= optind;
             argc -= optind;
             argv += optind;
             argv += optind;
-            
             bootstrapPath = [NSString stringWithUTF8String:argv[0]];
             bootstrapPath = [NSString stringWithUTF8String:argv[0]];
             NSLog(@"bootstrap path: %@?", bootstrapPath);
             NSLog(@"bootstrap path: %@?", bootstrapPath);
             //return 0;
             //return 0;
         }
         }
         
         
         if (bump == TRUE && debFile) {
         if (bump == TRUE && debFile) {
-            
             DLog(@"\n [INFO] Bumping version number for file: %@...\n", debFile);
             DLog(@"\n [INFO] Bumping version number for file: %@...\n", debFile);
             InputPackage *output = [HelperClass packageForDeb:debFile];
             InputPackage *output = [HelperClass packageForDeb:debFile];
             output.appendedPrefix = prefix;
             output.appendedPrefix = prefix;
@@ -145,7 +131,6 @@ int main(int argc, char **argv) {
         }
         }
         
         
         if (repackage == TRUE && debFile) {
         if (repackage == TRUE && debFile) {
-            
             DLog(@"\n [INFO] Repackaging file: %@...\n", debFile);
             DLog(@"\n [INFO] Repackaging file: %@...\n", debFile);
             InputPackage *output = [HelperClass packageForDeb:debFile];
             InputPackage *output = [HelperClass packageForDeb:debFile];
             output.appendedPrefix = prefix;
             output.appendedPrefix = prefix;
@@ -154,13 +139,9 @@ int main(int argc, char **argv) {
             return 0;
             return 0;
         }
         }
         
         
-        
         //DLog(@"folder: %@ project: %@", folder, project);
         //DLog(@"folder: %@ project: %@", folder, project);
-        
         if (clean && bootstrapPath) {
         if (clean && bootstrapPath) {
-            
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
-            
             NSString *listContents = [NSString stringWithContentsOfFile:statusFile encoding:NSUTF8StringEncoding error:nil];
             NSString *listContents = [NSString stringWithContentsOfFile:statusFile encoding:NSUTF8StringEncoding error:nil];
             //clean up any errant spaces
             //clean up any errant spaces
             listContents = [listContents stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\n\n"];
             listContents = [listContents stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\n\n"];
@@ -177,206 +158,123 @@ int main(int argc, char **argv) {
             __block NSMutableArray *alreadyAdded = [NSMutableArray new];
             __block NSMutableArray *alreadyAdded = [NSMutableArray new];
             
             
             [installedPackages enumerateObjectsUsingBlock:^(StatusPackageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
             [installedPackages enumerateObjectsUsingBlock:^(StatusPackageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                
                 DLog(@"\n [INFO] Processing package: %@", obj.package);
                 DLog(@"\n [INFO] Processing package: %@", obj.package);
-                
                 if (![alreadyAdded containsObject:obj.package]){
                 if (![alreadyAdded containsObject:obj.package]){
-                    
                     //duplicate check first
                     //duplicate check first
                     NSArray *doubleCheck = [installedPackages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"package == %@", obj.package]];
                     NSArray *doubleCheck = [installedPackages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"package == %@", obj.package]];
-                    
                     if (doubleCheck.count > 1){
                     if (doubleCheck.count > 1){
-                        
                         NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"version" ascending:FALSE];
                         NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"version" ascending:FALSE];
                         StatusPackageModel *latestVersion = [[doubleCheck sortedArrayUsingDescriptors:@[sortDesc]] firstObject];
                         StatusPackageModel *latestVersion = [[doubleCheck sortedArrayUsingDescriptors:@[sortDesc]] firstObject];
                         DLog(@"\n [INFO] We found a duplicate package, choosing latestVersion: %@", latestVersion);
                         DLog(@"\n [INFO] We found a duplicate package, choosing latestVersion: %@", latestVersion);
-                        
-                        
                         [newStatusFile appendFormat:@"%@\n\n", latestVersion.rawString];
                         [newStatusFile appendFormat:@"%@\n\n", latestVersion.rawString];
                         [alreadyAdded addObject:obj.package];
                         [alreadyAdded addObject:obj.package];
-                        
                     } else {
                     } else {
-                        
-                        
                         [newStatusFile appendFormat:@"%@\n\n", obj.rawString];
                         [newStatusFile appendFormat:@"%@\n\n", obj.rawString];
-                        
                     }
                     }
-                    
                 } else {
                 } else {
-                    
                     DLog(@"\n [INFO] We already had this package, skipping older duplicate: %@\n", obj.package);
                     DLog(@"\n [INFO] We already had this package, skipping older duplicate: %@\n", obj.package);
-                    
                 }
                 }
-                
-            
-                
-                
-                
             }];
             }];
-            
             testStatusFile = [testStatusFile stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\n\n"];
             testStatusFile = [testStatusFile stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\n\n"];
-            
             DLog(@"\n Writing new output file: %@\n", testStatusFile);
             DLog(@"\n Writing new output file: %@\n", testStatusFile);
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
             [newStatusFile writeToFile:testStatusFile atomically:TRUE];
             [newStatusFile writeToFile:testStatusFile atomically:TRUE];
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
             DLog(@"\n Done!\n\n");
             DLog(@"\n Done!\n\n");
-            
             return 0;
             return 0;
             
             
         } else if (clean) {
         } else if (clean) {
-            
             DLog(@"\nYou need to choose a bootstrap path to clean!\n\n");
             DLog(@"\nYou need to choose a bootstrap path to clean!\n\n");
             return 1;
             return 1;
-            
         }
         }
-        
         if (deletePackage && bootstrapPath) {
         if (deletePackage && bootstrapPath) {
-            
             __block NSString *postRmFile = nil;
             __block NSString *postRmFile = nil;
-            
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
             NSArray <StatusPackageModel*> *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
             NSArray <StatusPackageModel*> *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
-            
             StatusPackageModel *model = [[installedPackages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"package == %@", deletePackage]] lastObject];
             StatusPackageModel *model = [[installedPackages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"package == %@", deletePackage]] lastObject];
-            
             if (model) {
             if (model) {
-                
-                
                 NSString *listName = [NSString stringWithFormat:@"%@.list", deletePackage];
                 NSString *listName = [NSString stringWithFormat:@"%@.list", deletePackage];
                 NSString *infoPath = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/info"];
                 NSString *infoPath = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/info"];
                 NSString *listFile = [infoPath stringByAppendingPathComponent:listName];
                 NSString *listFile = [infoPath stringByAppendingPathComponent:listName];
-                
                 NSArray *listFiles = [FM contentsOfDirectoryAtPath:infoPath error:nil];
                 NSArray *listFiles = [FM contentsOfDirectoryAtPath:infoPath error:nil];
-                
                 NSPredicate *blockPred = [NSPredicate predicateWithBlock:^BOOL(id  _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
                 NSPredicate *blockPred = [NSPredicate predicateWithBlock:^BOOL(id  _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
-                    
                     if ([evaluatedObject containsString:deletePackage]){
                     if ([evaluatedObject containsString:deletePackage]){
                         return TRUE;
                         return TRUE;
                     }
                     }
                     return FALSE;
                     return FALSE;
                 }];
                 }];
-                
                 NSArray *relatedFiles = [listFiles filteredArrayUsingPredicate:blockPred]; //any files in dpkg/info/deletePackage.*
                 NSArray *relatedFiles = [listFiles filteredArrayUsingPredicate:blockPred]; //any files in dpkg/info/deletePackage.*
-                
                 DLog(@"\nWe have found the package, determining list details from: %@", listFile);
                 DLog(@"\nWe have found the package, determining list details from: %@", listFile);
-                
                 NSString *listContents = [NSString stringWithContentsOfFile:listFile encoding:NSUTF8StringEncoding error:nil];
                 NSString *listContents = [NSString stringWithContentsOfFile:listFile encoding:NSUTF8StringEncoding error:nil];
                 DLog(@"\nContents: %@\n", listContents);
                 DLog(@"\nContents: %@\n", listContents);
-                
-
-                
                 DLog(@"\nFound package info files: %@\n", relatedFiles);
                 DLog(@"\nFound package info files: %@\n", relatedFiles);
-                
                 NSArray *files = [listContents componentsSeparatedByString:@"\n"];
                 NSArray *files = [listContents componentsSeparatedByString:@"\n"];
                 __block NSMutableArray *filesToProcess = [NSMutableArray new];
                 __block NSMutableArray *filesToProcess = [NSMutableArray new];
-                
                 [relatedFiles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 [relatedFiles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                    
                     NSString *fullPath = [infoPath stringByAppendingPathComponent:obj];
                     NSString *fullPath = [infoPath stringByAppendingPathComponent:obj];
                     if([FM fileExistsAtPath:fullPath]){
                     if([FM fileExistsAtPath:fullPath]){
-                        
                         if ([[obj pathExtension] isEqualToString:@"postrm"]){
                         if ([[obj pathExtension] isEqualToString:@"postrm"]){
                             postRmFile = fullPath;
                             postRmFile = fullPath;
                         }
                         }
                         [filesToProcess addObject:fullPath];
                         [filesToProcess addObject:fullPath];
-                        
                     }
                     }
-                    
                 }];
                 }];
-                
                 [files enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 [files enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                    
                     NSString *fullPath = [bootstrapPath stringByAppendingPathComponent:obj];
                     NSString *fullPath = [bootstrapPath stringByAppendingPathComponent:obj];
                     BOOL isDir = FALSE;
                     BOOL isDir = FALSE;
                     if([FM fileExistsAtPath:fullPath isDirectory:&isDir]){
                     if([FM fileExistsAtPath:fullPath isDirectory:&isDir]){
-                        
                         if (!isDir){
                         if (!isDir){
                             DLog(@"found file: %@", fullPath);
                             DLog(@"found file: %@", fullPath);
                             [filesToProcess addObject:fullPath];
                             [filesToProcess addObject:fullPath];
                         }
                         }
-                        
                     }
                     }
-                    
                 }];
                 }];
-                
                 DLog(@"\nFiles to process: %@\n", filesToProcess);
                 DLog(@"\nFiles to process: %@\n", filesToProcess);
-                
                 NSString *error = [NSString stringWithFormat:@" [WARNING] We are about to delete '%@' from the bootstrap, this cannot be undone!", deletePackage];
                 NSString *error = [NSString stringWithFormat:@" [WARNING] We are about to delete '%@' from the bootstrap, this cannot be undone!", deletePackage];
                 if(![HelperClass shouldContinueWithError:error]){
                 if(![HelperClass shouldContinueWithError:error]){
-                    
                     return -1;
                     return -1;
                 }
                 }
-                
                 [filesToProcess enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 [filesToProcess enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                   
                     [FM removeItemAtPath:obj error:nil];
                     [FM removeItemAtPath:obj error:nil];
-                    
                 }];
                 }];
                 
                 
                 //TODO: delete the files here!
                 //TODO: delete the files here!
-                
-                
                 NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
                 NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
                 [FM copyItemAtPath:statusFile toPath:[statusFile stringByAppendingPathExtension:@"bak"] error:nil];
                 [FM copyItemAtPath:statusFile toPath:[statusFile stringByAppendingPathExtension:@"bak"] error:nil];
-
                 __block NSMutableString *newStatusFile = [NSMutableString new];
                 __block NSMutableString *newStatusFile = [NSMutableString new];
-                
                 [installedPackages enumerateObjectsUsingBlock:^(StatusPackageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 [installedPackages enumerateObjectsUsingBlock:^(StatusPackageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-                    
                     if (obj != model){
                     if (obj != model){
-                        
                         [newStatusFile appendFormat:@"%@\n\n", obj.rawString];
                         [newStatusFile appendFormat:@"%@\n\n", obj.rawString];
-                        
                     } else {
                     } else {
-                        
                         DLog(@"skipping the model we want to delete: %@", obj);
                         DLog(@"skipping the model we want to delete: %@", obj);
-                        
                     }
                     }
-                    
                 }];
                 }];
 #pragma clang diagnostic push
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
                 [newStatusFile writeToFile:statusFile atomically:TRUE];
                 [newStatusFile writeToFile:statusFile atomically:TRUE];
 #pragma clang diagnostic pop
 #pragma clang diagnostic pop
-                
                 if (postRmFile) {
                 if (postRmFile) {
-                    
                     DLog(@"\n [WARNING] We found a postrm file, will not run this due to potential unexpected consequences off of the target device, displaying contents so you can determine if any additional steps are necessary\n");
                     DLog(@"\n [WARNING] We found a postrm file, will not run this due to potential unexpected consequences off of the target device, displaying contents so you can determine if any additional steps are necessary\n");
-                    
                     DLog(@"\n\n%@ contents:\n%@\n\n", postRmFile, [NSString stringWithContentsOfFile:postRmFile encoding:NSUTF8StringEncoding error:nil]);
                     DLog(@"\n\n%@ contents:\n%@\n\n", postRmFile, [NSString stringWithContentsOfFile:postRmFile encoding:NSUTF8StringEncoding error:nil]);
-                    
-                    
-                    
                 }
                 }
-                
             }
             }
-            
-            
             return 0;
             return 0;
         } else if (deletePackage) {
         } else if (deletePackage) {
-            
             DLog(@"\nYou need to choose a bootstrap path to delete from!\n\n");
             DLog(@"\nYou need to choose a bootstrap path to delete from!\n\n");
             return 1;
             return 1;
-            
         }
         }
-        
         if (octalFile) {
         if (octalFile) {
-            
-            if([[NSFileManager defaultManager] fileExistsAtPath:octalFile]) {
-                
-               NSDictionary *attrs = [FM attributesOfItemAtPath:octalFile error:nil];
+            if([FM fileExistsAtPath:octalFile]) {
+                NSDictionary *attrs = [FM attributesOfItemAtPath:octalFile error:nil];
                 NSNumber *posixPerms = attrs[NSFilePosixPermissions];
                 NSNumber *posixPerms = attrs[NSFilePosixPermissions];
                 DLog(@"perms: %@", posixPerms);
                 DLog(@"perms: %@", posixPerms);
                 return 0;
                 return 0;
-                
             }
             }
             NSString *octal = [HelperClass octalFromSymbols:octalFile];
             NSString *octal = [HelperClass octalFromSymbols:octalFile];
             DLog(@"%@", octal);
             DLog(@"%@", octal);
             return 0;
             return 0;
         }
         }
-        
         if (listPackage && bootstrapPath) {
         if (listPackage && bootstrapPath) {
             
             
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
             NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
@@ -386,21 +284,18 @@ int main(int argc, char **argv) {
             
             
         } else if (listPackage) {
         } else if (listPackage) {
             
             
-             DLog(@"\nYou need to choose a bootstrap path to list packages from!\n\n");
-             return 1;
+            DLog(@"\nYou need to choose a bootstrap path to list packages from!\n\n");
+            return 1;
         }
         }
         
         
-        
         if (debFile && bootstrapPath) {
         if (debFile && bootstrapPath) {
-            
-    
             DLog(@"\nProcessing file: %@\n", debFile);
             DLog(@"\nProcessing file: %@\n", debFile);
             InputPackage *output = [HelperClass packageForDeb:debFile];
             InputPackage *output = [HelperClass packageForDeb:debFile];
             return [output installToBootstrapPath:bootstrapPath];
             return [output installToBootstrapPath:bootstrapPath];
-           
+            
         } else if (debFile) {
         } else if (debFile) {
-             DLog(@"\nYou need to choose a bootstrap path to install the package to!\n\n");
-             return 1;
+            DLog(@"\nYou need to choose a bootstrap path to install the package to!\n\n");
+            return 1;
         }
         }
         //if we got this far.. nothing happened, print help.
         //if we got this far.. nothing happened, print help.
         cmd_help();
         cmd_help();