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