|
@@ -95,7 +95,7 @@
|
|
|
}
|
|
|
|
|
|
NSString *pwd = [[HelperClass returnForProcess:@"/bin/pwd"] componentsJoinedByString:@"\n"];
|
|
|
-
|
|
|
+
|
|
|
NSFileManager *man = [NSFileManager defaultManager];
|
|
|
NSString *tmpPath = [pwd stringByAppendingPathComponent:self.packageName];
|
|
|
NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
|
|
@@ -159,7 +159,7 @@
|
|
|
newPath = [newPath stringByAppendingPathComponent:fileName];
|
|
|
//DLog(@"newPath: %@", newPath);
|
|
|
[man copyItemAtPath:fullPath toPath:newPath error:nil];
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
NSMutableString *controlFile = [[NSMutableString alloc] initWithContentsOfFile:fullPath encoding:NSASCIIStringEncoding error:nil];
|
|
@@ -234,8 +234,156 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-- (void)repackageInCurrentDirectoryWithArch:(NSString *)newArch {
|
|
|
+- (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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+- (void)validateSignaturesInPath:(NSString *)thePath {
|
|
|
+
|
|
|
+ [self.files enumerateObjectsUsingBlock:^(InputPackageFile * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+
|
|
|
+ NSString *file = [thePath stringByAppendingPathComponent:obj.path];
|
|
|
+
|
|
|
+ NSLog(@"check sig file: %@", file);
|
|
|
+ [self codesignIfNecessary:file];
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)bumpVersionInCurrentDirectory {
|
|
|
+
|
|
|
+ NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
|
+ 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"];
|
|
|
+ [FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
|
|
|
+ DLog(@"\nExtracting package contents for processing...\n");
|
|
|
+ [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, tmpPath]];
|
|
|
+ [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])];
|
|
|
+
|
|
|
+ [controlFile writeToFile:controlPath atomically:TRUE];
|
|
|
+
|
|
|
+ //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 validateSignaturesInPath: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/"]){
|
|
|
+
|
|
|
+ NSString *badPath = [tmpPath stringByAppendingPathComponent:obj.path];
|
|
|
+ NSString *newPath = [tmpPath stringByAppendingPathComponent:@"Applications"];
|
|
|
+ DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
|
|
|
+ [FM moveItemAtPath:badPath toPath:newPath error:nil];
|
|
|
+ [FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
|
|
|
+ *stop = TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *fullPath = [tmpPath stringByAppendingPathComponent:obj.path];
|
|
|
+
|
|
|
+ if ([ignoreFiles containsObject:obj.path.lastPathComponent]){
|
|
|
+
|
|
|
+ DLog(@"in ignore file list, purge");
|
|
|
+ [FM removeItemAtPath:fullPath error:nil];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ NSArray *pathComponents = [obj.path pathComponents];
|
|
|
+ if ([pathComponents count] > 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ NSString *rootPath = [pathComponents objectAtIndex:1];
|
|
|
+ //DLog(@"\n Checking root path: %@ for file %@\n", rootPath, obj.path);
|
|
|
+ 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]){
|
|
|
+ [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];
|
|
|
+ NSString *newPath = [privateDir stringByAppendingPathComponent:rootPath];
|
|
|
+ DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
|
|
|
+ [FM moveItemAtPath:badPath 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;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)repackageInCurrentDirectoryWithArch:(NSString *)newArch {
|
|
|
+
|
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
|
NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
|
|
|
DLog(@"\nProcessing file: %@\n", self.path);
|
|
@@ -313,7 +461,7 @@
|
|
|
DLog(@"\n [INFO] Moving %@ to %@...", badPath, newPath);
|
|
|
[FM moveItemAtPath:badPath toPath:newPath error:nil];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|