Browse Source

bumping packages will give a more appropriate package name, still want to do the same for repackage but need to add smarts for overwriting

Kevin Bradley 7 months ago
parent
commit
b54804c3de

+ 1 - 1
bootstrapTool/Classes/HelperClass.h

@@ -14,7 +14,7 @@
 + (void)runProcess:(NSString *)call environment:(NSDictionary *)env currentPath:(NSString *)currentPath completion:(void(^)(NSString *output, NSInteger returnStatus))block;
 + (int)runCommand:(NSString *)call environment:(NSDictionary *)env currentPath:(NSString *)currentPath verbose:(BOOL)verbose;
 + (NSString *)validLDIDPath;
-+ (int)bumpPackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip;
++ (int)bumpPackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip excludeFile:(NSString *)excludeFile;
 + (int)repackagePackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip arch:(NSString *)arch excludeFile:(NSString *)excludeFile;
 + (int)cleanBootstrapAtPath:(NSString *)bootstrapPath;
 + (int)deletePackage:(NSString *)deletePackage inBootstrap:(NSString *)bootstrapPath;

+ 3 - 3
bootstrapTool/Classes/HelperClass.m

@@ -173,7 +173,7 @@
 
 + (int)repackagePackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip arch:(NSString *)arch excludeFile:(NSString *)excludeFile {
     DLog(@"\n [INFO] Repackaging file: %@...\n", debFile);
-    InputPackage *output = [HelperClass packageForDeb:debFile];
+    InputPackage *output = [InputPackage packageForDeb:debFile excludes:excludeFile];
     output.appendedPrefix = prefix;
     output.skipSignatureChecks = skip;
     output.excludeFile = excludeFile;
@@ -184,9 +184,9 @@
     return 0;
 }
 
-+ (int)bumpPackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip {
++ (int)bumpPackageAtPath:(NSString *)debFile withPrefix:(NSString *)prefix sigChecks:(BOOL)skip excludeFile:(NSString *)excludeFile {
     DLog(@"\n [INFO] Bumping version number for file: %@...\n", debFile);
-    InputPackage *output = [HelperClass packageForDeb:debFile];
+    InputPackage *output = [InputPackage packageForDeb:debFile excludes:excludeFile];
     output.appendedPrefix = prefix;
     output.skipSignatureChecks = skip;
     [output bumpVersionInCurrentDirectory];

+ 2 - 0
bootstrapTool/Classes/InputPackage.h

@@ -11,6 +11,7 @@
 @property (nonatomic, strong) NSArray  *controlFiles;
 @property (nonatomic, strong) NSString *packageName;
 @property (nonatomic, strong) NSString *version;
+@property (nonatomic, strong) NSString *architecture;
 @property (nonatomic, strong) NSString *path;
 @property (nonatomic, strong) NSString *appendedPrefix;
 @property (readwrite, assign) BOOL skipSignatureChecks;
@@ -27,5 +28,6 @@
 - (ErrorReturn *)errorReturnForBootstrap:(NSString *)bootstrapPath;
 - (NSString *)listfile;
 - (NSArray *)rootPaths;
++ (InputPackage *)packageForDeb:(NSString *)debFile;
 + (InputPackage *)packageForDeb:(NSString *)debFile excludes:(NSString *)excludesFile;
 @end

+ 17 - 9
bootstrapTool/Classes/InputPackage.m

@@ -15,6 +15,7 @@
     NSString *dpkg = [@"dpkg" runPathForSearchPath];
     NSString *packageName = [HelperClass singleLineReturnForProcess:@"%@ -f %@ Package",dpkg, debFile];
     NSString *packageVersion = [HelperClass singleLineReturnForProcess:@"%@ -f %@ Version", dpkg, debFile];
+    NSString *architecture = [HelperClass singleLineReturnForProcess:@"%@ -f %@ Architecture", dpkg, debFile];
     NSArray <InputPackageFile *> *fileList = [HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -c %@", dpkg, debFile]];
     
     __block NSMutableArray *finalArray = [NSMutableArray new];
@@ -33,6 +34,7 @@
     pkg.path = debFile;
     pkg.packageName = packageName;
     pkg.version = packageVersion;
+    pkg.architecture = architecture;
     pkg.validLDIDPath = [HelperClass validLDIDPath];
     return pkg;
     
@@ -134,7 +136,9 @@
     return fileList;
 }
 
-
+- (NSString *)fullPackageName {
+    return [NSString stringWithFormat:@"%@_%@_%@.deb", self.packageName, self.version, self.architecture];
+}
 
 - (int)installToBootstrapPath:(NSString *)bootstrapPath {
     
@@ -347,6 +351,9 @@
         //DLog(@"skipping file: %@", file);
         return;
     }
+    if (![FM fileExistsAtPath:file]){
+        return;
+    }
     DLog(@"processing file: %@", file);
     NSString *fat = [HelperClass singleLineReturnForProcess:@"/usr/bin/lipo -info %@",file];
     if ([fat containsString:@"Architectures"]){
@@ -385,8 +392,8 @@
 - (BOOL)shouldCodesignFile:(NSString *)file {
     NSArray *codesignPrefixes = @[@"py", @"so", @"dylib", @"appex"];
     BOOL isDir = false;
-    [FM fileExistsAtPath:file isDirectory:&isDir];
-    if (isDir) return false;
+    BOOL exists = [FM fileExistsAtPath:file isDirectory:&isDir];
+    if (isDir || !exists) return false;
     return ([FM isExecutableFileAtPath:file] || [codesignPrefixes containsObject:[[file pathExtension] lowercaseString]]);
 }
 
@@ -477,12 +484,13 @@
     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])];
