#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
+#include <algorithm>
#include "indexcopy.h"
Res += 10;
if (Path.find("/debian/") != string::npos)
Res -= 10;
+
+ // check for symlinks in the patch leading to the actual file
+ // a symlink gets a big penalty
+ struct stat Buf;
+ string statPath = flNotFile(Path);
+ string cdromPath = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+ while(statPath != cdromPath && statPath != "./") {
+ statPath.resize(statPath.size()-1); // remove the trailing '/'
+ if (lstat(statPath.c_str(),&Buf) == 0) {
+ if(S_ISLNK(Buf.st_mode)) {
+ Res -= 60;
+ break;
+ }
+ }
+ statPath = flNotFile(statPath); // descent
+ }
+
return Res;
}
{
F.getline(Buffer,sizeof(Buffer));
CurLine++;
+ if (F.fail() && !F.eof())
+ return _error->Error(_("Line %u too long in source list %s."),
+ CurLine,File.c_str());
_strtabexpand(Buffer,sizeof(Buffer));
_strstrip(Buffer);
}
if(log) {
msg.str("");
- ioprintf(msg, _("Stored Label: %s \n"),
+ ioprintf(msg, _("Stored label: %s \n"),
Database.Find("CD::"+ident).c_str());
log->Update(msg.str());
}
string DFile = _config->FindFile("Dir::State::cdroms");
if (FileExists(DFile) == true)
{
- if (ReadConfigFile(Database,DFile) == false)
+ if (ReadConfigFile(Database,DFile) == false)
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
log->Update("["+ID+"]\n");
if(log)
- log->Update(_("Scanning Disc for index files..\n"),STEP_SCAN);
+ log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
// Get the CD structure
vector<string> List;
log->Update(msg.str(), STEP_SCAN);
}
- if (List.size() == 0 && SourceList.size() == 0)
+ if (List.size() == 0 && SourceList.size() == 0)
+ {
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ UnmountCdrom(CDROM);
return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc");
+ }
// Check if the CD is in the database
string Name;
if(log) {
msg.str("");
- ioprintf(msg, "Found label '%s'\n", Name.c_str());
+ ioprintf(msg, _("Found label '%s'\n"), Name.c_str());
log->Update(msg.str());
}
Database.Set("CD::" + ID + "::Label",Name);
Name.empty() == true)
{
if(!log)
+ {
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ UnmountCdrom(CDROM);
return _error->Error("No disc name found and no way to ask for it");
+ }
while(true) {
if(!log->AskCdromName(Name)) {
Database.Set("CD::" + ID,Name);
if(log) {
msg.str("");
- ioprintf(msg, _("This Disc is called: \n'%s'\n"), Name.c_str());
+ ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
log->Update(msg.str());
}
// Print the sourcelist entries
if(log)
- log->Update(_("Source List entries for this Disc are:\n"));
+ log->Update(_("Source list entries for this disc are:\n"));
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
+ {
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ UnmountCdrom(CDROM);
return _error->Error("Internal error");
+ }
if(log) {
msg.str("");
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
+ {
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ UnmountCdrom(CDROM);
return _error->Error("Internal error");
+ }
if(log) {
msg.str("");
// Unmount and finish
if (_config->FindB("APT::CDROM::NoMount",false) == false) {
- log->Update(_("Unmounting CD-ROM..."), STEP_LAST);
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
UnmountCdrom(CDROM);
}