diff options
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index ed88ae2..813a382 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -56,15 +56,17 @@ #include <WebKit/DOMHTMLIFrameElement.h> #include <algorithm> +#include <fstream> #include <iomanip> #include <set> #include <sstream> #include <string> -#include <ext/stdio_filebuf.h> +#include "fdstream.hpp" #undef ABS +#include "apt.h" #include <apt-pkg/acquire.h> #include <apt-pkg/acquire-item.h> #include <apt-pkg/algorithms.h> @@ -500,6 +502,10 @@ static _finline CFStringRef CYStringCreate(const char *data, size_t size) { CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const uint8_t *>(data), size, kCFStringEncodingISOLatin1, NO, kCFAllocatorNull); } +static _finline CFStringRef CYStringCreate(const std::string &data) { + return CYStringCreate(data.data(), data.size()); +} + static _finline CFStringRef CYStringCreate(const char *data) { return CYStringCreate(data, strlen(data)); } @@ -2513,15 +2519,7 @@ struct PackageNameOrdering : _end _profile(Package$parse$Tagline) - const char *start, *end; - if (parser->ShortDesc(start, end)) { - const char *stop(reinterpret_cast<const char *>(memchr(start, '\n', end - start))); - if (stop == NULL) - stop = end; - while (stop != start && stop[-1] == '\r') - --stop; - parsed->tagline_.set(pool_, start, stop - start); - } + parsed->tagline_.set(pool_, parser->ShortDesc()); _end _profile(Package$parse$Retain) @@ -2550,7 +2548,7 @@ struct PackageNameOrdering : version_ = version; - pkgCache::PkgIterator iterator(version.ParentPkg()); + pkgCache::PkgIterator iterator(version_.ParentPkg()); iterator_ = iterator; _profile(Package$initWithVersion$Version) @@ -2558,7 +2556,7 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Cache) - name_.set(NULL, iterator.Display()); + name_.set(NULL, version_.Display()); latest_.set(NULL, StripVersion_(version_.VerStr())); @@ -2622,7 +2620,11 @@ struct PackageNameOrdering : } while (false); _end _profile(Package$initWithVersion$Tags) +#ifdef __arm64__ + pkgCache::TagIterator tag(version_.TagList()); +#else pkgCache::TagIterator tag(iterator.TagList()); +#endif if (!tag.end()) { tags_ = [NSMutableArray arrayWithCapacity:8]; @@ -2852,23 +2854,12 @@ struct PackageNameOrdering : @synchronized (database_) { pkgRecords::Parser &parser([database_ records]->Lookup(file_)); - - const char *start, *end; - if (!parser.ShortDesc(start, end)) + std::string value(parser.ShortDesc()); + if (value.empty()) return nil; - - if (end - start > 200) - end = start + 200; - - /* - if (const char *stop = reinterpret_cast<const char *>(memchr(start, '\n', end - start))) - end = stop; - - while (end != start && end[-1] == '\r') - --end; - */ - - return [(id) CYStringCreate(start, end - start) autorelease]; + if (value.size() > 200) + value.resize(200); + return [(id) CYStringCreate(value) autorelease]; } } - (unichar) index { @@ -3541,8 +3532,7 @@ class CydiaLogCleaner : } - (void) _readCydia:(NSNumber *)fd { - __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in); - std::istream is(&ib); + boost::fdistream is([fd intValue]); std::string line; static RegEx finish_r("finish:([^:]*)"); @@ -3568,8 +3558,7 @@ class CydiaLogCleaner : } - (void) _readStatus:(NSNumber *)fd { - __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in); - std::istream is(&ib); + boost::fdistream is([fd intValue]); std::string line; static RegEx conffile_r("status: [^ ]* : conffile-prompt : (.*?) *"); @@ -3625,8 +3614,7 @@ class CydiaLogCleaner : } - (void) _readOutput:(NSNumber *)fd { - __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in); - std::istream is(&ib); + boost::fdistream is([fd intValue]); std::string line; while (std::getline(is, line)) { @@ -3653,7 +3641,11 @@ class CydiaLogCleaner : @synchronized (self) { if (static_cast<pkgDepCache *>(cache_) == NULL) return nil; - pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String])); + pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String] +#ifdef __arm64__ + , "any" +#endif + )); return iterator.end() ? nil : [Package packageWithIterator:iterator withZone:NULL inPool:NULL database:self]; } } @@ -4372,6 +4364,7 @@ static _H<NSMutableSet> Diversions_; + (NSArray *) _attributeKeys { return [NSArray arrayWithObjects: + @"bittage", @"bbsnum", @"build", @"cells", @@ -4403,6 +4396,17 @@ static _H<NSMutableSet> Diversions_; return Cydia_; } +- (unsigned) bittage { +#if 0 +#elif defined(__arm64__) + return 64; +#elif defined(__arm__) + return 32; +#else + return 0; +#endif +} + - (NSString *) build { return System_; } @@ -6277,7 +6281,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { NSString *directory = [stack lastObject]; [stack addObject:[file stringByAppendingString:@"/"]]; [files_ replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%*s%@", - ([stack count] - 2) * 3, "", + int(([stack count] - 2) * 3), "", [file substringFromIndex:[directory length]] ]]; } @@ -10215,7 +10219,18 @@ static NSMutableDictionary *AutoreleaseDeepMutableCopyOfDictionary(CFTypeRef typ return [(NSMutableDictionary *) copy autorelease]; } +int main_store(int, char *argv[]); + int main(int argc, char *argv[]) { +#ifdef __arm64__ + const char *argv0(argv[0]); + if (const char *slash = strrchr(argv0, '/')) + argv0 = slash + 1; + if (false); + else if (!strcmp(argv0, "store")) + return main_store(argc, argv); +#endif + int fd(open("/tmp/cydia.log", O_WRONLY | O_APPEND | O_CREAT, 0644)); dup2(fd, 2); close(fd); @@ -10313,7 +10328,7 @@ int main(int argc, char *argv[]) { if (lang != NULL) { setenv("LANG", lang, true); - std::setlocale(LC_ALL, lang); + setlocale(LC_ALL, lang); } /* }}} */ /* Index Collation {{{ */ @@ -10560,8 +10575,12 @@ int main(int argc, char *argv[]) { _assert(pkgInitConfig(*_config)); _assert(pkgInitSystem(*_config, _system)); - if (lang != NULL) - _config->Set("APT::Acquire::Translation", lang); + _config->Set("Acquire::AllowInsecureRepositories", true); + _config->Set("Acquire::Check-Valid-Until", false); + _config->Set("Dir::Bin::Methods::store", "/Applications/Cydia.app/store"); + + _config->Set("pkgCacheGen::ForceEssential", ""); + _config->Set("APT::Acquire::Translation", "environment"); // XXX: this timeout might be important :( //_config->Set("Acquire::http::Timeout", 15); @@ -10582,7 +10601,7 @@ int main(int argc, char *argv[]) { std::string logs("/var/mobile/Library/Logs/Cydia"); mkdir(logs.c_str(), 0755); - _config->Set("Dir::Log::Terminal", logs + "/apt.log"); + _config->Set("Dir::Log", logs); _config->Set("Dir::Bin::dpkg", "/usr/libexec/cydia/cydo"); /* }}} */ |