]> git.saurik.com Git - cydia.git/blob - postinst.mm
Use System_, not Firmware_, for APT repository.
[cydia.git] / postinst.mm
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 #include "CyteKit/PerlCompatibleRegEx.hpp"
9
10 _H<NSMutableDictionary> Sources_;
11 _H<NSString> CydiaSource_;
12 bool Changed_;
13
14 _H<NSString> System_;
15
16 int main(int argc, const char *argv[]) {
17 if (argc < 2 || strcmp(argv[1], "configure") != 0)
18 return 0;
19
20 NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
21
22 size_t size;
23 sysctlbyname("kern.osversion", NULL, &size, NULL, 0);
24 char *osversion = new char[size];
25 if (sysctlbyname("kern.osversion", osversion, &size, NULL, 0) != -1)
26 System_ = [NSString stringWithUTF8String:osversion];
27
28 NSDictionary *metadata([[[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"] autorelease]);
29 NSUInteger version(0);
30
31 if (metadata != nil) {
32 Sources_ = [metadata objectForKey:@"Sources"];
33 CydiaSource_ = [metadata objectForKey:@"CydiaSource"];
34
35 if (NSNumber *number = [metadata objectForKey:@"Version"])
36 version = [number unsignedIntValue];
37 }
38
39 if (CydiaSource_ == nil)
40 CydiaSource_ = @"apt.saurik.com";
41
42 if (Sources_ == nil)
43 Sources_ = [NSMutableDictionary dictionaryWithCapacity:8];
44
45 if (version == 0) {
46 CydiaAddSource(@"http://apt.thebigboss.org/repofiles/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]);
47 CydiaAddSource(@"http://apt.modmyi.com/", @"stable", [NSMutableArray arrayWithObject:@"main"]);
48 CydiaAddSource(@"http://cydia.zodttd.com/repo/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]);
49 CydiaAddSource(@"http://repo666.ultrasn0w.com/", @"./");
50 }
51
52 CydiaWriteSources();
53
54 [pool release];
55 return 0;
56 }