Browse Source

should finally work properly to repackage and bump versions for rootless packages

Kevin Bradley 11 months ago
parent
commit
5a5302be39
2 changed files with 17 additions and 14 deletions
  1. 5 7
      bootstrapTool/Classes/HelperClass.m
  2. 12 7
      bootstrapTool/Classes/InputPackage.m

+ 5 - 7
bootstrapTool/Classes/HelperClass.m

@@ -71,15 +71,14 @@
 }
 
 + (NSString *)singleLineReturnForProcess:(NSString *)format, ... {
-    DLog(@"singleLineReturnForProcess");
     if (format==nil)
         return nil;
     char line[200];
     va_list args;
     va_start(args, format);
-    va_end(args);
     NSString *newString = [[NSString alloc] initWithFormat:format arguments:args];
-    DLog(@"running process: %@", newString);
+    va_end(args);
+    //DLog(@"running process: %@", newString);
     FILE* fp = popen([newString UTF8String], "r");
     NSMutableString *lines = [[NSMutableString alloc]init];
     if (fp) {
@@ -87,7 +86,6 @@
             NSString *s = [NSString stringWithCString:line encoding:NSUTF8StringEncoding];
             s = [s stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
             [lines appendString:s];
-            //[lines addObject:s];
         }
     }
     pclose(fp);
@@ -98,7 +96,7 @@
     if (call==nil)
         return 0;
     char line[200];
-    DLog(@"\nRunning process: %@\n", call);
+    //DLog(@"\nRunning process: %@\n", call);
     FILE* fp = popen([call UTF8String], "r");
     NSMutableArray *lines = [[NSMutableArray alloc]init];
     if (fp) {
@@ -301,8 +299,8 @@
 
 + (InputPackage *)packageForDeb:(NSString *)debFile {
     
-    NSString *packageName = [self singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -f %@ Package", debFile]];
-    NSString *packageVersion = [self singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -f %@ Version", debFile]];
+    NSString *packageName = [self singleLineReturnForProcess:@"/usr/local/bin/dpkg -f %@ Package", debFile];
+    NSString *packageVersion = [self singleLineReturnForProcess:@"/usr/local/bin/dpkg -f %@ Version", debFile];
     NSArray <InputPackageFile *> *fileList = [self returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -c %@", debFile]];
     
     __block NSMutableArray *finalArray = [NSMutableArray new];

+ 12 - 7
bootstrapTool/Classes/InputPackage.m

@@ -227,7 +227,7 @@
         DLog(@"skipping symbolic link: %@", file);
         return;
     }
-    NSString *fat = [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"/usr/bin/lipo -info %@",file]];
+    NSString *fat = [HelperClass singleLineReturnForProcess:@"/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]];
@@ -250,8 +250,13 @@
     NSString *ldidPath = [self validLDIDPath];
     if (ldidPath) {
         [FM removeItemAtPath:@"/tmp/ent.plist" error:nil];
-        [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"%@ -e %@ > /tmp/ent.plist", ldidPath, file]];
-        [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"%@ -S/tmp/ent.plist %@", ldidPath, file]];
+        [HelperClass singleLineReturnForProcess:@"%@ -e %@ > /tmp/ent.plist", ldidPath, file];
+        NSString *fileCheck = [NSString stringWithContentsOfFile:@"/tmp/ent.plist" encoding:NSUTF8StringEncoding error:nil];
+        if (fileCheck.length == 0) {
+            [HelperClass singleLineReturnForProcess:@"%@ -S %@", ldidPath, file];
+        } else {
+            [HelperClass singleLineReturnForProcess:@"%@ -S/tmp/ent.plist %@", ldidPath, file];
+        }
     }
 }
 
@@ -273,7 +278,7 @@
     
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
         NSString *file = [thePath stringByAppendingPathComponent:obj.path];
-        DLog(@"check sig file: %@", obj.path);
+        //DLog(@"check sig file: %@", obj.path);
         [self flattenIfNecessary:file];
     }];
     
@@ -283,7 +288,7 @@
     if (self.skipSignatureChecks) { return; }
     [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
         NSString *file = [thePath stringByAppendingPathComponent:obj.path];
-        DLog(@"check sig file: %@", file);
+        //DLog(@"check sig file: %@", file);
         [self codesignIfNecessary:file];
     }];
     
@@ -305,7 +310,7 @@
                     fullString = [fullString stringByReplacingOccurrencesOfString:@"#!/bin/sh" withString:@""];
                     if (fullString.length > 0) {
                         [fullString writeToFile:fullPath atomically:TRUE encoding:NSUTF8StringEncoding error:nil];
-                        [HelperClass singleLineReturnForProcess:[NSString stringWithFormat:@"chmod +x %@", fullPath]];
+                        [HelperClass singleLineReturnForProcess:@"chmod +x %@", fullPath];
                     }
                 }
             }
@@ -349,7 +354,7 @@
     
     NSArray *ignoreFiles = @[@".fauxsu", @".DS_Store"];
     NSArray *forbiddenRoots = @[@"etc", @"var", @"tmp"];
-    
+    [self flattenInPath:tmpPath];
     [self validateSignaturesInPath:tmpPath];
     
     //__block NSMutableArray *_overwriteArray = [NSMutableArray new];