Browse Source

tighten up the spacing and some minor refactoring

Kevin Bradley 1 year 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"];
     
-    NSFileManager *man = [NSFileManager defaultManager];
     NSString *tmpPath = [pwd stringByAppendingPathComponent:self.packageName];
     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");
     [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];
     */
-    [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");
     
@@ -144,23 +143,20 @@
     
     __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) {
         
         NSString *fullPath = [debian stringByAppendingPathComponent:obj];
         if (![obj isEqualToString:@"control"]){
-            
             if ([obj isEqualToString:@"postinst"]){
-                
                 postInstFile = fullPath;
-                
             }
             DLog(@"Copying file... %@\n\n", fullPath);
             NSString *fileName = [NSString stringWithFormat:@"%@.%@", self.packageName, obj];
             NSString *newPath = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/info"];
             newPath = [newPath stringByAppendingPathComponent:fileName];
             //DLog(@"newPath: %@", newPath);
-            [man copyItemAtPath:fullPath toPath:newPath error:nil];
+            [FM copyItemAtPath:fullPath toPath:newPath error:nil];
             
         } else {
             
@@ -179,66 +175,38 @@
             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
-                
-                
                 DLog(@"Updating status file for new package version...\n\n");
                 
                 [statusContents replaceOccurrencesOfString:model.rawString withString:controlFile options:NSLiteralSearch range:NSMakeRange(0, [statusContents length])];
-                
                 //[statusContents writeToFileWithoutAttributes:statusFile];
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
-                
-                
             } else {
-                
-                
-                
                 DLog(@"Updating status file for new package...\n\n");
                 
                 //DLog(@"down here??: -%@-\n", controlFile);
-                
                 [statusContents appendFormat:@"%@\n", controlFile];
-                
                 //DLog(@"\nnew status file: %@\n", statusContents);
-                
                 //[statusContents writeToFileWithoutAttributes:statusFile];
-                
                 [statusContents writeToFile:statusFile atomically:TRUE encoding:NSASCIIStringEncoding error:nil];
-                
             }
-            
-            
         }
-        
-        
     }];
     
     //finally actually install the package onto the bootstrap
     
     DLog(@"Extracting package onto bootstrap folder...\n");
-    
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, bootstrapPath]];
-    
     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%@ Contents:\n\n---------------------\n\n%@\n\n---------------------\n\n", postInstFile, [NSString stringWithContentsOfFile:postInstFile encoding:NSASCIIStringEncoding error:nil]);
-        
-        
     }
-    
     [FM removeItemAtPath:tmpPath error:nil];
-    
     DLog(@"Done!\n\n");
     return 0;
-    
-    
 }
 
 - (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]);
 }
 
@@ -247,15 +215,13 @@
         DLog(@"skipping symbolic link: %@", file);
         return;
     }
-    NSFileManager *man = [NSFileManager defaultManager];
     NSString *fat = [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -info %@",file]];
     if ([fat containsString:@"Architectures"]){
         NSString *newFile = [file stringByAppendingPathExtension:@"thin"];
         [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];
         if (uni == 1){
@@ -268,47 +234,33 @@
     }
 }
 
+//FIXME: change to ldid
 - (void)codesignRetainingSignature:(NSString *)file {
-    
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     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]];
         NSString *ents = [HelperClass singleLineReturnForProcess:@"/bin/cat /tmp/ent.plist"];
         DLog(@"ents: %@", ents);
         NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --ent /tmp/ent.plist --inplace", jtp, file];
-        
         DLog(@"running codesign command: %@", runCommand);
-        
         NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
-        
         DLog(@"returnValue: %@", returnValue);
-        
     }
 }
 
 - (void)codesignIfNecessary:(NSString *)file {
-    
     if (![[[file pathExtension] lowercaseString] isEqualToString:@"dylib"]){
         return;
     }
-    
     NSString *jtp = [HelperClass singleLineReturnForProcess:@"/usr/bin/which jtool"];
     if (jtp){
-        
         NSString *proc = [[HelperClass arrayReturnForTask:jtp withArguments:@[@"--sig", file]] componentsJoinedByString:@"\n"];
-        
         NSLog(@"proc: %@", proc);
-        
         if ([proc containsString:@"No Code Signing blob detected in this file"]){
-            
             NSString *runCommand = [NSString stringWithFormat:@"%@ --sign platform %@ --inplace", jtp, file];
-            
             NSLog(@"running codesign command: %@", runCommand);
-            
             NSString *returnValue = [HelperClass singleLineReturnForProcess:runCommand];
-            
             NSLog(@"returnValue: %@", returnValue);
         }
     }
@@ -356,10 +308,7 @@
     [FM createDirectoryAtPath:debian withIntermediateDirectories:TRUE attributes:nil error:nil];
     DLog(@"\nExtracting DEBIAN files for processing...\n");
     [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -e %@ %@", self.path, debian]];
-    
-    
     NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
-    
     NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
     //@"appletvos-arm64"
     [controlFile replaceOccurrencesOfString:self.version withString:[self.version nextVersionNumber] options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
@@ -376,12 +325,9 @@
     
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
-            
             //DLog(@"processing path: %@", obj.path);
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
-                
                 NSString *badPath = [tmpPath stringByAppendingPathComponent:obj.path];
                 NSString *newPath = [tmpPath stringByAppendingPathComponent:@"Applications"];
                 DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
@@ -391,12 +337,9 @@
             }
             
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
-            
             if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
-                
                 DLog(@"in ignore file list, purge");
                 [FM removeItemAtPath:fullPath error:nil];
-                
             }
             
             if (self.appendedPrefix.length > 0 && [obj.path properPathComponents].count == 1) {
@@ -444,9 +387,7 @@
     NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
     DLog(@"\nProcessing file: %@\n", self.path);
     InputPackage *output = self;
-    
     DLog(@"\nFound package: '%@' at version: '%@'...\n", output.packageName, output.version );
-    
     NSString *tmpPath = [pwd stringByAppendingPathComponent:output.packageName];
     NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
     NSString *newRoot = nil;
@@ -463,25 +404,17 @@
     [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){
@@ -490,35 +423,23 @@
                             markedForDeath = idx;
                         }
                         *stop = TRUE;
-                        
                     }
-                    
                 }];
