|
@@ -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
|