From 114019ea578001659f0c2b49353fabba72ff83fc Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Mon, 2 Jun 2008 21:56:16 -0700 Subject: Add a note to the manpage documentation of "aptitude download" indicating that patterns are allowed. --- doc/en/manpage.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/en/manpage.xml b/doc/en/manpage.xml index 157676b2..3f939ee7 100644 --- a/doc/en/manpage.xml +++ b/doc/en/manpage.xml @@ -830,7 +830,14 @@ i A texlive-latex-extra Conflicts textopo Downloads the .deb file for the given - package to the current directory. + package to the current directory. If a package name + contains a tilde character + (~) or a question mark + (?), it will be treated + as a search pattern and all the matching packages will be + downloaded (see the section Search Patterns + in the &aptitude; reference manual). -- cgit v1.2.3 From 45f522281d76b07c5ac6c3dfe64fc08c1f94400a Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Wed, 4 Jun 2008 21:34:21 -0700 Subject: In the internal resolver self-test, check that the set of packages and versions known to the resolver is consistent with reality. --- src/cmdline/cmdline_check_resolver.cc | 139 +++++++++++++++++++++++++++++++++- 1 file changed, 138 insertions(+), 1 deletion(-) diff --git a/src/cmdline/cmdline_check_resolver.cc b/src/cmdline/cmdline_check_resolver.cc index 6a059ef2..04463602 100644 --- a/src/cmdline/cmdline_check_resolver.cc +++ b/src/cmdline/cmdline_check_resolver.cc @@ -1,6 +1,6 @@ // cmdline_check_resolver.cc // -// Copyright (C) 2005, 2007 Daniel Burrows +// Copyright (C) 2005, 2007-2008 Daniel Burrows // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -26,8 +26,134 @@ #include +#include +#include + using namespace std; +namespace +{ + // Check that each real (non-virtual) package and real version are + // represented in the universe. + void check_packages_and_versions(const aptitude_universe &u) + { + std::set real_packages; + + // Insert each non-virtual package into real_packages. + for(pkgCache::PkgIterator pkg = (*apt_cache_file)->PkgBegin(); + !pkg.end(); ++pkg) + { + if(!pkg.VersionList().end()) + real_packages.insert(pkg); + } + + std::set seen_packages; + + for(aptitude_universe::package_iterator pi = u.packages_begin(); + !pi.end(); ++pi) + { + const aptitude_universe::package p = *pi; + const pkgCache::PkgIterator apt_pkg = p.get_pkg(); + bool seen_uninst = false; + + seen_packages.insert(apt_pkg); + + std::set real_versions; + for(pkgCache::VerIterator ver = apt_pkg.VersionList(); + !ver.end(); ++ver) + { + // Skip versions that exist only on the current system and + // that have been removed; the resolver does. + if( ! (!ver.Downloadable() && + (ver != apt_pkg.CurrentVer() || + apt_pkg->CurrentState == pkgCache::State::ConfigFiles) )) + real_versions.insert(ver); + } + + std::set seen_versions; + for(aptitude_universe::package::version_iterator vi = p.versions_begin(); + !vi.end(); ++vi) + { + if(vi.get_ver().end()) + seen_uninst = true; + else + seen_versions.insert(vi.get_ver()); + } + + if(!seen_uninst) + std::cout << "Didn't see the UNINST version of the package " << apt_pkg.Name() << "." << std::endl; + + std::vector remaining_versions; + std::set_difference(real_versions.begin(), real_versions.end(), + seen_versions.begin(), seen_versions.end(), + std::back_inserter(remaining_versions)); + + for(std::vector::const_iterator it = + remaining_versions.begin(); it != remaining_versions.end(); + ++it) + { + std::cout << "The package version " << it->ParentPkg().Name() + << " " << it->VerStr() << " is missing from the resolver." + << std::endl; + } + + if((*apt_cache_file)[apt_pkg].Keep() && + apt_pkg->CurrentState == pkgCache::State::ConfigFiles) + { + if(!p.current_version().get_ver().end()) + { + std::cout << "The package " << apt_pkg.Name() + << " only has config files installed, but version " + << p.current_version().get_ver().VerStr() + << " is installed according to the resolver." + << std::endl; + } + } + else + { + pkgCache::VerIterator cache_instver = (*apt_cache_file)[apt_pkg].InstVerIter(*apt_cache_file); + pkgCache::VerIterator resolver_instver = p.current_version().get_ver(); + + if(cache_instver != resolver_instver) + { + if(cache_instver.end()) + std::cout << "The package " << apt_pkg.Name() + << " should not be installed, but version " + << resolver_instver.VerStr() + << " is installed according to the resolver." + << std::endl; + else if(resolver_instver.end()) + std::cout << "The package " << apt_pkg.Name() + << " should be installed at version " + << cache_instver.VerStr() + << ", but it isn't installed according to the resolver." + << std::endl; + else + std::cout << "The package " << apt_pkg.Name() + << " should be installed at version " + << cache_instver.VerStr() + << ", but version " + << resolver_instver.VerStr() + << " is installed according to the resolver." + << std::endl; + } + } + } + + std::vector remaining_packages; + std::set_difference(real_packages.begin(), real_packages.end(), + seen_packages.begin(), seen_packages.end(), + std::back_inserter(remaining_packages)); + + for(std::vector::const_iterator it = + remaining_packages.begin(); it != remaining_packages.end(); ++it) + { + std::cout << "The package " << it->Name() + << " is missing from the resolver model." << std::endl; + } + } +} + int cmdline_check_resolver(int argc, char *argv[], const char *status_fname) { @@ -45,6 +171,17 @@ int cmdline_check_resolver(int argc, char *argv[], aptitude_universe u(*apt_cache_file); + std::cout << "Checking that packages and versions are properly projected." + << std::endl; + + check_packages_and_versions(u); + + // TODO: test that all dependencies are represented, somehow. This + // is complicated since dependency representation isn't one-to-one. + + std::cout << "Checking internal consistency of the dependency model." + << std::endl; + sanity_check_universe(u); std::cout << "Sanity check complete." << std::endl; -- cgit v1.2.3 From 76456fd07e12bef4e383e40ec5607d6e2cd3b6a2 Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Sat, 7 Jun 2008 12:48:04 -0700 Subject: Implement the "disable column formatting" feature via a new command-line option, "--disable-columns". (Closes: #141929) This should make 'aptitude search' more useful in scripting contexts or other situations where its output is being used noninteractively. --- doc/en/aptitude.xml | 18 +++++++++++-- doc/en/manpage.xml | 48 ++++++++++++++++++++++++++++++++++ src/cmdline/cmdline_search.cc | 60 +++++++++++++++++++++++++++++++++++-------- src/cmdline/cmdline_search.h | 3 ++- src/main.cc | 11 ++++++-- 5 files changed, 125 insertions(+), 15 deletions(-) diff --git a/doc/en/aptitude.xml b/doc/en/aptitude.xml index e0cfb200..f383fef6 100644 --- a/doc/en/aptitude.xml +++ b/doc/en/aptitude.xml @@ -9439,6 +9439,20 @@ iuAU wesnoth-data +930kB 0.8.7-1 0.8.8-1.0w + + Aptitude::CmdLine::Disable-Columns + false + + If this option is enabled, the results of command-line + searches (performed via aptitude + search) will not be formatted into + fixed-width columns or truncated to the screen width. + This is equivalent to the --disable-columns + command-line option. + + + Aptitude::CmdLine::Download-Only false @@ -9629,8 +9643,8 @@ iuAU wesnoth-data +930kB 0.8.7-1 0.8.8-1.0w Aptitude::Safe-Resolver::No-New-Installs false - If this option is enabled, then when the - safe dependency resolver has been + If this option is true, then when + the safe dependency resolver has been activated via --safe-resolver, the resolver will not be allowed to install packages diff --git a/doc/en/manpage.xml b/doc/en/manpage.xml index 3f939ee7..e3ae7046 100644 --- a/doc/en/manpage.xml +++ b/doc/en/manpage.xml @@ -1006,6 +1006,48 @@ i A texlive-latex-extra Conflicts textopo + + --disable-columns + + + + This option causes aptitude search to + output its results without any special formatting. In + particular: normally &aptitude; will add whitespace or + truncate search results in an attempt to fit its results + into vertical columns. With this flag, + each line will be formed by replacing any format escapes + in the format string with the correponding text; column + widths will be ignored. + + + + For instance, the first few lines of output from aptitude search -F '%p %V' --disable-columns libedataserver might be: + + + disksearch 1.2.1-3 +hp-search-mac 0.1.3 +libbsearch-ruby 1.5-5 +libbsearch-ruby1.8 1.5-5 +libclass-dbi-abstractsearch-perl 0.07-2 +libdbix-fulltextsearch-perl 0.73-10 + + + As in the above example, + --disable-columns is often useful in + combination with a custom display format set using the + command-line option -F. + + + + This corresponds to the configuration option + Aptitude::CmdLine::Disable-Columns. + + + + -D, --show-deps @@ -1057,6 +1099,12 @@ i A texlive-latex-extra Conflicts textopo available version (see the section Customizing how packages are displayed in the &aptitude; reference manual for more information). + + The command-line option --disable-columns + is often useful in combination with -F. + + This corresponds to the configuration option Aptitude::CmdLine::Package-Display-Format. diff --git a/src/cmdline/cmdline_search.cc b/src/cmdline/cmdline_search.cc index 45bf3f5f..e76376c9 100644 --- a/src/cmdline/cmdline_search.cc +++ b/src/cmdline/cmdline_search.cc @@ -27,8 +27,9 @@ using namespace std; namespace cw = cwidget; using cwidget::util::transcode; using namespace aptitude::matching; +using namespace cwidget::config; -class search_result_parameters : public cwidget::config::column_parameters +class search_result_parameters : public column_parameters { pkg_match_result *r; public: @@ -91,7 +92,8 @@ public: // FIXME: apt-cache does lots of tricks to make this fast. Should I? int cmdline_search(int argc, char *argv[], const char *status_fname, - string display_format, string width, string sort) + string display_format, string width, string sort, + bool disable_columns) { int real_width=-1; @@ -123,7 +125,7 @@ int cmdline_search(int argc, char *argv[], const char *status_fname, return -1; } - cwidget::config::column_definition_list *columns = + column_definition_list *columns = parse_columns(wdisplay_format, pkg_item::pkg_columnizer::parse_column_type, pkg_item::pkg_columnizer::defaults); @@ -201,15 +203,53 @@ int cmdline_search(int argc, char *argv[], const char *status_fname, for(vector >::iterator i=output.begin(); i!=output.end(); ++i) { - cwidget::config::column_parameters *p = + column_parameters *p = new search_result_parameters(i->second); + pkg_item::pkg_columnizer columnizer(i->first, + i->first.VersionList(), + *columns, + 0); + if(disable_columns) + { + // Instantiate the format string without clipping or + // expanding columns. + // + // TODO: this should move into cwidget in the future, as a new + // mode of operation for layout_columns(). + std::wstring output; + + for(column_definition_list::iterator it = columns->begin(); + it != columns->end(); + ++it) + { + if(it->type == column_definition::COLUMN_LITERAL) + output += it->arg; + else + { + eassert(it->type == column_definition::COLUMN_GENERATED || + it->type == column_definition::COLUMN_PARAM); + + if(it->type == column_definition::COLUMN_GENERATED) + { + cwidget::column_disposition disp = columnizer.setup_column(it->ival); + output += disp.text; + } + else + { + if(p->param_count() <= it->ival) + output += L"###"; + else + output += p->get_param(it->ival); + } + } + } - printf("%ls\n", - pkg_item::pkg_columnizer(i->first, - i->first.VersionList(), - *columns, - 0).layout_columns(real_width==-1?screen_width:real_width, - *p).c_str()); + printf("%ls\n", output.c_str()); + } + else + printf("%ls\n", + columnizer.layout_columns(real_width==-1?screen_width:real_width, + *p).c_str()); // Note that this deletes the whole result, so we can't re-use // the list. diff --git a/src/cmdline/cmdline_search.h b/src/cmdline/cmdline_search.h index ead96a70..284f2601 100644 --- a/src/cmdline/cmdline_search.h +++ b/src/cmdline/cmdline_search.h @@ -11,6 +11,7 @@ */ int cmdline_search(int argc, char *argv[], const char *status_fname, - std::string display_format, std::string width, std::string sort); + std::string display_format, std::string width, std::string sort, + bool disable_columns); #endif // CMDLINE_SEARCH_H diff --git a/src/main.cc b/src/main.cc index f105d0eb..d4bd2107 100644 --- a/src/main.cc +++ b/src/main.cc @@ -207,7 +207,8 @@ enum { OPTION_SAFE_RESOLVER, OPTION_FULL_RESOLVER, OPTION_ARCH_ONLY, - OPTION_NOT_ARCH_ONLY + OPTION_NOT_ARCH_ONLY, + OPTION_DISABLE_COLUMNS }; int getopt_result; @@ -230,6 +231,7 @@ option opts[]={ {"prompt", 0, NULL, 'P'}, {"sort", 1, NULL, 'O'}, {"target-release", 1, NULL, 't'}, + {"disable-columns", 0, &getopt_result, OPTION_DISABLE_COLUMNS}, {"no-new-installs", 0, &getopt_result, OPTION_NO_NEW_INSTALLS}, {"no-new-upgrades", 0, &getopt_result, OPTION_NO_NEW_UPGRADES}, {"allow-new-installs", 0, &getopt_result, OPTION_ALLOW_NEW_INSTALLS}, @@ -282,6 +284,7 @@ int main(int argc, char *argv[]) bool safe_resolver_no_new_installs = aptcfg->FindB(PACKAGE "::Safe-Resolver::No-New-Installs", false); bool safe_resolver_no_new_upgrades = aptcfg->FindB(PACKAGE "::Safe-Resolver::No-New-Upgrades", false); bool always_use_safe_resolver = aptcfg->FindB(PACKAGE "::Always-Use-Safe-Resolver", false); + bool disable_columns = aptcfg->FindB(PACKAGE "::CmdLine::Disable-Columns", false); bool safe_resolver_option = false; bool full_resolver_option = false; @@ -520,6 +523,9 @@ int main(int argc, char *argv[]) case OPTION_ARCH_ONLY: arch_only = true; break; + case OPTION_DISABLE_COLUMNS: + disable_columns = true; + break; default: fprintf(stderr, "%s", _("WEIRDNESS: unknown option code received\n")); @@ -599,7 +605,8 @@ int main(int argc, char *argv[]) return cmdline_search(argc-optind, argv+optind, status_fname, display_format, width, - sort_policy); + sort_policy, + disable_columns); else if(!strcasecmp(argv[optind], "why")) return cmdline_why(argc - optind, argv + optind, status_fname, verbose, false); -- cgit v1.2.3 From bd06624e3d9161d9b82e4a247e512fb7c7f8b20f Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Sat, 7 Jun 2008 13:37:45 -0700 Subject: If -v is passed to safe-upgrade and there are broken deps, show the set of actions prior to dependency resolution in addition to the usual list of broken dependencies. --- src/cmdline/cmdline_prompt.cc | 10 +++++----- src/cmdline/cmdline_prompt.h | 6 ++++++ src/cmdline/cmdline_upgrade.cc | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/cmdline/cmdline_prompt.cc b/src/cmdline/cmdline_prompt.cc index e536c4ff..398cddee 100644 --- a/src/cmdline/cmdline_prompt.cc +++ b/src/cmdline/cmdline_prompt.cc @@ -748,11 +748,11 @@ static bool prompt_trust() * user are being installed/removed (eg, because of sticky states) and * tell the caller to pause for confirmation. */ -static bool cmdline_show_preview(bool as_upgrade, pkgset &to_install, - pkgset &to_hold, pkgset &to_remove, - bool showvers, bool showdeps, - bool showsize, bool showwhy, - int verbose) +bool cmdline_show_preview(bool as_upgrade, pkgset &to_install, + pkgset &to_hold, pkgset &to_remove, + bool showvers, bool showdeps, + bool showsize, bool showwhy, + int verbose) { const int quiet = aptcfg->FindI("Quiet", 0); bool all_empty=true; diff --git a/src/cmdline/cmdline_prompt.h b/src/cmdline/cmdline_prompt.h index 653e6d44..f8ab58a8 100644 --- a/src/cmdline/cmdline_prompt.h +++ b/src/cmdline/cmdline_prompt.h @@ -70,6 +70,12 @@ bool cmdline_do_prompt(bool as_upgrade, pkgPolicy &policy, bool arch_only); +bool cmdline_show_preview(bool as_upgrade, pkgset &to_install, + pkgset &to_hold, pkgset &to_remove, + bool showvers, bool showdeps, + bool showsize, bool showwhy, + int verbose); + /** Prompt for a single line of input from the user. * * \param prompt a message to display before reading input. diff --git a/src/cmdline/cmdline_upgrade.cc b/src/cmdline/cmdline_upgrade.cc index 1cd679bd..c7bf5192 100644 --- a/src/cmdline/cmdline_upgrade.cc +++ b/src/cmdline/cmdline_upgrade.cc @@ -89,8 +89,20 @@ int cmdline_upgrade(int argc, char *argv[], // resolver. (*apt_cache_file)->mark_all_upgradable(false, true, NULL); - if(verbose > 0) - show_broken(); + if(verbose > 0 && (*apt_cache_file)->BrokenCount() > 0) + { + pkgset to_install, to_hold, to_remove; + cmdline_show_preview(true, + to_install, + to_hold, + to_remove, + showvers, + showdeps, + showsize, + showwhy, + verbose); + show_broken(); + } if(!aptitude::cmdline::safe_resolve_deps(verbose, no_new_installs, true)) { -- cgit v1.2.3