X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/78c9276d29172cbe72fc65ac56bde1627a8f86d1..7296e47e10687e554a4756f65e9c842f88e696e3:/apt-pkg/cdrom.cc diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2c40c731d..4462d4e24 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -58,23 +58,21 @@ bool pkgCdrom::FindPackages(string CD, return _error->Errno("chdir","Unable to change to %s",CD.c_str()); // Look for a .disk subdirectory - struct stat Buf; - if (stat(".disk",&Buf) == 0) + if (DirectoryExists(".disk") == true) { if (InfoDir.empty() == true) InfoDir = CD + ".disk/"; } // Don't look into directories that have been marked to ingore. - if (stat(".aptignr",&Buf) == 0) + if (RealFileExists(".aptignr") == true) return true; - /* Check _first_ for a signature file as apt-cdrom assumes that all files under a Packages/Source file are in control of that file and stops the scanning */ - if (stat("Release.gpg",&Buf) == 0) + if (RealFileExists("Release.gpg") == true || RealFileExists("InRelease") == true) { SigList.push_back(CD); } @@ -86,7 +84,7 @@ bool pkgCdrom::FindPackages(string CD, for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - if (stat(std::string("Packages").append(c->Extension).c_str(), &Buf) != 0) + if (RealFileExists(std::string("Packages").append(c->Extension).c_str()) == false) continue; if (_config->FindB("Debug::aptcdrom",false) == true) @@ -101,7 +99,7 @@ bool pkgCdrom::FindPackages(string CD, for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - if (stat(std::string("Sources").append(c->Extension).c_str(), &Buf) != 0) + if (RealFileExists(std::string("Sources").append(c->Extension).c_str()) == false) continue; if (_config->FindB("Debug::aptcdrom",false) == true) @@ -136,6 +134,7 @@ bool pkgCdrom::FindPackages(string CD, { if (_config->FindB("Debug::aptcdrom",false) == true) std::clog << "Found translation " << Dir->d_name << " in " << CD << "i18n/" << std::endl; + file.erase(file.size() - fileext.size()); TransList.push_back(CD + "i18n/" + file); break; } @@ -278,6 +277,7 @@ bool pkgCdrom::DropBinaryArch(vector &List) /* Here we go and stat every file that we found and strip dup inodes. */ bool pkgCdrom::DropRepeats(vector &List,const char *Name) { + bool couldFindAllFiles = true; // Get a list of all the inodes ino_t *Inodes = new ino_t[List.size()]; for (unsigned int I = 0; I != List.size(); ++I) @@ -298,21 +298,22 @@ bool pkgCdrom::DropRepeats(vector &List,const char *Name) } if (found == false) - _error->Errno("stat","Failed to stat %s%s",List[I].c_str(), Name); + { + _error->Errno("stat","Failed to stat %s%s",List[I].c_str(), Name); + couldFindAllFiles = false; + Inodes[I] = 0; + } } - if (_error->PendingError() == true) { - delete[] Inodes; - return false; - } - // Look for dups for (unsigned int I = 0; I != List.size(); I++) { + if (Inodes[I] == 0) + continue; for (unsigned int J = I+1; J < List.size(); J++) { // No match - if (Inodes[J] != Inodes[I]) + if (Inodes[J] == 0 || Inodes[J] != Inodes[I]) continue; // We score the two paths.. and erase one @@ -338,7 +339,7 @@ bool pkgCdrom::DropRepeats(vector &List,const char *Name) List.erase(List.begin()+I); } - return true; + return couldFindAllFiles; } /*}}}*/ // ReduceSourceList - Takes the path list and reduces it /*{{{*/ @@ -717,7 +718,13 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ DropBinaryArch(List); DropRepeats(List,"Packages"); DropRepeats(SourceList,"Sources"); + // FIXME: We ignore stat() errors here as we usually have only one of those in use + // This has little potencial to drop 'valid' stat() errors as we know that one of these + // files need to exist, but it would be better if we would check it here + _error->PushToStack(); DropRepeats(SigList,"Release.gpg"); + DropRepeats(SigList,"InRelease"); + _error->RevertToStack(); DropRepeats(TransList,""); if(log != NULL) { msg.str("");