X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/5530e23458e832a9840ce6f0182f1ebdb7c9021b..af7a541a90f647596ccf1309d0d77925b8c5f742:/postinst.mm diff --git a/postinst.mm b/postinst.mm index b380d644..a204b81b 100644 --- a/postinst.mm +++ b/postinst.mm @@ -71,12 +71,11 @@ static bool MoveStash() { } static bool FixProtections() { - for (const char *path : (const char *[]) {"/var/lib", "/var/cache"}) { - mkdir(path, 0755); - if (!setnsfpn(path)) { - fprintf(stderr, "failed to setnsfpn %s\n", path); - return false; - } + const char *path("/var/lib"); + mkdir(path, 0755); + if (!setnsfpn(path)) { + fprintf(stderr, "failed to setnsfpn %s\n", path); + return false; } return true; @@ -172,11 +171,6 @@ static bool FixApplications() { } } -_H Sources_; -bool Changed_; - -_H System_; - int main(int argc, const char *argv[]) { if (argc < 2 || strcmp(argv[1], "configure") != 0) return 0; @@ -196,45 +190,15 @@ int main(int argc, const char *argv[]) { } } - size_t size; - sysctlbyname("kern.osversion", NULL, &size, NULL, 0); - char *osversion = new char[size]; - if (sysctlbyname("kern.osversion", osversion, &size, NULL, 0) != -1) - System_ = [NSString stringWithUTF8String:osversion]; - - NSDictionary *metadata([[[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"] autorelease]); - NSUInteger version(0); - - if (metadata != nil) { - Sources_ = [metadata objectForKey:@"Sources"]; - - if (NSNumber *number = [metadata objectForKey:@"Version"]) - version = [number unsignedIntValue]; - } - - 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(); - #define OldCache_ "/var/root/Library/Caches/com.saurik.Cydia" if (access(OldCache_, F_OK) == 0) system("rm -rf " OldCache_); #define NewCache_ "/var/mobile/Library/Caches/com.saurik.Cydia" system("cd /; su -c 'mkdir -p " NewCache_ "' mobile"); - - if (access(NewCache_ "/lists", F_OK) != 0 && errno == ENOENT) { + if (access(NewCache_ "/lists", F_OK) != 0 && errno == ENOENT) system("cp -at " NewCache_ " /var/lib/apt/lists"); - system("chown -R 501.501 " NewCache_ "/lists"); - } + system("chown -R 501.501 " NewCache_); #define OldLibrary_ "/var/lib/cydia" @@ -243,6 +207,15 @@ int main(int argc, const char *argv[]) { #define Cytore_ "/metadata.cb0" + #define CYDIA_LIST "/etc/apt/sources.list.d/cydia.list" + unlink(CYDIA_LIST); + [[NSString stringWithFormat:@ + "deb http://apt.saurik.com/ ios/%.2f main\n" + "deb http://apt.thebigboss.org/repofiles/cydia/ stable main\n" + "deb http://cydia.zodttd.com/repo/cydia/ stable main\n" + "deb http://apt.modmyi.com/ stable main\n" + , kCFCoreFoundationVersionNumber] writeToFile:@ CYDIA_LIST atomically:YES]; + if (access(NewLibrary_ Cytore_, F_OK) != 0 && errno == ENOENT) { if (access(NewCache_ Cytore_, F_OK) == 0) system("mv -f " NewCache_ Cytore_ " " NewLibrary_);