From 30746bd9d9211005fa1225401f88c675b7010ef6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 18 Nov 2010 10:52:41 -0800 Subject: [PATCH] Reimplement APT marking as I finally understand how it works. --- MobileCydia.mm | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index ebe42b4a..33f5ab5d 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -2748,29 +2748,41 @@ struct PackageNameOrdering : } - (void) clear { +@synchronized (database_) { pkgProblemResolver *resolver = [database_ resolver]; resolver->Clear(iterator_); - resolver->Protect(iterator_); -} + + pkgCacheFile &cache([database_ cache]); + cache->SetReInstall(iterator_, false); + cache->MarkKeep(iterator_, false); +} } - (void) install { +@synchronized (database_) { pkgProblemResolver *resolver = [database_ resolver]; resolver->Clear(iterator_); resolver->Protect(iterator_); + pkgCacheFile &cache([database_ cache]); + cache->SetReInstall(iterator_, false); cache->MarkInstall(iterator_, false); + pkgDepCache::StateCache &state((*cache)[iterator_]); if (!state.Install()) cache->SetReInstall(iterator_, true); -} +} } - (void) remove { +@synchronized (database_) { pkgProblemResolver *resolver = [database_ resolver]; resolver->Clear(iterator_); - resolver->Protect(iterator_); resolver->Remove(iterator_); - [database_ cache]->MarkDelete(iterator_, true); -} + resolver->Protect(iterator_); + + pkgCacheFile &cache([database_ cache]); + cache->SetReInstall(iterator_, false); + cache->MarkDelete(iterator_, true); +} } - (bool) isUnfilteredAndSearchedForBy:(NSString *)search { _profile(Package$isUnfilteredAndSearchedForBy) @@ -3409,6 +3421,19 @@ static NSString *Warning_; } } } CYPoolEnd() _trace(); } +- (void) clear { +@synchronized (self) { + delete resolver_; + resolver_ = new pkgProblemResolver(cache_); + + for (pkgCache::PkgIterator iterator(cache_->PkgBegin()); !iterator.end(); ++iterator) { + if (!cache_[iterator].Keep()) { + cache_->MarkKeep(iterator, false); + cache_->SetReInstall(iterator, false); + } + } +} } + - (void) configure { NSString *dpkg = [NSString stringWithFormat:@"dpkg --configure -a --status-fd %u", statusfd_]; system([dpkg UTF8String]); @@ -8450,16 +8475,7 @@ static _finline void _setHomePage(Cydia *self) { - (void) cancelAndClear:(bool)clear { @synchronized (self) { if (clear) { - // Clear all marks. - pkgCacheFile &cache([database_ cache]); - for (pkgCache::PkgIterator iterator = cache->PkgBegin(); !iterator.end(); ++iterator) { - // Unmark method taken from Synaptic Package Manager. - // Thanks for being sane, unlike Aptitude. - if (!cache[iterator].Keep()) { - cache->MarkKeep(iterator, false); - cache->SetReInstall(iterator, false); - } - } + [database_ clear]; // Stop queuing. Queuing_ = false; -- 2.45.2