+    NSString *nextVersionNumber = [self.version nextVersionNumber];
+    [controlFile replaceOccurrencesOfString:self.version withString:nextVersionNumber options:NSLiteralSearch range:NSMakeRange(0, [controlFile length])];
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
     [controlFile writeToFile:controlPath atomically:TRUE];
-    
-    [self sanitizeScriptsIfNecessary:debian];
+    self.version = nextVersionNumber;
+    //[self sanitizeScriptsIfNecessary:debian];
 
     //at this point we have the files extracted, time to determine what needs to be changed
     
@@ -556,9 +564,9 @@
         DLog(@"[INFO] moving %@ to %@", oldPath, newPath);
         [FM moveItemAtPath:oldPath toPath:newPath error:nil];
     }];
-    NSString *depArchiveInfo = [NSString stringWithFormat:@"%@ -b %@", dpkg, self.packageName];
+    NSString *depArchiveInfo = [NSString stringWithFormat:@"%@ -b %@ %@", dpkg, self.packageName, [self fullPackageName]];
     if (fakeRoot) {
-        depArchiveInfo = [NSString stringWithFormat:@"%@ %@ -b %@", fakeRoot, dpkg, self.packageName];
+        depArchiveInfo = [NSString stringWithFormat:@"%@ %@ -b %@ %@", fakeRoot, dpkg, self.packageName, [self fullPackageName]];
     }
     [[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
     DLog(@"\nDone!\n\n");
@@ -653,7 +661,7 @@
         [controlFile writeToFile:controlPath atomically:TRUE];
 #pragma clang diagnostic pop
     }
-    [self sanitizeScriptsIfNecessary:debian];
+    //[self sanitizeScriptsIfNecessary:debian];
     //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"];

+ 1 - 1
bootstrapTool/main.m

@@ -195,7 +195,7 @@ int main(int argc, char **argv) {
                 return -1;
             }
             DLog(@"skip signature checks: %d", skip);
-            return [HelperClass bumpPackageAtPath:debFile withPrefix:prefix sigChecks:skip];
+            return [HelperClass bumpPackageAtPath:debFile withPrefix:prefix sigChecks:skip excludeFile:excludeFile];
         }
         
         if (repackage == TRUE && debFile) {