From eaa9f1224cce97bf2568e914b7f3e7efe3dc5505 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 12 Mar 2011 15:17:58 -0800 Subject: Add a postinst to update cydia.list. --- postinst.mm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 postinst.mm (limited to 'postinst.mm') diff --git a/postinst.mm b/postinst.mm new file mode 100644 index 0000000..f55db81 --- /dev/null +++ b/postinst.mm @@ -0,0 +1,53 @@ +#include +#include + +#include +#include +#include "CyteKit/PerlCompatibleRegEx.hpp" + +_H Sources_; +_H CydiaSource_; +bool Changed_; + +_H Firmware_; + +int main(int argc, const char *argv[]) { + if (argc < 2 || strcmp(argv[1], "configure") != 0) + return 0; + + NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); + + Pcre pattern("^([0-9]+\\.[0-9]+)"); + + if (pattern([[UIDevice currentDevice] systemVersion])) + Firmware_ = pattern[1]; + + NSDictionary *metadata([[[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"] autorelease]); + NSUInteger version(0); + + if (metadata != nil) { + Sources_ = [metadata objectForKey:@"Sources"]; + CydiaSource_ = [metadata objectForKey:@"CydiaSource"]; + + if (NSNumber *number = [metadata objectForKey:@"Version"]) + version = [number unsignedIntValue]; + } + + if (CydiaSource_ == nil) + CydiaSource_ = @"apt.saurik.com"; + + if (Sources_ == nil) + Sources_ = [NSMutableDictionary dictionaryWithCapacity:8]; + + if (version == 0) { + CydiaAddSource(@"http://apt.thebigboss.org/repofiles/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); + CydiaAddSource(@"http://apt.modmyi.com/", @"stable", [NSMutableArray arrayWithObject:@"main"]); + CydiaAddSource(@"http://cydia.zodttd.com/repo/cydia/", @"stable", [NSMutableArray arrayWithObject:@"main"]); + CydiaAddSource(@"http://repo666.ultrasn0w.com/", @"./"); + } + + CydiaWriteSources(); + + [pool release]; + return 0; +} -- cgit v1.2.3