]>
Commit | Line | Data |
---|---|---|
eaa9f122 JF |
1 | #include <strings.h> |
2 | #include <Sources.h> | |
3 | ||
407564b5 JF |
4 | #include <sys/types.h> |
5 | #include <sys/sysctl.h> | |
6 | ||
eaa9f122 JF |
7 | #include <CydiaSubstrate/CydiaSubstrate.h> |
8 | #include "CyteKit/PerlCompatibleRegEx.hpp" | |
9 | ||
10 | _H<NSMutableDictionary> Sources_; | |
eaa9f122 JF |
11 | bool Changed_; |
12 | ||
407564b5 | 13 | _H<NSString> System_; |
eaa9f122 JF |
14 | |
15 | int main(int argc, const char *argv[]) { | |
16 | if (argc < 2 || strcmp(argv[1], "configure") != 0) | |
17 | return 0; | |
18 | ||
19 | NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); | |
20 | ||
407564b5 JF |
21 | size_t size; |
22 | sysctlbyname("kern.osversion", NULL, &size, NULL, 0); | |
23 | char *osversion = new char[size]; | |
24 | if (sysctlbyname("kern.osversion", osversion, &size, NULL, 0) != -1) | |
25 | System_ = [NSString stringWithUTF8String:osversion]; | |
eaa9f122 JF |
26 | |
27 | NSDictionary *metadata([[[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"] autorelease]); | |
28 | NSUInteger version(0); | |
29 | ||
30 | if (metadata != nil) { | |
31 | Sources_ = [metadata objectForKey:@"Sources"]; | |
eaa9f122 JF |
32 | |
33 | if (NSNumber *number = [metadata objectForKey:@"Version"]) | |
34 | version = [number unsignedIntValue]; | |
35 | } | |
36 | ||
eaa9f122 JF |
37 | if (Sources_ == nil) |
38 | Sources_ = [NSMutableDictionary dictionaryWithCapacity:8]; | |
39 | ||
40 | if (version == 0) { | |
41 | CydiaAddSource(@"http://apt.thebigboss.org/repofiles/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
42 | CydiaAddSource(@"http://apt.modmyi.com/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
43 | CydiaAddSource(@"http://cydia.zodttd.com/repo/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); | |
44 | CydiaAddSource(@"http://repo666.ultrasn0w.com/", @"./"); | |
45 | } | |
46 | ||
47 | CydiaWriteSources(); | |
48 | ||
49 | [pool release]; | |
50 | return 0; | |
51 | } |