- // Look for a .disk subdirectory
- struct stat Buf;
- if (stat(".disk",&Buf) == 0)
- {
- if (InfoDir.empty() == true)
- InfoDir = CD + ".disk/";
- }
-
- /* Aha! We found some package files. We assume that everything under
- this dir is controlled by those package files so we don't look down
- anymore */
- if (stat("Packages",&Buf) == 0 || stat("Packages.gz",&Buf) == 0)
- {
- List.push_back(CD);
-
- // Continue down if thorough is given
- if (_config->FindB("APT::CDROM::Thorough",false) == false)
- return true;
- }
- if (stat("Sources.gz",&Buf) == 0 || stat("Sources",&Buf) == 0)
- {
- SList.push_back(CD);
-
- // Continue down if thorough is given
- if (_config->FindB("APT::CDROM::Thorough",false) == false)
- return true;
- }
-
- DIR *D = opendir(".");
- if (D == 0)
- return _error->Errno("opendir","Unable to read %s",CD.c_str());
-
- // Run over the directory
- for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
- {
- // Skip some files..
- if (strcmp(Dir->d_name,".") == 0 ||
- strcmp(Dir->d_name,"..") == 0 ||
- //strcmp(Dir->d_name,"source") == 0 ||
- strcmp(Dir->d_name,".disk") == 0 ||
- strcmp(Dir->d_name,"experimental") == 0 ||
- strcmp(Dir->d_name,"binary-all") == 0)
- continue;
-
- // See if the name is a sub directory
- struct stat Buf;
- if (stat(Dir->d_name,&Buf) != 0)
- continue;
-
- if (S_ISDIR(Buf.st_mode) == 0)
- continue;
-
- unsigned int I;
- for (I = 0; I != Depth; I++)
- if (Inodes[I] == Buf.st_ino)
- break;
- if (I != Depth)
- continue;
-
- // Store the inodes weve seen
- Inodes[Depth] = Buf.st_ino;
-
- // Descend
- if (FindPackages(CD + Dir->d_name,List,SList,InfoDir,Depth+1) == false)
- break;
-
- if (chdir(CD.c_str()) != 0)
- return _error->Errno("chdir","Unable to change to ",CD.c_str());
- };
-
- closedir(D);
-
- return !_error->PendingError();
-}
- /*}}}*/
-// DropBinaryArch - Dump dirs with a string like /binary-<foo>/ /*{{{*/
-// ---------------------------------------------------------------------
-/* Here we drop everything that is not this machines arch */
-bool DropBinaryArch(vector<string> &List)