]> git.saurik.com Git - cydia.git/commitdiff
Write a default cydia.list for apt to fix AppleTV. v1.1.21
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 10 Jul 2015 11:20:22 +0000 (04:20 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 10 Jul 2015 11:30:48 +0000 (04:30 -0700)
MobileCydia.mm
Sources.list/cydia.list [changed from symlink to file mode: 0644]
postinst.mm

index abc1643c8bdaf1b456fea0fe48b986d4acbf7edb..c6b82040d839d0e363a6b993a215a2b8a4e20fcc 100644 (file)
@@ -90,6 +90,7 @@
 #include <sys/mount.h>
 #include <sys/reboot.h>
 
+#include <dirent.h>
 #include <fcntl.h>
 #include <notify.h>
 #include <dlfcn.h>
@@ -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));
deleted file mode 120000 (symlink)
index 2c62ba771255cabdac081944f397938beaac907a..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-/var/mobile/Library/Caches/com.saurik.Cydia/sources.list
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
index e69f9c2f559126bd6f54a10cd36cf5fb1beeb411..a204b81b50915160a1de7d8ae8e00330a4734d7f 100644 (file)
@@ -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_);