// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cdrom.cc,v 1.10 1998/12/09 00:31:16 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.
#include <apt-pkg/progress.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/cdromutl.h>
-#include <strutl.h>
+#include <apt-pkg/strutl.h>
#include <config.h>
#include <iostream>
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. */
-ino_t Inodes[9];
-
bool FindPackages(string CD,vector<string> &List, unsigned int Depth = 0)
{
+ static ino_t Inodes[9];
if (Depth >= 7)
return true;
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);
for (I = 0; I != Depth; I++)
if (Inodes[I] == Buf.st_ino)
break;
- if (Inodes[I] == Buf.st_ino)
+ if (I != Depth)
continue;
-
+
// Store the inodes weve seen
Inodes[Depth] = Buf.st_ino;
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)
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++)
{
{
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;
}
// Print the sourcelist entries
- cout << "Source List entires for this Disc are:" << endl;
+ cout << "Source List entries for this Disc are:" << endl;
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
{
string::size_type Space = (*I).find(' ');
{
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;
{
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},