diff options
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r-- | cmdline/apt-get.cc | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index cce80ccfe..06daca09b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -130,13 +130,42 @@ class CacheFile : public pkgCacheFile /* Returns true on a Yes.*/ bool YnPrompt(bool Default=true) { + /* nl_langinfo does not support LANGUAGE setting, so we unset it here + to have the help-message (hopefully) match the expected characters */ + char * language = getenv("LANGUAGE"); + if (language != NULL) + language = strdup(language); + if (language != NULL) + unsetenv("LANGUAGE"); + + if (Default == true) + // TRANSLATOR: Yes/No question help-text: defaulting to Y[es] + // e.g. "Do you want to continue? [Y/n] " + // The user has to answer with an input matching the + // YESEXPR/NOEXPR defined in your l10n. + c2out << " " << _("[Y/n]") << " " << std::flush; + else + // TRANSLATOR: Yes/No question help-text: defaulting to N[o] + // e.g. "Should this file be removed? [y/N] " + // The user has to answer with an input matching the + // YESEXPR/NOEXPR defined in your l10n. + c2out << " " << _("[y/N]") << " " << std::flush; + + if (language != NULL) + { + setenv("LANGUAGE", language, 0); + free(language); + } + if (_config->FindB("APT::Get::Assume-Yes",false) == true) { + // TRANSLATOR: "Yes" answer printed for a yes/no question if --assume-yes is set c1out << _("Y") << endl; return true; } else if (_config->FindB("APT::Get::Assume-No",false) == true) { + // TRANSLATOR: "No" answer printed for a yes/no question if --assume-no is set c1out << _("N") << endl; return false; } @@ -1076,7 +1105,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) if (_config->FindI("quiet",0) < 2 && _config->FindB("APT::Get::Assume-Yes",false) == false) { - c2out << _("Install these packages without verification [y/N]? ") << flush; + c2out << _("Install these packages without verification?") << flush; if (!YnPrompt(false)) return _error->Error(_("Some packages could not be authenticated")); @@ -1281,8 +1310,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindI("quiet",0) < 2 && _config->FindB("APT::Get::Assume-Yes",false) == false) { - c2out << _("Do you want to continue [Y/n]? ") << flush; - + c2out << _("Do you want to continue?") << flush; + if (YnPrompt() == false) { c2out << _("Abort.") << endl; @@ -1965,7 +1994,6 @@ bool DoInstall(CommandLine &CmdL) if (Fix != NULL) { // Call the scored problem resolver - Fix->InstallProtect(); Fix->Resolve(true); delete Fix; } @@ -2297,9 +2325,10 @@ bool DoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(archivedir + "lock")); - if (_error->PendingError() == true) + int lock_fd = GetLock(archivedir + "lock"); + if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); + Lock.Fd(lock_fd); } pkgAcquire Fetcher; @@ -2333,9 +2362,10 @@ bool DoAutoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); - if (_error->PendingError() == true) + int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"); + if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); + Lock.Fd(lock_fd); } CacheFile Cache; @@ -3126,8 +3156,7 @@ bool DoBuildDep(CommandLine &CmdL) } } } - - Fix.InstallProtect(); + if (Fix.Resolve(true) == false) _error->Discard(); |