|
@@ -16,7 +16,7 @@
|
|
|
#import <sys/utsname.h>
|
|
|
#import "HelperClass.h"
|
|
|
|
|
|
-#define OPTION_FLAGS "o:i:ld:hcrbp:s"
|
|
|
+#define OPTION_FLAGS "o:i:ld:hcrbp:su:"
|
|
|
|
|
|
char *progname;
|
|
|
char *path;
|
|
@@ -32,6 +32,7 @@ static struct option longopts[] = {
|
|
|
{ "bump", no_argument, NULL, 'b' },
|
|
|
{ "prefix", required_argument, NULL, 'p' },
|
|
|
{ "skip", no_argument, NULL, 's' },
|
|
|
+ { "unique", required_argument, NULL, 'u' },
|
|
|
{ NULL, 0, NULL, 0 }
|
|
|
};
|
|
|
|
|
@@ -106,6 +107,10 @@ int main(int argc, char **argv) {
|
|
|
case 's':
|
|
|
skip = TRUE;
|
|
|
break;
|
|
|
+
|
|
|
+ case 'u':
|
|
|
+ up = [NSString stringWithUTF8String:optarg];
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
|
cmd_help();
|
|
@@ -121,6 +126,16 @@ int main(int argc, char **argv) {
|
|
|
//return 0;
|
|
|
}
|
|
|
|
|
|
+ if (up) {
|
|
|
+ NSArray *contents = [FM contentsOfDirectoryAtPath:up error:nil];
|
|
|
+ NSString *newFile = [[up lastPathComponent] stringByAppendingPathExtension:@"plist"];
|
|
|
+ NSArray *unique = [contents uniquePackageNames];
|
|
|
+ [unique writeToFile:newFile atomically:true];
|
|
|
+
|
|
|
+ DLog(@"%@", unique);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (bump == TRUE && debFile) {
|
|
|
DLog(@"\n [INFO] Bumping version number for file: %@...\n", debFile);
|
|
|
InputPackage *output = [HelperClass packageForDeb:debFile];
|
|
@@ -141,7 +156,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
//DLog(@"folder: %@ project: %@", folder, project);
|
|
|
if (clean && bootstrapPath) {
|
|
|
- NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
|
|
|
+ NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
|
NSString *listContents = [NSString stringWithContentsOfFile:statusFile encoding:NSUTF8StringEncoding error:nil];
|
|
|
//clean up any errant spaces
|
|
|
listContents = [listContents stringByReplacingOccurrencesOfString:@"\n\n\n" withString:@"\n\n"];
|
|
@@ -152,7 +167,7 @@ int main(int argc, char **argv) {
|
|
|
#pragma clang diagnostic pop
|
|
|
DLog(@"\n [INFO] Cleaning status file: %@", statusFile);
|
|
|
|
|
|
- NSString *testStatusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
|
|
|
+ NSString *testStatusFile = [bootstrapPath relativeStatusFilePath];
|
|
|
NSArray <StatusPackageModel*> *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
|
|
|
__block NSMutableString *newStatusFile = [NSMutableString new];
|
|
|
__block NSMutableArray *alreadyAdded = [NSMutableArray new];
|
|
@@ -190,7 +205,7 @@ int main(int argc, char **argv) {
|
|
|
}
|
|
|
if (deletePackage && bootstrapPath) {
|
|
|
__block NSString *postRmFile = nil;
|
|
|
- NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
|
|
|
+ NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
|
NSArray <StatusPackageModel*> *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
|
|
|
StatusPackageModel *model = [[installedPackages filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"package == %@", deletePackage]] lastObject];
|
|
|
if (model) {
|
|
@@ -240,7 +255,7 @@ int main(int argc, char **argv) {
|
|
|
}];
|
|
|
|
|
|
//TODO: delete the files here!
|
|
|
- NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
|
|
|
+ NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
|
[FM copyItemAtPath:statusFile toPath:[statusFile stringByAppendingPathExtension:@"bak"] error:nil];
|
|
|
__block NSMutableString *newStatusFile = [NSMutableString new];
|
|
|
[installedPackages enumerateObjectsUsingBlock:^(StatusPackageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
@@ -276,8 +291,8 @@ int main(int argc, char **argv) {
|
|
|
return 0;
|
|
|
}
|
|
|
if (listPackage && bootstrapPath) {
|
|
|
+ NSString *statusFile = [bootstrapPath relativeStatusFilePath];
|
|
|
|
|
|
- NSString *statusFile = [bootstrapPath stringByAppendingPathComponent:@"Library/dpkg/status"];
|
|
|
NSArray *installedPackages = [HelperClass statusInstalledPackagesFromFile:statusFile];
|
|
|
DLog(@"%@", installedPackages);
|
|
|
return 0;
|