- // Startup
- string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
- cout << "Using CD-ROM mount point " << CDROM << endl;
-
- // Read the database
- Configuration Database;
- string DFile = _config->FindFile("Dir::State::cdroms");
- if (FileExists(DFile) == true)
- {
- if (ReadConfigFile(Database,DFile) == false)
- return _error->Error("Unable to read the cdrom database %s",
- DFile.c_str());
- }
-
- // Unmount the CD and get the user to put in the one they want
- if (_config->FindB("APT::CDROM::NoMount",false) == false)
- {
- cout << "Unmounting CD-ROM" << endl;
- UnmountCdrom(CDROM);
-
- // Mount the new CDROM
- Prompt("Please insert a CD-ROM and press any key");
- cout << "Mounting CD-ROM" << endl;
- if (MountCdrom(CDROM) == false)
- {
- cout << "Failed to mount the cdrom." << endl;
- return false;
- }
- }
-
- // Hash the CD to get an ID
- cout << "Indentifying.. " << flush;
- string ID;
- if (IdentCdrom(CDROM,ID) == false)
- return false;
- cout << '[' << ID << ']' << endl;
-
- cout << "Scanning Disc for index files.. " << flush;
- // Get the CD structure
- vector<string> List;
- string StartDir = SafeGetCWD();
- if (FindPackages(CDROM,List) == false)
- return false;
- chdir(StartDir.c_str());
-
- // Fix up the list
- DropBinaryArch(List);
- DropRepeats(List);
- cout << "Found " << List.size() << " package index files." << endl;
-
- if (List.size() == 0)
- return _error->Error("Unable to locate any package files, perhaps this is not a debian CD-ROM");
-
- // Check if the CD is in the database
- string Name;
- if (Database.Exists("CD::" + ID) == false ||
- _config->FindB("APT::CDROM::Rename",false) == true)
- {
- cout << "Please provide a name for this CD-ROM, such as 'Debian 2.1r1 Disk 1'";
- Name = PromptLine("");
- }
- else
- Name = Database.Find("CD::" + ID);
- cout << "This Disc is called '" << Name << "'" << endl;
-
- // Copy the package files to the state directory
- if (CopyPackages(CDROM,Name,List) == false)
- return false;
-
- ConvertToSourcelist(CDROM,List);
-
- // Print the sourcelist entries
- cout << "Source List entires for this Disc are:" << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
- cout << "deb \"cdrom:" << Name << "/\" " << *I << endl;
-
- return true;