X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/c60d151b7375696a5d2378ee98f3905d38ee70ef..65a1e968442361247b646dc61843f841235114e0:/cmdline/apt-cdrom.cc diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index c312ca30d..85d2fa3e8 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-cdrom.cc,v 1.8 1998/12/08 23:52:23 jgg Exp $ +// $Id: apt-cdrom.cc,v 1.17 1999/01/30 02:12:53 jgg Exp $ /* ###################################################################### APT CDROM - Tool for handling APT's CDROM database. @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -38,8 +38,9 @@ search that short circuits when it his a package file in the dir. This speeds it up greatly as the majority of the size is in the binary-* sub dirs. */ -bool FindPackages(string CD,vector &List, int Depth = 0) +bool FindPackages(string CD,vector &List, unsigned int Depth = 0) { + static ino_t Inodes[9]; if (Depth >= 7) return true; @@ -53,8 +54,7 @@ bool FindPackages(string CD,vector &List, int Depth = 0) this dir is controlled by those package files so we don't look down anymore */ struct stat Buf; - if (stat("Packages",&Buf) == 0 || - stat("Packages.gz",&Buf) == 0) + if (stat("Packages",&Buf) == 0) { List.push_back(CD); @@ -86,6 +86,16 @@ bool FindPackages(string CD,vector &List, int Depth = 0) 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,Depth+1) == false) break; @@ -145,6 +155,8 @@ int Score(string Path) int Res = 0; if (Path.find("stable/") != string::npos) Res += 2; + if (Path.find("/binary-") != string::npos) + Res += 2; if (Path.find("frozen/") != string::npos) Res += 2; if (Path.find("/dists/") != string::npos) @@ -170,11 +182,14 @@ bool DropRepeats(vector &List) for (unsigned int I = 0; I != List.size(); I++) { struct stat Buf; - if (stat(List[I].c_str(),&Buf) != 0) - _error->Errno("stat","Failed to stat %s",List[I].c_str()); + if (stat((List[I] + "Packages").c_str(),&Buf) != 0) + _error->Errno("stat","Failed to stat %sPackages",List[I].c_str()); Inodes[I] = Buf.st_ino; } + if (_error->PendingError() == true) + return false; + // Look for dups for (unsigned int I = 0; I != List.size(); I++) { @@ -892,15 +907,22 @@ bool DoAdd(CommandLine &) { Name = PromptLine(""); if (Name.empty() == false && + Name.find('"') == string::npos && + Name.find(':') == string::npos && Name.find('/') == string::npos) break; cout << "That is not a valid name, try again " << endl; - } - + } } } else Name = Database.Find("CD::" + ID); + + string::iterator J = Name.begin(); + for (; J != Name.end(); J++) + if (*J == '/' || *J == '"' || *J == ':') + *J = '_'; + Database.Set("CD::" + ID,Name); cout << "This Disc is called '" << Name << "'" << endl; @@ -922,7 +944,7 @@ bool DoAdd(CommandLine &) } // Print the sourcelist entries - cout << "Source List entires for this Disc are:" << endl; + cout << "Source List entries for this Disc are:" << endl; for (vector::iterator I = List.begin(); I != List.end(); I++) { string::size_type Space = (*I).find(' '); @@ -944,6 +966,8 @@ int ShowHelp() { cout << PACKAGE << ' ' << VERSION << " for " << ARCHITECTURE << " compiled on " << __DATE__ << " " << __TIME__ << endl; + if (_config->FindB("version") == true) + return 100; cout << "Usage: apt-cdrom [options] command" << endl; cout << endl; @@ -960,6 +984,7 @@ int ShowHelp() cout << " -r Rename a recognized CD-ROM" << endl; cout << " -m No mounting" << endl; cout << " -f Fast mode, don't check package files" << endl; + cout << " -a Thorough scan mode" << endl; cout << " -c=? Read this configuration file" << endl; cout << " -o=? Set an arbitary configuration option, ie -o dir::cache=/tmp" << endl; cout << "See fstab(5)" << endl; @@ -971,6 +996,7 @@ int main(int argc,const char *argv[]) { CommandLine::Args Args[] = { {'h',"help","help",0}, + {'v',"version","version",0}, {'d',"cdrom","Acquire::cdrom::mount",CommandLine::HasArg}, {'r',"rename","APT::CDROM::Rename",0}, {'m',"no-mount","APT::CDROM::NoMount",0},