-                
                 if (markedForDeath != NSNotFound){
-                    
                     [lines removeObjectAtIndex:markedForDeath];
                     NSString *newString = [lines componentsJoinedByString:@"\n"];
                     [newString writeToFile:postinst atomically:TRUE];
 #pragma clang diagnostic pop
                 }
-                
             }
         }
-        
-        
     }
-    
     if (newArch != nil) {
-        
         NSString *controlPath = [debian stringByAppendingPathComponent:@"control"];
         NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:controlPath encoding:NSASCIIStringEncoding error:nil];
         //@"appletvos-arm64"
-        
         //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:@"darwin-arm64" withString:newArch options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
         
 #pragma clang diagnostic push
@@ -528,15 +449,12 @@
     }
     
     //at this point we have the files extracted, time to determine what needs to be changed
-    
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
     [self flattenInPath:tmpPath];
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if (obj.type == BSPackageFileTypeFile || obj.type == BSPackageFileTypeDirectory){
-            
             //DLog(@"processing path: %@", obj.path);
             if ([obj.path isEqualToString:@"/private/var/mobile/Applications/"]){
                 
@@ -547,34 +465,26 @@
                 [FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
                 *stop = TRUE;
             }
-            
             NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
-            
-            if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
-                
+            if ([ignoreFiles containsObject:obj.path.lastPathComponent]) {
                 DLog(@"in ignore file list, purge");
                 [FM removeItemAtPath:fullPath error:nil];
-                
             }
             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);
                     [moveRoot addObject:obj.path];
                 }
             }
             NSArray *pathComponents = [obj.path pathComponents];
-            if ([pathComponents count] > 1)
-            {
-                
+            if ([pathComponents count] > 1) {
                 NSString *rootPath = [pathComponents objectAtIndex:1];
                 //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);
                     NSString *privateDir = [tmpPath stringByAppendingPathComponent:@"private"];
-                    if (![FM fileExistsAtPath:privateDir]){
+                    if (![FM fileExistsAtPath:privateDir]) {
                         [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]
                     NSString *badPath = [tmpPath stringByAppendingPathComponent:rootPath];
@@ -592,67 +502,42 @@
         [FM moveItemAtPath:oldPath toPath:newPath error:nil];
     }];
     NSString *depArchiveInfo = [NSString stringWithFormat:@"/usr/local/bin/dpkg -b %@", self.packageName];
-    
     if (fakeRoot) {
-        
         depArchiveInfo = [NSString stringWithFormat:@"%@ /usr/local/bin/dpkg -b %@", fakeRoot, self.packageName];
-        
-        
     }
-    
     [[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
-    
-    
-    
     DLog(@"\nDone!\n\n");
-    
-    //return er;
 }
 
-- (ErrorReturn *)errorReturnForBootstrap:(NSString *)bootstrapPath
-{
+- (ErrorReturn *)errorReturnForBootstrap:(NSString *)bootstrapPath {
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     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 NSMutableArray *_overwriteArray = [NSMutableArray new];
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         if ([obj.fileType isEqualToString:@"file"]){
-            
             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);
                 [_overwriteArray addObject:obj.path];
                 //*stop = TRUE;//return FALSE;
                 returnValue = 1;
             }
-            
             NSArray *pathComponents = [obj.path pathComponents];
-            if ([pathComponents count] > 1)
-            {
+            if ([pathComponents count] > 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);
                     *stop = TRUE;
                     returnValue = 2;
                 }
             }
-            
-            
         }
-        
-        
     }];
-    
     ErrorReturn *er = [ErrorReturn new];
     er.returnStatus = returnValue;
     er.overwriteFiles = _overwriteArray;
-    
     return er;
 }
 
-
 @end

+ 0 - 10
bootstrapTool/Classes/InputPackageFile.m

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

+ 7 - 112
bootstrapTool/main.m

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