From d3e8fbb395f57954acd7a2095f02ce530a05ec6a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:20:53 +0100 Subject: =?UTF-8?q?warning:=20extra=20=E2=80=98;=E2=80=99=20[-Wpedantic]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git-Dch: Ignore Reported-By: gcc -Wpedantic --- apt-pkg/cdrom.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 3ae1e8b1d..838c8887a 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -933,10 +933,10 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ // convenience interface, this will just call ScanForRemovable vector pkgUdevCdromDevices::Scan() -{ +{ bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true); - return ScanForRemovable(CdromOnly); -}; + return ScanForRemovable(CdromOnly); +} /*}}}*/ /*{{{*/ vector -- cgit v1.2.3 From e788a834ce421042e727b72e43177edaa47e53a7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 02:18:11 +0100 Subject: warning: useless cast to type A [-Wuseless-cast] Git-Dch: Ignore Reported-By: gcc -Wuseless-cast --- apt-pkg/cdrom.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 838c8887a..ea5ed7e92 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -440,7 +440,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) Out.close(); if (FileExists(DFile) == true) - rename(DFile.c_str(), string(DFile + '~').c_str()); + rename(DFile.c_str(), (DFile + '~').c_str()); if (rename(NewFile.c_str(),DFile.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", DFile.c_str(),DFile.c_str()); @@ -553,7 +553,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) Out.close(); - rename(File.c_str(),string(File + '~').c_str()); + rename(File.c_str(), (File + '~').c_str()); if (rename(NewFile.c_str(),File.c_str()) != 0) return _error->Errno("rename","Failed to rename %s.new to %s", File.c_str(),File.c_str()); @@ -737,7 +737,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (InfoDir.empty() == false && FileExists(InfoDir + "/info") == true) { - ifstream F(string(InfoDir + "/info").c_str()); + ifstream F((InfoDir + "/info").c_str()); if (!F == 0) getline(F,Name); @@ -981,7 +981,7 @@ pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) cdrom.DeviceName = string(devnode); if (mountpath != "") { cdrom.MountPath = mountpath; - string s = string(mountpath); + string s = mountpath; cdrom.Mounted = IsMounted(s); } else { cdrom.Mounted = false; -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- apt-pkg/cdrom.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index ea5ed7e92..6f946b030 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -369,7 +369,7 @@ bool pkgCdrom::DropRepeats(vector &List,const char *Name) // --------------------------------------------------------------------- /* This takes the list of source list expressed entires and collects similar ones to form a single entry for each dist */ -void pkgCdrom::ReduceSourcelist(string CD,vector &List) +void pkgCdrom::ReduceSourcelist(string /*CD*/,vector &List) { sort(List.begin(),List.end()); -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-pkg/cdrom.cc | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 6f946b030..262ff9eab 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -1,28 +1,30 @@ /* */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include #include -#include #include #include #include #include #include -#include "indexcopy.h" - #include using namespace std; -- cgit v1.2.3 From b374004b8ffebe393c5fd5e8056f7a99849c0ebd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 00:09:56 +0100 Subject: apt-cdrom ident shouldn't be interactive Commit 62dcbf84 changed the code of ident to look more like the code for add on my suggestion. This made ident interactive as it starts with a unmount, press enter, mount cycle. The first two are skipped now. This fixes d-i/apt-setup which is using it to get ID as well as label. Closes: 740673 --- apt-pkg/cdrom.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 262ff9eab..dd6d51e97 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -563,7 +563,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) return true; } /*}}}*/ -bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log)/*{{{*/ +bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/ { // Startup CDROM = _config->FindDir("Acquire::cdrom::mount"); @@ -581,16 +581,19 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s // Unmount the CD and get the user to put in the one they want if (_config->FindB("APT::CDROM::NoMount", false) == false) { - if(log != NULL) - log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); - UnmountCdrom(CDROM); - - if(log != NULL) + if (interactive == true) { - log->Update(_("Waiting for disc...\n"), STEP_WAIT); - if(!log->ChangeCdrom()) { - // user aborted - return false; + if(log != NULL) + log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); + UnmountCdrom(CDROM); + + if(log != NULL) + { + log->Update(_("Waiting for disc...\n"), STEP_WAIT); + if(!log->ChangeCdrom()) { + // user aborted + return false; + } } } @@ -636,7 +639,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ { Configuration Database; std::string CDROM; - if (MountAndIdentCDROM(Database, CDROM, ident, log) == false) + if (MountAndIdentCDROM(Database, CDROM, ident, log, false) == false) return false; if (log != NULL) @@ -662,7 +665,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { Configuration Database; std::string ID, CDROM; - if (MountAndIdentCDROM(Database, CDROM, ID, log) == false) + if (MountAndIdentCDROM(Database, CDROM, ID, log, true) == false) return false; if(log != NULL) -- cgit v1.2.3 From 1166ea79889ecd6c88380f7988182647cf787f8f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 02:54:33 +0100 Subject: msgstr with elipses need three dots fixes some messages and their translation so that all of them have three dots for messages with an elipse. Many translations already had this. --- apt-pkg/cdrom.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index dd6d51e97..2635ede76 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -584,7 +584,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s if (interactive == true) { if(log != NULL) - log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); + log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); UnmountCdrom(CDROM); if(log != NULL) @@ -607,7 +607,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s // Hash the CD to get an ID if (log != NULL) - log->Update(_("Identifying.. "), STEP_IDENT); + log->Update(_("Identifying... "), STEP_IDENT); if (IdentCdrom(CDROM,ident) == false) { @@ -669,7 +669,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ return false; if(log != NULL) - 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 List; -- cgit v1.2.3 From 7187074bfc7a6932ab21c33546e71b61abe258e3 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Mon, 21 Apr 2014 11:54:34 +0200 Subject: properly undo CD-ROM mount in all error cases In bug #740673 various issues in the CD-ROM handling code were identified, while most the issues ended up being fixed in another way, the unmounting of the CD-ROM in error cases was not tackled so far. (The patch was modified by the commiter to apply) --- apt-pkg/cdrom.cc | 66 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 25 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2635ede76..a5ad6a9ff 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -563,6 +563,15 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) return true; } /*}}}*/ +bool pkgCdrom::UnmountCDROM(std::string const &CDROM, pkgCdromStatus * const log)/*{{{*/ +{ + if (_config->FindB("APT::CDROM::NoMount",false) == true) + return true; + if (log != NULL) + log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); + return UnmountCdrom(CDROM); +} + /*}}}*/ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/ { // Startup @@ -583,9 +592,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s { if (interactive == true) { - if(log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, log); if(log != NULL) { @@ -605,6 +612,9 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s return _error->Error("Failed to mount the cdrom."); } + if (IsMounted(CDROM) == false) + return _error->Error("Failed to mount the cdrom."); + // Hash the CD to get an ID if (log != NULL) log->Update(_("Identifying... "), STEP_IDENT); @@ -614,6 +624,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s ident = ""; if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } @@ -629,8 +640,11 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s if (FileExists(DFile) == true) { if (ReadConfigFile(Database,DFile) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); + } } return true; } @@ -651,13 +665,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) - { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ @@ -682,11 +690,15 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } if (chdir(StartDir.c_str()) != 0) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("chdir","Unable to change to %s", StartDir.c_str()); + } if (_config->FindB("Debug::aptcdrom",false) == true) { @@ -728,8 +740,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (List.empty() == true && SourceList.empty() == true) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error(_("Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture?")); } @@ -769,14 +780,14 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if(log == NULL) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("No disc name found and no way to ask for it"); } while(true) { if(!log->AskCdromName(Name)) { // user canceld + UnmountCDROM(CDROM, NULL); return false; } cout << "Name: '" << Name << "'" << endl; @@ -813,7 +824,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string const partialListDir = listDir + "partial/"; if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("cdrom", _("List directory %spartial is missing."), listDir.c_str()); + } // take care of the signatures and copy them if they are ok // (we do this before PackageCopy as it modifies "List" and "SourceList") @@ -827,7 +841,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (Copy.CopyPackages(CDROM,Name,List, log) == false || SrcCopy.CopyPackages(CDROM,Name,SourceList, log) == false || TransCopy.CopyTranslations(CDROM,Name,TransList, log) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } // reduce the List so that it takes less space in sources.list ReduceSourcelist(CDROM,List); @@ -837,13 +854,19 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (_config->FindB("APT::cdrom::NoAct",false) == false) { if (WriteDatabase(Database) == false) + { + UnmountCDROM(CDROM, NULL); return false; - + } + if(log != NULL) log->Update(_("Writing new source list\n"), STEP_WRITE); if (WriteSourceList(Name,List,false) == false || WriteSourceList(Name,SourceList,true) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } } // Print the sourcelist entries @@ -855,8 +878,7 @@ 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); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -874,8 +896,7 @@ 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); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -888,12 +909,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ -- cgit v1.2.3