summaryrefslogtreecommitdiff
path: root/postinst.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-12 15:17:58 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-14 05:09:08 -0700
commiteaa9f1224cce97bf2568e914b7f3e7efe3dc5505 (patch)
tree0df2f79de90dec12aa3b5f972065a01d1a455a0f /postinst.mm
parent25c1dafb7565aea86bec1f415896e4ad1431906b (diff)
Add a postinst to update cydia.list.
Diffstat (limited to 'postinst.mm')
-rw-r--r--postinst.mm53
1 files changed, 53 insertions, 0 deletions
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 <strings.h>
+#include <Sources.h>
+
+#include <UIKit/UIKit.h>
+#include <CydiaSubstrate/CydiaSubstrate.h>
+#include "CyteKit/PerlCompatibleRegEx.hpp"
+
+_H<NSMutableDictionary> Sources_;
+_H<NSString> CydiaSource_;
+bool Changed_;
+
+_H<NSString> 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;
+}