forked from Randy-420/aptFix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.m
54 lines (44 loc) · 2.06 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#import <UIKit/UIKit.h>
#include "420.h"
static NSString *local(NSString *local, NSString *def){
NSString *path = @"/Library/Application Support/aptFix";
NSString *tPath;
NSArray *languages = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
NSArray *preferredLanguages = [NSLocale preferredLanguages];
for (NSString *preferredLanguage in preferredLanguages){
for (NSString *language in languages){
if ([preferredLanguage hasPrefix:[language stringByReplacingOccurrencesOfString:@".lproj" withString:@""]]){
tPath = [path stringByAppendingPathComponent:language];
if ([[NSFileManager defaultManager] fileExistsAtPath:tPath]){
path = tPath;
return [[NSBundle bundleWithPath:path] localizedStringForKey:local value:def table:@"aptFix"];
}
}
}
}
return def;//[[NSBundle bundleWithPath:path] localizedStringForKey:local value:def table:@"aptFix"];
}
id CC(NSString *CMD) {
return [NSString stringWithFormat:@"echo \"%@\" | gap",CMD];
}
int main(int argc, char *argv[]) {
_420Manager *fix = [[_420Manager alloc] init];
NSFileManager *fm = [[NSFileManager alloc] init];
NSString *runCode = @"whoami";
NSString *whoami = [fix RunCMDWithLog:runCode];
runCode = @"killall Cydia;killall apt apt-get;rm -rf /var/log/apt;mkdir /var/log/apt;rm -f /var/lib/apt/lists/lock;rm -f /var/lib/dpkg/lock-frontend;rm -f /var/cache/apt/archives/lock;rm -f /var/lib/dpkg/lock;dpkg --configure -a >/dev/null 2>&1";
if ([whoami isEqualToString:@"mobile\n"]){
if ([fm fileExistsAtPath:@"/usr/bin/gap"]){
runCode = [runCode stringByReplacingOccurrencesOfString:@"a >/dev/null 2>&1" withString:@"a"];
runCode = CC(runCode);
}else{
printf("\n\n%s\n\n", local(@"RUN_ROOT", @"Package Managers should now work").UTF8String);
exit(1);
}
} else {
runCode = [runCode stringByReplacingOccurrencesOfString:@";" withString:@" >/dev/null 2>&1;"];
}
[fix RunCMD:runCode WaitUntilExit:YES];
printf("%s ( ͡° ͜ʖ ͡°)\n%s!\n", local(@"DONE", @"Done").UTF8String, local(@"FINISH", @"Package Managers should now work").UTF8String);
return 0;
}