|
@@ -92,22 +92,63 @@
|
|
|
return lines;
|
|
|
}
|
|
|
|
|
|
++ (int)runCommand:(NSString *)call environment:(NSDictionary *)env currentPath:(NSString *)currentPath verbose:(BOOL)verbose {
|
|
|
+ if (call==nil)
|
|
|
+ return 0;
|
|
|
+ char line[200];
|
|
|
+ chdir([currentPath UTF8String]);
|
|
|
+ FILE* fp = popen([call UTF8String], "r");
|
|
|
+ //NSMutableArray *lines = [[NSMutableArray alloc]init];
|
|
|
+ if (fp) {
|
|
|
+ while (fgets(line, sizeof line, fp)) {
|
|
|
+ if (verbose) {
|
|
|
+ NSString *s = [NSString stringWithCString:line encoding:NSUTF8StringEncoding];
|
|
|
+ s = [s stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
+ DLog(@"%@",s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int returnCode = pclose(fp);
|
|
|
+ return returnCode;
|
|
|
+}
|
|
|
+
|
|
|
++ (void)runProcess:(NSString *)call environment:(NSDictionary *)env currentPath:(NSString *)currentPath completion:(void(^)(NSString *output, NSInteger returnStatus))block {
|
|
|
+
|
|
|
+ NSArray *args = [call componentsSeparatedByString:@" "];
|
|
|
+ NSString *taskBinary = args[0];
|
|
|
+ NSArray *taskArguments = [args subarrayWithRange:NSMakeRange(1, args.count-1)];
|
|
|
+ //DDLogInfo(@"%@ %@", taskBinary, [taskArguments componentsJoinedByString:@" "]);
|
|
|
+ NSTask *task = [[NSTask alloc] init];
|
|
|
+ NSPipe *pipe = [[NSPipe alloc] init];
|
|
|
+ NSFileHandle *handle = [pipe fileHandleForReading];
|
|
|
+ [task setLaunchPath:taskBinary];
|
|
|
+ [task setArguments:taskArguments];
|
|
|
+ [task setEnvironment:env];
|
|
|
+ [task setCurrentDirectoryPath:currentPath];
|
|
|
+ [task setStandardOutput:pipe];
|
|
|
+ [task setStandardError:pipe];
|
|
|
+ [task launch];
|
|
|
+ NSData *outData = nil;
|
|
|
+ NSString *temp = nil;
|
|
|
+ while((outData = [handle readDataToEndOfFile]) && [outData length]){
|
|
|
+ temp = [[NSString alloc] initWithData:outData encoding:NSASCIIStringEncoding];
|
|
|
+ DLog(@"%@", temp);
|
|
|
+ }
|
|
|
+ [handle closeFile];
|
|
|
+ [task waitUntilExit];
|
|
|
+ int termStatus = [task terminationStatus];
|
|
|
+ task = nil;
|
|
|
+ if (block){
|
|
|
+ block(temp, termStatus);
|
|
|
+ }
|
|
|
+}
|
|
|
+//-rw-r--r-- 1 root wheel 4197184 May 9 19:53 nitotv_3.4.3-63_appletvos-arm64.deb
|
|
|
+ (InputPackageFile *)packageFileFromLine:(NSString *)inputLine {
|
|
|
// "-rwxr-xr-x 0 root wheel 69424 Oct 22 03:56 ./Library/MobileSubstrate/DynamicLibraries/beigelist7.dylib\n",
|
|
|
|
|
|
//-rwxr-xr-x root/staff 10860 2011-02-02 03:55 ./Library/Frameworks/CydiaSubstrate.framework/Commands/cycc
|
|
|
NSArray *lineObjects = [inputLine spaceDelimitedArray];
|
|
|
- /*
|
|
|
- inputLine = [inputLine stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
- inputLine = [inputLine stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\t"]];
|
|
|
- NSMutableString *newString = [[NSMutableString alloc] initWithString:inputLine];
|
|
|
- [newString replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
|
|
|
- [newString replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
|
|
|
- [newString replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
|
|
|
- [newString replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
|
|
|
- [newString replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
|
|
|
- NSArray *lineObjects = [newString componentsSeparatedByString:@" "];
|
|
|
- */
|
|
|
+
|
|
|
//NSLog(@"lineObjects: %@", lineObjects);
|
|
|
/*
|
|
|
|
|
@@ -131,7 +172,10 @@
|
|
|
NSString *octalUG = [self octalFromGroupSymbols:userGroup];
|
|
|
NSString *fileName = [path lastPathComponent];
|
|
|
//NSString *fullPath = [NSString stringWithFormat:@"/%@", path];
|
|
|
- NSString *fullPath = [path substringFromIndex:1];
|
|
|
+ NSString *fullPath = path;
|
|
|
+ if ([path hasPrefix:@"."]){
|
|
|
+ fullPath = [path substringFromIndex:1];
|
|
|
+ }
|
|
|
|
|
|
InputPackageFile *pf = [InputPackageFile new];
|
|
|
[pf _setFileTypeFromRaw:fileTypeChar];
|
|
@@ -221,6 +265,19 @@
|
|
|
return [NSString stringWithFormat:@"%@:%@", octalUser, octalGroup];
|
|
|
}
|
|
|
|
|
|
++ (NSString *)validLDIDPath {
|
|
|
+ NSString *ldid = [[HelperClass arrayReturnForTask:@"/usr/bin/which" withArguments:@[@"ldid"]] firstObject];
|
|
|
+ if (ldid) {
|
|
|
+ //DLog(@"found ldid: %@", ldid);
|
|
|
+ NSString *ldidCommand = [NSString stringWithFormat:@"%@ -- 2>&1", ldid];
|
|
|
+ NSString *ldidTest = [HelperClass singleLineReturnForProcess:ldidCommand];
|
|
|
+ //DLog(@"ldidTest: %@", ldidTest);
|
|
|
+ if ([ldidTest containsString:@"Link Identity Editor"]) {
|
|
|
+ return ldid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
|
|
|
+ (InputPackage *)packageForDeb:(NSString *)debFile {
|
|
|
|
|
@@ -245,6 +302,7 @@
|
|
|
pkg.path = debFile;
|
|
|
pkg.packageName = packageName;
|
|
|
pkg.version = packageVersion;
|
|
|
+ pkg.validLDIDPath = [self validLDIDPath];
|
|
|
return pkg;
|
|
|
|
|
|
}
|