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 --- NEWS | 11 +++++++++++ doc/en/aptitude.xml | 15 +++++++++++++++ doc/en/manpage.xml | 27 +++++++++++++++++++++++++++ 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 + 9 files changed, 74 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6bfc1f2c..07e9a62c 100644 --- a/NEWS +++ b/NEWS @@ -79,6 +79,17 @@ behaviour is desirable for two reasons: which is not available for every package it applies to (Closes: #590686); + * [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. + + * [cmdline]: changelog exits with non-zero status on any error (Closes: #675833) diff --git a/doc/en/aptitude.xml b/doc/en/aptitude.xml index cb673b39..3c3711b5 100644 --- a/doc/en/aptitude.xml +++ b/doc/en/aptitude.xml @@ -10804,6 +10804,21 @@ e: Examine !: Apply .: Next ,: Previous + + Aptitude::CmdLine::Fix-Missing + false + + In command-line mode, if a package is unavailable of + fails to download to correctly and this option is + true, &aptitude; will try to + continue installing other packages without it. The + package will still be marked for later installation, + as though --schedule-only had been + used. Command-line Option: --fix-missing. + + + Aptitude::CmdLine::Versions-Group-By diff --git a/doc/en/manpage.xml b/doc/en/manpage.xml index 8b03d591..c6933eb6 100644 --- a/doc/en/manpage.xml +++ b/doc/en/manpage.xml @@ -1533,6 +1533,33 @@ libdbix-fulltextsearch-perl 0.73-10 + + + -m, --ignore-missing, + --fix-missing + + + + + If a package is unavailable or fails to download correctly + try to continue installing packages without it. The + package will still be marked for later installation, as + though --schedule-only had been used. + Configuration Item: Aptitude::CmdLine::Fix-Missing. + + + + + This was the default behaviour in previous versions of + &aptitude; however it caused problems when trying to + detect errors using the exit status and was prone to + resulting in undesired effects. + + + + + --no-new-installs 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