From 0f25fa58e3cd2989afdaef3bc50d3b97cbe0571f Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 2 Mar 2008 10:55:09 +0000 Subject: [PATCH] Added CYDIA environment variable during Cydia execution, slightly refactored essential checks (but don't do anything with the new data), and fixed the Install button bug. --- Cydia.mm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index 3493f1e4..a37c35a1 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -40,6 +40,8 @@ extern "C" { exit(-1); \ } \ while (false) + +#define _not(type) ((type) ~ (type) 0) /* }}} */ /* Miscellaneous Messages {{{ */ @interface WebView @@ -853,23 +855,31 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString NSMutableArray *upgrading = [NSMutableArray arrayWithCapacity:16]; NSMutableArray *removing = [NSMutableArray arrayWithCapacity:16]; - bool essential(false); + bool install(false); + bool upgrade(false); + bool remove(false); pkgCacheFile &cache([database_ cache]); for (pkgCache::PkgIterator iterator = cache->PkgBegin(); !iterator.end(); ++iterator) { NSString *name([NSString stringWithCString:iterator.Name()]); - if (cache[iterator].NewInstall()) + bool essential((iterator->Flags & pkgCache::Flag::Essential) != 0); + + if (cache[iterator].NewInstall()) { + if (essential) + install = true; [installing addObject:name]; - else if (cache[iterator].Upgrade()) + } else if (cache[iterator].Upgrade()) { + if (essential) + upgrade = true; [upgrading addObject:name]; - else if (cache[iterator].Delete()) { + } else if (cache[iterator].Delete()) { + if (essential) + remove = true; [removing addObject:name]; - if ((iterator->Flags & pkgCache::Flag::Essential) != 0) - essential = true; } } - if (!essential) + if (!remove) essential_ = nil; else { essential_ = [[UIAlertSheet alloc] @@ -2562,7 +2572,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) { else if (section_ != nil) ++views; - [self popViews:views]; + if (views != 0) + [self popViews:views]; [self setPrompt]; } @@ -3712,6 +3723,7 @@ int main(int argc, char *argv[]) { else Packages_ = [Metadata_ objectForKey:@"Packages"]; + setenv("CYDIA", "", _not(int)); system("dpkg --configure -a"); UIApplicationMain(argc, argv, [Cydia class]); -- 2.45.2