From 57cc2170d119bec4eefdcfaabeb47839e44f5856 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 10 Jul 2015 04:20:22 -0700 Subject: Write a default cydia.list for apt to fix AppleTV. --- MobileCydia.mm | 38 +++++++++++++++++++------------------- Sources.list/cydia.list | 1 - postinst.mm | 9 +++++++++ 3 files changed, 28 insertions(+), 20 deletions(-) mode change 120000 => 100644 Sources.list/cydia.list diff --git a/MobileCydia.mm b/MobileCydia.mm index abc1643..c6b8204 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -90,6 +90,7 @@ #include #include +#include #include #include #include @@ -3758,24 +3759,25 @@ class CydiaLogCleaner : return [self popErrorWithTitle:title] || !success; } -- (bool) _isEtceteraAptSourcesListDirectoryCydiaListSymbolicallyLinkedToMobileCachesCydiaSourceList { - char target[1024]; - ssize_t length(readlink("/etc/apt/sources.list.d/cydia.list", target, sizeof(target) - 1)); - if (length == -1) - return false; - if (length >= sizeof(target)) - return false; - target[length] = '\0'; - return strcmp(target, "/var/mobile/Library/Caches/com.saurik.Cydia/sources.list") == 0; -} - - (bool) popErrorWithTitle:(NSString *)title forReadList:(pkgSourceList &)list { - if ([self popErrorWithTitle:title forOperation:list.ReadMainList()]) - return true; - if (![self _isEtceteraAptSourcesListDirectoryCydiaListSymbolicallyLinkedToMobileCachesCydiaSourceList]) - if ([self popErrorWithTitle:title forOperation:list.Read(SOURCES_LIST)]) - return true; - return false; + list.Reset(); + + bool error(false); + + if (access("/etc/apt/sources.list", F_OK) == 0) + error |= [self popErrorWithTitle:title forOperation:list.ReadAppend("/etc/apt/sources.list")]; + + std::string base("/etc/apt/sources.list.d"); + if (DIR *sources = opendir(base.c_str())) { + while (dirent *source = readdir(sources)) + if (source->d_name[0] != '.' && source->d_namlen > 5 && strcmp(source->d_name + source->d_namlen - 5, ".list") == 0 && strcmp(source->d_name, "cydia.list") != 0) + error |= [self popErrorWithTitle:title forOperation:list.ReadAppend((base + "/" + source->d_name).c_str())]; + closedir(sources); + } + + error |= [self popErrorWithTitle:title forOperation:list.ReadAppend(SOURCES_LIST)]; + + return error; } - (void) reloadDataWithInvocation:(NSInvocation *)invocation { @@ -10413,8 +10415,6 @@ int main(int argc, char *argv[]) { _assert(errno == ENOENT); } - system("/usr/libexec/cydia/cydo /bin/ln -sf /var/mobile/Library/Caches/com.saurik.Cydia/sources.list /etc/apt/sources.list.d/cydia.list"); - /* APT Initialization {{{ */ _assert(pkgInitConfig(*_config)); _assert(pkgInitSystem(*_config, _system)); diff --git a/Sources.list/cydia.list b/Sources.list/cydia.list deleted file mode 120000 index 2c62ba7..0000000 --- a/Sources.list/cydia.list +++ /dev/null @@ -1 +0,0 @@ -/var/mobile/Library/Caches/com.saurik.Cydia/sources.list \ No newline at end of file diff --git a/Sources.list/cydia.list b/Sources.list/cydia.list new file mode 100644 index 0000000..e69de29 diff --git a/postinst.mm b/postinst.mm index e69f9c2..a204b81 100644 --- a/postinst.mm +++ b/postinst.mm @@ -207,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_); -- cgit v1.2.3