From 2f544c3c351591f0f30e9f3bdf2cc905f54b906a Mon Sep 17 00:00:00 2001 From: Daniel Hartwig Date: Wed, 20 Jun 2012 17:22:11 +0800 Subject: Do not do FixMissing automatically for command-line actions When a package is not available or fails to download incorrectly aptitude would try to continue without it. This made it hard to detect errors automatically using the exit status. This behaviour is no longer the default, instead if there are missing packages an error will be displayed and the program exit with failure (100). If the user wishes to continue anyway, they can use --fix-missing or configure Aptitude::CmdLine::Fix-Missing in apt.conf. * [cmdline]: An install run will no longer proceed if any package was unavailable or failed to download correctly, instead an error will be shown and exit with non-zero status (100). (Closes: #121313, #302784) The old behaviour can be obtained with the new --fix-missing option or setting Aptitude::CmdLine::Fix-Missing. Closes: #121313 Closes: #302784 --- src/cmdline/cmdline_do_action.cc | 1 + src/generic/apt/download_install_manager.cc | 12 +++++++++++- src/generic/apt/download_install_manager.h | 5 +++++ src/gtk/gui.cc | 1 + src/main.cc | 2 ++ src/ui.cc | 1 + 6 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cmdline/cmdline_do_action.cc b/src/cmdline/cmdline_do_action.cc index 36ded861..a7b2ce3f 100644 --- a/src/cmdline/cmdline_do_action.cc +++ b/src/cmdline/cmdline_do_action.cc @@ -384,6 +384,7 @@ int cmdline_do_action(int argc, char *argv[], aptitude::cmdline::apply_user_tags(user_tags); download_install_manager m(download_only, + aptcfg->FindB(PACKAGE "::CmdLine::Fix-Missing", false), sigc::ptr_fun(&run_dpkg_directly)); // FIXME: Temporary work-around for bug #677175 in apt. diff --git a/src/generic/apt/download_install_manager.cc b/src/generic/apt/download_install_manager.cc index 7c9aa835..a499faa5 100644 --- a/src/generic/apt/download_install_manager.cc +++ b/src/generic/apt/download_install_manager.cc @@ -38,8 +38,11 @@ using namespace std; download_install_manager::download_install_manager(bool _download_only, + bool _fix_missing, const run_dpkg_in_terminal_func &_run_dpkg_in_terminal) - : log(NULL), download_only(_download_only), + : log(NULL), + download_only(_download_only), + fix_missing(_fix_missing), pm(new pkgDPkgPM(*apt_cache_file)), run_dpkg_in_terminal(_run_dpkg_in_terminal) { @@ -139,6 +142,13 @@ download_manager::result download_install_manager::finish_pre_dpkg(pkgAcquire::R } } + if(failed == true && fix_missing == false) + { + _error->Error(_("Unable to fetch some archives, maybe run aptitude" + " update or try with --fix-missing?")); + return failure; + } + if(failed && !pm->FixMissing()) { _error->Error(_("Unable to correct for unavailable packages")); diff --git a/src/generic/apt/download_install_manager.h b/src/generic/apt/download_install_manager.h index 24989883..069a1a41 100644 --- a/src/generic/apt/download_install_manager.h +++ b/src/generic/apt/download_install_manager.h @@ -59,6 +59,10 @@ class download_install_manager : public download_manager /** If \b true, don't actually invoke the package manager. */ bool download_only; + /** If \b true, attempt to correct for packages which fail + to download or are unavailable. */ + bool fix_missing; + /** The package manager object used when installing packages */ pkgPackageManager *pm; @@ -112,6 +116,7 @@ public: * \param _run_dpkg_in_terminal how to set up the terminal for dpkg. */ download_install_manager(bool _download_only, + bool _fix_missing, const run_dpkg_in_terminal_func &_run_dpkg_in_terminal); ~download_install_manager(); diff --git a/src/gtk/gui.cc b/src/gtk/gui.cc index d44a8499..b1715bb5 100644 --- a/src/gtk/gui.cc +++ b/src/gtk/gui.cc @@ -956,6 +956,7 @@ namespace gui boost::shared_ptr m = boost::make_shared(false, + true, sigc::ptr_fun(&gui_run_dpkg)); start_download(m, diff --git a/src/main.cc b/src/main.cc index 47b305d4..baf1b0fc 100644 --- a/src/main.cc +++ b/src/main.cc @@ -313,6 +313,8 @@ CommandLine::Args opts[] = { {0, "group-by", PACKAGE "::CmdLine::Versions-Group-By", CommandLine::HasArg}, {0, "show-package-names", PACKAGE "::CmdLine::Versions-Show-Package-Names", CommandLine::HasArg}, {'f', "fix-broken", PACKAGE "::CmdLine::Fix-Broken", 0}, + {'m', "ignore-missing", PACKAGE "::CmdLine::Fix-Missing", 0}, + {0, "fix-missing", PACKAGE "::CmdLine::Fix-Missing", 0}, {'Z', "show-size-changes", PACKAGE "::CmdLine::Show-Size-Changes", 0}, {'S', "pkgstates", PACKAGE "::%::pkgstates.in", CommandLine::HasArg}, {'c', "config-file", 0, CommandLine::ConfigFile}, diff --git a/src/ui.cc b/src/ui.cc index 084046e5..1f8bfe31 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -1258,6 +1258,7 @@ void install_or_remove_packages() { boost::shared_ptr m = boost::make_shared(false, + true, sigc::ptr_fun(&run_dpkg_with_cwidget_suspended)); m->post_forget_new_hook.connect(package_states_changed.make_slot()); -- cgit v1.2.3