]> git.saurik.com Git - cydia.git/commitdiff
Add a postinst to update cydia.list.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 12 Mar 2011 23:17:58 +0000 (15:17 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 14 Mar 2011 12:09:08 +0000 (05:09 -0700)
.gitignore
makefile
postinst.mm [new file with mode: 0644]

index c880fb887615298c0fe3907a938456d423e58752..5b341bd0ea2e870fc56067f475437b8170c38377 100644 (file)
@@ -1,6 +1,7 @@
 sysroot
 MobileCydia
 CydiaAppliance
+postinst
 _
 __
 Cydia.deb
index 6ab3a0d24496fbf9f87498744652023f13f2aacc..7070db9562aa806b91da957d894ea5a097a10b4f 100644 (file)
--- a/makefile
+++ b/makefile
@@ -88,7 +88,7 @@ lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
 all: MobileCydia
 
 clean:
-       rm -f MobileCydia
+       rm -f MobileCydia postinst
        rm -rf Objects/ Images/
 
 Objects/%.o: %.c $(header)
@@ -129,7 +129,10 @@ MobileCydia: sysroot $(object)
 CydiaAppliance: CydiaAppliance.mm
        $(cycc) $(filter %.mm,$^) $(flags) -bundle $(link) $(backrow)
 
-debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst $(images) $(shell find MobileCydia.app) cydia.control
+postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
+       $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre
+
+debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst $(images) $(shell find MobileCydia.app) cydia.control
        sudo rm -rf _
        mkdir -p _/var/lib/cydia
        
@@ -164,7 +167,7 @@ debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst $(images) $(shell fi
        
        mkdir -p _/DEBIAN
        ./control.sh cydia.control _ >_/DEBIAN/control
-       cp -a preinst _/DEBIAN/
+       cp -a preinst postinst _/DEBIAN/
        
        find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
        
diff --git a/postinst.mm b/postinst.mm
new file mode 100644 (file)
index 0000000..f55db81
--- /dev/null
@@ -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;
+}