X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/22f8568d5ffd0d3c90f9aadb3450afa4ab500a13..36fb926eada14ae6d3cb7f7658d95fb8c8013812:/apt-pkg/cdrom.cc diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 7e194e253..afb067559 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -1,9 +1,6 @@ /* */ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/cdrom.h" -#endif #include #include #include @@ -18,6 +15,7 @@ #include #include #include +#include #include "indexcopy.h" @@ -446,6 +444,9 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) { 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); @@ -559,8 +560,8 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) } if(log) { msg.str(""); - ioprintf(msg, _("Stored label: %s \n"), - Database.Find("CD::"+ident).c_str()); + ioprintf(msg, _("Stored label: %s\n"), + Database.Find("CD::"+ident).c_str()); log->Update(msg.str()); } return true; @@ -588,7 +589,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) 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()); } @@ -667,15 +668,19 @@ bool pkgCdrom::Add(pkgCdromStatus *log) DropRepeats(TransList,""); if(log) { msg.str(""); - ioprintf(msg, _("Found %i package indexes, %i source indexes, " - "%i translation indexes and %i signatures\n"), + ioprintf(msg, _("Found %u package indexes, %u source indexes, " + "%u translation indexes and %u signatures\n"), List.size(), SourceList.size(), TransList.size(), SigList.size()); 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; @@ -700,7 +705,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) 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); @@ -711,7 +716,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) 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)) { @@ -786,7 +795,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) { 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(""); @@ -800,7 +813,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) { 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(""); @@ -814,7 +831,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) // 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); }