From 2ecf54d8704f93f086df7def08e80f49892ac075 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 16 Jun 2013 18:28:45 +0200 Subject: try defaults if auto-detection failed in apt-cdrom The default is to ask udev for location and mountpoints of CD-ROMs, but the old way of specifying the mountpoint is still available and is tried now in case udev doesn't find any CD-ROM. It probably fails, too, but we get a bunch of error messages this way and the user can get an idea of how to make his setup work even if udev can't be convienced to return something useful. Closes: #712433 --- cmdline/apt-cdrom.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'cmdline/apt-cdrom.cc') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 2551f4916..70e49910c 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -150,14 +150,12 @@ bool DoAdd(CommandLine &) bool res = true; bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); + unsigned int count = 0; if (AutoDetect && UdevCdroms.Dlopen()) - { - unsigned int count = 0; while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Add(&log); - } else { + if (count == 0) res = cdrom.Add(&log); - } if(res) cout << _("Repeat this process for the rest of the CDs in your set.") << endl; @@ -178,15 +176,12 @@ bool DoIdent(CommandLine &) bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect"); + unsigned int count = 0; if (AutoDetect && UdevCdroms.Dlopen()) - { - unsigned int count = 0; while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Ident(ident, &log); - } else { + if (count == 0) return cdrom.Ident(ident, &log); - } - return res; } /*}}}*/ -- cgit v1.2.3 From 0a83556bf3ed33c95f39dd1063c4e745aaaeac9e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 22 Jun 2013 10:03:24 +0200 Subject: Improve the apt-cdrom output when no CD-ROM can be auto-detected (closes: #712433) --- cmdline/apt-cdrom.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'cmdline/apt-cdrom.cc') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 70e49910c..520b1e0a0 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -39,6 +39,12 @@ #include /*}}}*/ +static const char *W_NO_CDROM_FOUND = \ + N_("No CD-ROM could be auto-detected or found using " + "the default mount path.\n" + "You may try the --cdrom option to set the CD-ROM mount path. " + "See 'man apt-cdrom' for more " + "information about the CD-ROM auto-detection and mount path."); using namespace std; @@ -135,7 +141,6 @@ bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i) return true; } /*}}}*/ - // DoAdd - Add a new CDROM /*{{{*/ // --------------------------------------------------------------------- /* This does the main add bit.. We show some status and things. The @@ -154,8 +159,12 @@ bool DoAdd(CommandLine &) if (AutoDetect && UdevCdroms.Dlopen()) while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Add(&log); - if (count == 0) + if (count == 0) { res = cdrom.Add(&log); + if (res == false) { + _error->Warning(_(W_NO_CDROM_FOUND)); + } + } if(res) cout << _("Repeat this process for the rest of the CDs in your set.") << endl; @@ -180,8 +189,12 @@ bool DoIdent(CommandLine &) if (AutoDetect && UdevCdroms.Dlopen()) while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Ident(ident, &log); - if (count == 0) - return cdrom.Ident(ident, &log); + if (count == 0) { + res = cdrom.Ident(ident, &log); + if (res == false) { + _error->Warning(_(W_NO_CDROM_FOUND)); + } + } return res; } /*}}}*/ @@ -213,7 +226,7 @@ int ShowHelp() " -m No mounting\n" " -f Fast mode, don't check package files\n" " -a Thorough scan mode\n" - " --auto-detect Auto detect drive and mount point\n" + " --no-auto-detect Do not try to auto detect drive and mount point\n" " -c=? Read this configuration file\n" " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n" "See fstab(5)\n"; @@ -224,7 +237,7 @@ int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, - { 0,"auto-detect","Acquire::cdrom::AutoDetect",0}, + { 0,"auto-detect","Acquire::cdrom::AutoDetect", CommandLine::Boolean}, {'v',"version","version",0}, {'d',"cdrom","Acquire::cdrom::mount",CommandLine::HasArg}, {'r',"rename","APT::CDROM::Rename",0}, -- cgit v1.2.3 From 9d0c9e70494abe789490cd3b76b67d2927e410e7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jun 2013 07:35:16 +0200 Subject: "mount path"->"mount point" and also make the warning a error when no CD-ROM is found --- cmdline/apt-cdrom.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cmdline/apt-cdrom.cc') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 520b1e0a0..3f53e16ee 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -41,10 +41,10 @@ /*}}}*/ static const char *W_NO_CDROM_FOUND = \ N_("No CD-ROM could be auto-detected or found using " - "the default mount path.\n" - "You may try the --cdrom option to set the CD-ROM mount path. " + "the default mount point.\n" + "You may try the --cdrom option to set the CD-ROM mount point. " "See 'man apt-cdrom' for more " - "information about the CD-ROM auto-detection and mount path."); + "information about the CD-ROM auto-detection and mount point."); using namespace std; @@ -162,7 +162,7 @@ bool DoAdd(CommandLine &) if (count == 0) { res = cdrom.Add(&log); if (res == false) { - _error->Warning(_(W_NO_CDROM_FOUND)); + _error->Error(_(W_NO_CDROM_FOUND)); } } @@ -192,7 +192,7 @@ bool DoIdent(CommandLine &) if (count == 0) { res = cdrom.Ident(ident, &log); if (res == false) { - _error->Warning(_(W_NO_CDROM_FOUND)); + _error->Error(_(W_NO_CDROM_FOUND)); } } return res; -- cgit v1.2.3 From 4ff028826ef0fa500b7717415be4109c2ac1da1d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 2 Jul 2013 08:45:03 +0200 Subject: fix format string error --- cmdline/apt-cdrom.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-cdrom.cc') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 3f53e16ee..c153cca85 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -162,7 +162,7 @@ bool DoAdd(CommandLine &) if (count == 0) { res = cdrom.Add(&log); if (res == false) { - _error->Error(_(W_NO_CDROM_FOUND)); + _error->Error("%s", _(W_NO_CDROM_FOUND)); } } @@ -192,7 +192,7 @@ bool DoIdent(CommandLine &) if (count == 0) { res = cdrom.Ident(ident, &log); if (res == false) { - _error->Error(_(W_NO_CDROM_FOUND)); + _error->Error("%s", _(W_NO_CDROM_FOUND)); } } return res; -- cgit v1.2.3