|
@@ -6,6 +6,38 @@
|
|
|
|
|
|
@implementation InputPackage
|
|
@implementation InputPackage
|
|
|
|
|
|
|
|
++ (InputPackage *)packageForDeb:(NSString *)debFile {
|
|
|
|
+ return [self packageForDeb:debFile excludes:nil];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
++ (InputPackage *)packageForDeb:(NSString *)debFile excludes:(NSString *)excludesFile {
|
|
|
|
+
|
|
|
|
+ NSString *dpkg = [@"dpkg" runPathForSearchPath];
|
|
|
|
+ NSString *packageName = [HelperClass singleLineReturnForProcess:@"%@ -f %@ Package",dpkg, debFile];
|
|
|
|
+ NSString *packageVersion = [HelperClass singleLineReturnForProcess:@"%@ -f %@ Version", dpkg, debFile];
|
|
|
|
+ NSArray <InputPackageFile *> *fileList = [HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -c %@", dpkg, debFile]];
|
|
|
|
+
|
|
|
|
+ __block NSMutableArray *finalArray = [NSMutableArray new];
|
|
|
|
+
|
|
|
|
+ [fileList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ InputPackageFile *file = [HelperClass packageFileFromLine:obj];
|
|
|
|
+ if (file) {
|
|
|
|
+ //DLog(@"%@", file);
|
|
|
|
+ [finalArray addObject:file];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+ InputPackage *pkg = [InputPackage new];
|
|
|
|
+ pkg.excludeFile = excludesFile;
|
|
|
|
+ pkg.files = finalArray;
|
|
|
|
+ pkg.path = debFile;
|
|
|
|
+ pkg.packageName = packageName;
|
|
|
|
+ pkg.version = packageVersion;
|
|
|
|
+ pkg.validLDIDPath = [HelperClass validLDIDPath];
|
|
|
|
+ return pkg;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
- (NSString*) description {
|
|
- (NSString*) description {
|
|
|
|
|
|
NSString *orig = [super description];
|
|
NSString *orig = [super description];
|
|
@@ -56,7 +88,6 @@
|
|
[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:@"./"]) {
|
|
invalidCount++;
|
|
invalidCount++;
|
|
if (invalidCount > 1){
|
|
if (invalidCount > 1){
|
|
@@ -82,10 +113,29 @@
|
|
[_mutableList removeObject:@"/"];
|
|
[_mutableList removeObject:@"/"];
|
|
fileList = [_mutableList copy];
|
|
fileList = [_mutableList copy];
|
|
}
|
|
}
|
|
|
|
+ NSArray *excludeArray = [self.excludeFile excludeArrayFromFile];
|
|
|
|
+ if (excludeArray) {
|
|
|
|
+ __block NSMutableArray *filesToRemove = [NSMutableArray new];
|
|
|
|
+ [excludeArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ if ([obj length] > 0){
|
|
|
|
+ NSArray *items = [fileList filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF LIKE[c] %@", obj]];
|
|
|
|
+ if (items.count > 0) {
|
|
|
|
+ //DLog(@"found items to remove: %@", items);
|
|
|
|
+ [filesToRemove addObjectsFromArray:items];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ //DLog(@"\nShould remove the following: %@", filesToRemove);
|
|
|
|
+ self.excludedFiles = filesToRemove;
|
|
|
|
+ NSMutableArray *_mutableList = [fileList mutableCopy];
|
|
|
|
+ [_mutableList removeObjectsInArray:filesToRemove];
|
|
|
|
+ fileList = [_mutableList copy];
|
|
|
|
+ }
|
|
return fileList;
|
|
return fileList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
- (int)installToBootstrapPath:(NSString *)bootstrapPath {
|
|
- (int)installToBootstrapPath:(NSString *)bootstrapPath {
|
|
|
|
|
|
DLog(@"\nFound package: '%@' at version: '%@'...\n", self.packageName, self.version );
|
|
DLog(@"\nFound package: '%@' at version: '%@'...\n", self.packageName, self.version );
|
|
@@ -161,7 +211,7 @@
|
|
NSString *listFile = [bootstrapPath.relativeInfoFolderPath stringByAppendingPathComponent:baseFile];
|
|
NSString *listFile = [bootstrapPath.relativeInfoFolderPath stringByAppendingPathComponent:baseFile];
|
|
NSString *listOutput = [fileList componentsJoinedByString:@"\n"];
|
|
NSString *listOutput = [fileList componentsJoinedByString:@"\n"];
|
|
DLog(@"\nCreating list file '%@'...\n", listFile);
|
|
DLog(@"\nCreating list file '%@'...\n", listFile);
|
|
- DLog(@"list: %@", listOutput);
|
|
|
|
|
|
+ //DLog(@"list: %@", listOutput);
|
|
[[listOutput stringByAppendingString:@"\n"] writeToFile:listFile atomically:TRUE encoding:NSUTF8StringEncoding error:nil];
|
|
[[listOutput stringByAppendingString:@"\n"] writeToFile:listFile atomically:TRUE encoding:NSUTF8StringEncoding error:nil];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -265,8 +315,25 @@
|
|
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]);
|
|
}
|
|
}
|
|
|
|
+ NSArray *excludeArray = self.excludedFiles;//[self.excludeFile excludeArrayFromFile];
|
|
|
|
+ if (excludeArray) {
|
|
|
|
+ DLog(@"\nRemoving excluded files...\n\n");
|
|
|
|
+ [excludeArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ if ([obj length] > 0){
|
|
|
|
+ NSString *filePath = [bootstrapPath stringByAppendingPathComponent:obj];
|
|
|
|
+ if ([FM fileExistsAtPath:filePath]) {
|
|
|
|
+ NSString *commandToRun = [NSString stringWithFormat:@"/bin/rm -r %@", filePath];
|
|
|
|
+ DLog(@"%@", commandToRun);
|
|
|
|
+ [HelperClass singleLineReturnForProcess:commandToRun];
|
|
|
|
+ } else {
|
|
|
|
+ DLog(@"file doesn't exist at %@", filePath);
|
|
|
|
+ }
|
|
|
|
+ //DLog(@"returned: %@", deets);
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
[FM removeItemAtPath:tmpPath error:nil];
|
|
[FM removeItemAtPath:tmpPath error:nil];
|
|
- DLog(@"Done!\n\n");
|
|
|
|
|
|
+ DLog(@"\nDone!\n\n");
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -396,6 +463,17 @@
|
|
[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:@"%@ -e %@ %@",dpkg, self.path, debian]];
|
|
[HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -e %@ %@",dpkg, self.path, debian]];
|
|
|
|
+ NSArray *excludeArray = [self.excludeFile excludeArrayFromFile];
|
|
|
|
+ if (excludeArray) {
|
|
|
|
+ [excludeArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ if ([obj length] > 0){
|
|
|
|
+ NSString *commandToRun = [NSString stringWithFormat:@"/bin/rm %@/%@", tmpPath, obj];
|
|
|
|
+ //DLog(@"%@", commandToRun);
|
|
|
|
+ NSString *deets = [HelperClass singleLineReturnForProcess:commandToRun];
|
|
|
|
+ DLog(@"returned: %@", deets);
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
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"
|
|
@@ -486,6 +564,10 @@
|
|
DLog(@"\nDone!\n\n");
|
|
DLog(@"\nDone!\n\n");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (NSString *)excludeContents {
|
|
|
|
+ return @"path-exclude=*/share/info/*\npath-exclude=*/share/doc/*\npath-exclude=*/share/man/*";
|
|
|
|
+}
|
|
|
|
+
|
|
- (void)repackageInCurrentDirectoryWithArch:(NSString *)newArch {
|
|
- (void)repackageInCurrentDirectoryWithArch:(NSString *)newArch {
|
|
|
|
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
NSString *fakeRoot = [HelperClass singleLineReturnForProcess:@"/usr/bin/which fakeroot"];
|
|
@@ -508,7 +590,19 @@
|
|
[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:@"%@ -e %@ %@", dpkg, self.path, debian]];
|
|
[HelperClass returnForProcess:[NSString stringWithFormat:@"%@ -e %@ %@", dpkg, self.path, debian]];
|
|
-
|
|
|
|
|
|
+ NSArray *excludeArray = [self.excludeFile excludeArrayFromFile];
|
|
|
|
+ if (excludeArray) {
|
|
|
|
+ DLog(@"excludeARray: %@", excludeArray);
|
|
|
|
+ [excludeArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
+ if ([obj length] > 0){
|
|
|
|
+ NSString *commandToRun = [NSString stringWithFormat:@"/bin/rm %@/%@", tmpPath, obj];
|
|
|
|
+ //DLog(@"%@", commandToRun);
|
|
|
|
+ NSString *deets = [HelperClass singleLineReturnForProcess:commandToRun];
|
|
|
|
+ DLog(@"returned: %@", deets);
|
|
|
|
+ }
|
|
|
|
+ //[HelperClass returnForProcess:[NSString stringWithFormat:@"/bin/rm %@/%@", tmpPath, obj]];
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
//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);
|