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. --- .gitignore | 1 + makefile | 9 ++++++--- postinst.mm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 postinst.mm 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 +#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