summaryrefslogtreecommitdiff
path: root/cmdline/apt-cdrom.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-08-15 09:26:00 +0200
committerMichael Vogt <mvo@debian.org>2013-08-15 09:26:00 +0200
commitd7a4635391d9ff36152603ab6faa6eafa206750a (patch)
treee16a562e3e9a195cae286433c5751a1ab9990635 /cmdline/apt-cdrom.cc
parent2a49601f69e08f06fb2727d869d420daacdd09d5 (diff)
parent183116d1a64a2610b88fa6b50f2c5199b69d5841 (diff)
Merge branch 'debian/sid' into debian/experimental
Conflicts: apt-pkg/contrib/strutl.cc apt-pkg/deb/dpkgpm.cc configure.ac debian/changelog doc/po/apt-doc.pot po/apt-all.pot po/ar.po po/ast.po po/bg.po po/bs.po po/ca.po po/cs.po po/cy.po po/da.po po/de.po po/dz.po po/el.po po/es.po po/eu.po po/fi.po po/fr.po po/gl.po po/hu.po po/it.po po/ja.po po/km.po po/ko.po po/ku.po po/lt.po po/mr.po po/nb.po po/ne.po po/nl.po po/nn.po po/pl.po po/pt.po po/pt_BR.po po/ro.po po/ru.po po/sk.po po/sl.po po/sv.po po/th.po po/tl.po po/uk.po po/vi.po po/zh_CN.po po/zh_TW.po test/integration/framework test/integration/test-bug-602412-dequote-redirect test/integration/test-ubuntu-bug-346386-apt-get-update-paywall test/interactive-helper/aptwebserver.cc test/interactive-helper/makefile
Diffstat (limited to 'cmdline/apt-cdrom.cc')
-rw-r--r--cmdline/apt-cdrom.cc34
1 files changed, 22 insertions, 12 deletions
diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc
index 2551f4916..a95970782 100644
--- a/cmdline/apt-cdrom.cc
+++ b/cmdline/apt-cdrom.cc
@@ -39,6 +39,12 @@
#include <apti18n.h>
/*}}}*/
+static const char *W_NO_CDROM_FOUND = \
+ N_("No CD-ROM could be auto-detected or found using "
+ "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 point.");
using namespace std;
@@ -60,7 +66,9 @@ void pkgCdromTextStatus::Prompt(const char *Text)
{
char C;
cout << Text << ' ' << flush;
- read(STDIN_FILENO,&C,1);
+ if (read(STDIN_FILENO,&C,1) < 0)
+ _error->Errno("pkgCdromTextStatus::Prompt",
+ "Failed to read from standard input (not a terminal?)");
if (C != '\n')
cout << endl;
}
@@ -135,7 +143,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
@@ -150,13 +157,15 @@ 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 == false) {
+ _error->Error("%s", _(W_NO_CDROM_FOUND));
+ }
}
if(res)
@@ -178,15 +187,16 @@ 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 {
- return cdrom.Ident(ident, &log);
+ if (count == 0) {
+ res = cdrom.Ident(ident, &log);
+ if (res == false) {
+ _error->Error("%s", _(W_NO_CDROM_FOUND));
+ }
}
-
return res;
}
/*}}}*/
@@ -218,7 +228,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";
@@ -229,7 +239,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},