From d25b4eee0cafb763b8281da78f2476fcab2fa27c Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Thu, 2 Aug 2018 20:58:23 -1000 Subject: Make Cydia packages report common arch first and fallback to other arches --- MobileCydia.mm | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index 4b82efb..dcfb7a3 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -118,6 +118,8 @@ extern "C" { #include "Cydia/ProgressEvent.h" /* }}} */ +const char *common_arch=NULL; + /* Profiler {{{ */ struct timeval _ltv; bool _itv; @@ -2745,10 +2747,15 @@ struct PackageNameOrdering : - (BOOL) upgradableAndEssential:(BOOL)essential { _profile(Package$upgradableAndEssential) pkgCache::VerIterator current(iterator_.CurrentVer()); - if (current.end()) - return essential && essential_; - else + if (current.end()) { + if (essential && essential_) { + return (strcmp(version_.Arch(), common_arch)==0); + } else { + return false; + } + } else { return version_ != current; + } _end } @@ -3475,11 +3482,11 @@ class CydiaLogCleaner : @synchronized (self) { if (static_cast(cache_) == NULL) return nil; - pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String] -#ifndef __arm__ - , "any" -#endif - )); + pkgCache::PkgIterator iterator; + // try common arch first + iterator = cache_->FindPkg([name UTF8String], common_arch); + if (iterator.end()) + iterator = cache_->FindPkg([name UTF8String], "any"); return iterator.end() ? nil : [[Package newPackageWithIterator:iterator withZone:NULL inPool:NULL database:self] autorelease]; } } @@ -9458,6 +9465,9 @@ int main(int argc, char *argv[]) { _assert(pkgInitConfig(*_config)); _assert(pkgInitSystem(*_config, _system)); + const Configuration::Item *arch = _config->Tree("APT::Architecture"); + NSLog(@"Common Arch: %s\n", arch->Value.c_str()); + common_arch = arch->Value.c_str(); _config->Set("Acquire::AllowInsecureRepositories", true); _config->Set("Acquire::Check-Valid-Until", false); -- cgit v1.2.3