|
@@ -52,12 +52,17 @@
|
|
|
|
|
|
- (BOOL)validateFileList:(NSArray *)fileList {
|
|
- (BOOL)validateFileList:(NSArray *)fileList {
|
|
__block BOOL retv = true;
|
|
__block BOOL retv = true;
|
|
|
|
+ __block int invalidCount = 0; //make sure its greater than 1 before we bail...
|
|
[fileList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
[fileList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if ([obj length] > 1) {
|
|
if ([obj length] > 1) {
|
|
NSString *sub = [obj substringToIndex:2];
|
|
NSString *sub = [obj substringToIndex:2];
|
|
|
|
+ DLog(@"sub: %@", sub);
|
|
if ([sub isEqualToString:@"./"]) {
|
|
if ([sub isEqualToString:@"./"]) {
|
|
- *stop = true;
|
|
|
|
- retv = false;
|
|
|
|
|
|
+ invalidCount++;
|
|
|
|
+ if (invalidCount > 1){
|
|
|
|
+ *stop = true;
|
|
|
|
+ retv = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}];
|
|
}];
|
|
@@ -65,11 +70,12 @@
|
|
}
|
|
}
|
|
|
|
|
|
- (NSArray *)getFileListing {
|
|
- (NSArray *)getFileListing {
|
|
- NSString *listProcess = [NSString stringWithFormat:@"/usr/local/bin/dpkg-deb -c %@ | awk '{ print $6 }'" , self.path];
|
|
|
|
|
|
+ NSString *dpkgDeb = [@"dpkg-deb" runPathForSearchPath];
|
|
|
|
+ NSString *listProcess = [NSString stringWithFormat:@"%@ -c %@ | awk '{ print $6 }'" ,dpkgDeb, self.path];
|
|
NSArray *fileList = [HelperClass returnForProcess:listProcess];
|
|
NSArray *fileList = [HelperClass returnForProcess:listProcess];
|
|
BOOL validated = [self validateFileList:fileList];
|
|
BOOL validated = [self validateFileList:fileList];
|
|
if (!validated) {
|
|
if (!validated) {
|
|
- fileList = [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg-deb -c %@ | awk '{ print $6 }' | cut -c 2-" , self.path]];
|
|
|
|
|
|
+ fileList = [HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -c %@ | awk '{ print $6 }' | cut -c 2-" ,dpkgDeb, self.path]];
|
|
}
|
|
}
|
|
if ([fileList containsObject:@"/"]) {
|
|
if ([fileList containsObject:@"/"]) {
|
|
NSMutableArray *_mutableList = [fileList mutableCopy];
|
|
NSMutableArray *_mutableList = [fileList mutableCopy];
|
|
@@ -86,7 +92,7 @@
|
|
|
|
|
|
NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
NSArray *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
|
|
NSArray *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
|
|
-
|
|
|
|
|
|
+ NSString *dpkg = [@"dpkg" runPathForSearchPath];
|
|
//DLog(@"installedPackages: %@", installedPackages);
|
|
//DLog(@"installedPackages: %@", installedPackages);
|
|
|
|
|
|
|
|
|
|
@@ -144,7 +150,7 @@
|
|
NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
|
|
NSString *debian = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
|
|
[FM 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:@"%@ -x %@ %@", dpkg, self.path, tmpPath]];
|
|
|
|
|
|
NSArray *fileList = [self getFileListing];
|
|
NSArray *fileList = [self getFileListing];
|
|
|
|
|
|
@@ -195,7 +201,7 @@
|
|
|
|
|
|
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:@"%@ -e %@ %@", dpkg, self.path, debian]];
|
|
//NSString *nextPath = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
|
|
//NSString *nextPath = [tmpPath stringByAppendingPathComponent:@"DEBIAN"];
|
|
|
|
|
|
DLog(@"\nCopying any necessary DEBIAN files to new locations...\n\n");
|
|
DLog(@"\nCopying any necessary DEBIAN files to new locations...\n\n");
|
|
@@ -254,7 +260,7 @@
|
|
//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:@"%@ -x %@ %@",dpkg, 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]);
|
|
@@ -371,6 +377,7 @@
|
|
|
|
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
|
|
NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
|
|
|
|
+ NSString *dpkg = [@"dpkg" runPathForSearchPath];
|
|
DLog(@"\nProcessing file: %@\n", self.path);
|
|
DLog(@"\nProcessing file: %@\n", self.path);
|
|
InputPackage *output = self;
|
|
InputPackage *output = self;
|
|
NSMutableArray *moveRoot = [NSMutableArray new];
|
|
NSMutableArray *moveRoot = [NSMutableArray new];
|
|
@@ -385,10 +392,10 @@
|
|
}
|
|
}
|
|
[FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
|
|
[FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
|
|
DLog(@"\nExtracting package contents for processing...\n");
|
|
DLog(@"\nExtracting package contents for processing...\n");
|
|
- [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, tmpPath]];
|
|
|
|
|
|
+ [HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -x %@ %@",dpkg, self.path, tmpPath]];
|
|
[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:@"%@ -e %@ %@",dpkg, 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"
|
|
@@ -418,7 +425,22 @@
|
|
[FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
|
|
[FM removeItemAtPath:[tmpPath stringByAppendingPathComponent:@"private"] error:nil];
|
|
*stop = TRUE;
|
|
*stop = TRUE;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if ([[obj.path lastPathComponent] isEqualToString:@"Info.plist"]){
|
|
|
|
+ if ([[[[obj.path stringByDeletingLastPathComponent] lastPathComponent] pathExtension] isEqualToString:@"app"]){
|
|
|
|
+ DLog(@"Got an Info.plist inside an app: %@", obj.path);
|
|
|
|
+ NSString *plistFullPath = [tmpPath stringByAppendingPathComponent:obj.path];
|
|
|
|
+ NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfFile:plistFullPath];
|
|
|
|
+ //DLog(@"infoPlist: %@", infoPlist);
|
|
|
|
+ infoPlist[@"itemId"] = @(995367539);
|
|
|
|
+ //DLog(@"infoPlist updated: %@", infoPlist);
|
|
|
|
+ NSError *error = nil;
|
|
|
|
+ [FM removeItemAtPath:plistFullPath error:&error];
|
|
|
|
+ if (error){
|
|
|
|
+ DLog(@"error removing file: %@", plistFullPath);
|
|
|
|
+ }
|
|
|
|
+ [infoPlist writeToFile:plistFullPath atomically: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");
|
|
@@ -456,9 +478,9 @@
|
|
DLog(@"[INFO] moving %@ to %@", oldPath, newPath);
|
|
DLog(@"[INFO] moving %@ to %@", oldPath, newPath);
|
|
[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:@"%@ -b %@", dpkg, self.packageName];
|
|
if (fakeRoot) {
|
|
if (fakeRoot) {
|
|
- depArchiveInfo = [NSString stringWithFormat:@"%@ /usr/local/bin/dpkg -b %@", fakeRoot, self.packageName];
|
|
|
|
|
|
+ depArchiveInfo = [NSString stringWithFormat:@"%@ %@ -b %@", fakeRoot, dpkg, self.packageName];
|
|
}
|
|
}
|
|
[[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
|
|
[[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
|
|
DLog(@"\nDone!\n\n");
|
|
DLog(@"\nDone!\n\n");
|
|
@@ -468,6 +490,7 @@
|
|
|
|
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
|
|
NSString *pwd = [HelperClass singleLineReturnForProcess:@"/bin/pwd"];
|
|
|
|
+ NSString *dpkg = [@"dpkg" runPathForSearchPath];
|
|
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 );
|
|
@@ -481,10 +504,10 @@
|
|
}
|
|
}
|
|
[FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
|
|
[FM createDirectoryAtPath:tmpPath withIntermediateDirectories:TRUE attributes:nil error:nil];
|
|
DLog(@"\nExtracting package contents for processing...\n");
|
|
DLog(@"\nExtracting package contents for processing...\n");
|
|
- [HelperClass returnForProcess:[NSString stringWithFormat:@"/usr/local/bin/dpkg -x %@ %@", self.path, tmpPath]];
|
|
|
|
|
|
+ [HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -x %@ %@", dpkg, self.path, tmpPath]];
|
|
[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:@"%@ -e %@ %@", dpkg, 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"];
|
|
@@ -590,9 +613,9 @@
|
|
DLog(@"[INFO] moving %@ to %@", oldPath, newPath);
|
|
DLog(@"[INFO] moving %@ to %@", oldPath, newPath);
|
|
[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:@"%@ -b %@", dpkg, self.packageName];
|
|
if (fakeRoot) {
|
|
if (fakeRoot) {
|
|
- depArchiveInfo = [NSString stringWithFormat:@"%@ /usr/local/bin/dpkg -b %@", fakeRoot, self.packageName];
|
|
|
|
|
|
+ depArchiveInfo = [NSString stringWithFormat:@"%@ %@ -b %@", fakeRoot, dpkg, self.packageName];
|
|
}
|
|
}
|
|
[[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
|
|
[[HelperClass returnForProcess:depArchiveInfo] componentsJoinedByString:@"\n"];
|
|
DLog(@"\nDone!\n\n");
|
|
DLog(@"\nDone!\n\n");
|