summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--makefile9
-rw-r--r--postinst.mm53
3 files changed, 60 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index c880fb8..5b341bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
sysroot
MobileCydia
CydiaAppliance
+postinst
_
__
Cydia.deb
diff --git a/makefile b/makefile
index 6ab3a0d..7070db9 100644
--- 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
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;
+}