diff options
-rw-r--r-- | doc/en/manpage.xml | 27 | ||||
-rw-r--r-- | src/cmdline/cmdline_action.cc | 254 | ||||
-rw-r--r-- | src/cmdline/cmdline_action.h | 33 | ||||
-rw-r--r-- | src/cmdline/cmdline_common.h | 2 | ||||
-rw-r--r-- | src/cmdline/cmdline_do_action.cc | 26 | ||||
-rw-r--r-- | src/cmdline/cmdline_do_action.h | 1 | ||||
-rw-r--r-- | src/cmdline/cmdline_prompt.cc | 13 | ||||
-rw-r--r-- | src/cmdline/cmdline_prompt.h | 10 | ||||
-rw-r--r-- | src/cmdline/cmdline_resolver.cc | 7 | ||||
-rw-r--r-- | src/cmdline/cmdline_resolver.h | 10 | ||||
-rw-r--r-- | src/cmdline/cmdline_simulate.cc | 6 | ||||
-rw-r--r-- | src/cmdline/cmdline_simulate.h | 8 | ||||
-rw-r--r-- | src/cmdline/cmdline_upgrade.cc | 14 | ||||
-rw-r--r-- | src/cmdline/cmdline_upgrade.h | 3 | ||||
-rw-r--r-- | src/main.cc | 21 |
15 files changed, 398 insertions, 37 deletions
diff --git a/doc/en/manpage.xml b/doc/en/manpage.xml index 950d1949..501447a6 100644 --- a/doc/en/manpage.xml +++ b/doc/en/manpage.xml @@ -96,6 +96,8 @@ <arg choice='plain'>show</arg> <arg choice='plain'>unhold</arg> <arg choice='plain'>unmarkauto</arg> + <arg choice='plain'>build-dep</arg> + <arg choice='plain'>build-depends</arg> </group> <arg choice='plain' rep='repeat'><replaceable>packages</replaceable></arg> @@ -389,6 +391,31 @@ </varlistentry> <varlistentry> + <term><literal>build-depends</literal>, <literal>build-dep</literal></term> + + <listitem> + <para> + Satisfy the build-dependencies of a package. Each package + name may be a source package, in which case the build + dependencies of that source package are installed; + otherwise, binary packages are found in the same way as + for the <quote><literal>install</literal></quote> command, + and the build-dependencies of the source packages that + build those binary packages are satisfied. + </para> + + <para> + If the command-line parameter + <literal>--arch-only</literal> is present, only + architecture-dependent build dependencies (i.e., not + <literal>Build-Depends-Indep</literal> or + <literal>Build-Conflicts-Indep</literal>) will be + obeyed. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><literal>forbid-version</literal></term> <listitem> diff --git a/src/cmdline/cmdline_action.cc b/src/cmdline/cmdline_action.cc index f2cd1dc6..b088aae3 100644 --- a/src/cmdline/cmdline_action.cc +++ b/src/cmdline/cmdline_action.cc @@ -15,9 +15,194 @@ #include <apt-pkg/algorithms.h> #include <apt-pkg/error.h> #include <apt-pkg/pkgcache.h> +#include <apt-pkg/pkgsystem.h> +#include <apt-pkg/policy.h> +#include <apt-pkg/version.h> #include <stdlib.h> + +namespace +{ + bool cmdline_do_build_depends(const string &pkg, + cmdline_version_source version_source, + const string &version_source_string, + bool arch_only, + pkgPolicy &policy, + pkgset &to_install, pkgset &to_hold, + pkgset &to_remove, pkgset &to_purge, + int verbose, + bool allow_auto) + { + aptitude::cmdline::source_package sourcepkg = + aptitude::cmdline::find_source_package(pkg, + version_source, + version_source_string); + + if(!sourcepkg.valid()) + { + printf(_("Unable to find the source package for \"%s\".\n"), + pkg.c_str()); + return false; + } + + if(apt_cache_file == NULL) + { + // Should never happen. + printf("Sanity-check failed: apt_cache_file should not be NULL here.\n"); + return false; + } + + bool rval = true; + bool last_was_or = false; + typedef pkgSrcRecords::Parser::BuildDepRec BuildDepRec; + typedef std::vector<BuildDepRec> BuildDepList; + for(BuildDepList::const_iterator it = sourcepkg.get_build_deps().begin(); + it != sourcepkg.get_build_deps().end(); ++it) + { + bool is_conflict = (it->Type == pkgSrcRecords::Parser::BuildConflictIndep || + it->Type == pkgSrcRecords::Parser::BuildConflict); + + if(!arch_only && (it->Type == pkgSrcRecords::Parser::BuildDependIndep || + it->Type == pkgSrcRecords::Parser::BuildConflictIndep)) + continue; + + BuildDepList::const_iterator or_group_start = it; + + // Find the bounds of the OR group. + while((it->Op & pkgCache::Dep::Or) != 0) + ++it; + + bool ok = true; + if(!is_conflict) + { + // Walk over the OR group and see if it's satisfied. + // + // NB: if two build-deps require incompatible versions + // of the same package, we'll just get confused. + bool satisfied = false; + for(BuildDepList::const_iterator it2 = or_group_start; + !satisfied && it2 <= it; ++it2) + { + pkgCache::PkgIterator pkg = (*apt_cache_file)->FindPkg(it2->Package); + if(!pkg.end()) + { + pkgCache::VerIterator ver = pkg.CurrentVer(); + if(!ver.end() && + _system->VS->CheckDep(ver.VerStr(), + it2->Op, + it2->Version.c_str())) + satisfied = true; + } + } + + if(!satisfied) + { + for(BuildDepList::const_iterator it2 = or_group_start; + !satisfied && it2 <= it; ++it2) + { + pkgCache::PkgIterator pkg = (*apt_cache_file)->FindPkg(it2->Package); + if(!pkg.end()) + { + int best_priority; + pkgCache::VerIterator best_ver; + for(pkgCache::VerIterator ver = pkg.VersionList(); + !ver.end(); ++ver) + { + if(!_system->VS->CheckDep(ver.VerStr(), it->Op, it->Version.c_str())) + continue; + + for(pkgCache::VerFileIterator vf = ver.FileList(); + !vf.end(); ++vf) + { + const int priority = policy.GetPriority(vf.File()); + if(best_ver.end() || best_priority < priority) + { + best_ver = ver; + best_priority = priority; + } + } + } + + if(!best_ver.end()) + { + cmdline_applyaction(cmdline_install, + pkg, + to_install, to_hold, + to_remove, to_purge, + verbose, + cmdline_version_version, + best_ver.VerStr(), + policy, + arch_only, + allow_auto); + satisfied = true; + } + } + } + + if(!satisfied) + ok = false; + } + } + else // if(!is_conflict); now we're satisfying a conflict. + { + for(BuildDepList::const_iterator it2 = or_group_start; + it2 <= it; ++it2) + { + pkgCache::PkgIterator pkg = (*apt_cache_file)->FindPkg(it2->Package); + if(!pkg.end()) + { + pkgCache::VerIterator ver = pkg.CurrentVer(); + if(!ver.end() && + _system->VS->CheckDep(ver.VerStr(), + it2->Op, + it2->Version.c_str())) + { + cmdline_applyaction(cmdline_remove, + pkg, + to_install, to_hold, + to_remove, to_purge, + verbose, + cmdline_version_cand, + std::string(), + policy, + arch_only, + allow_auto); + } + } + } + } + + if(!ok) + { + rval = false; + + std::string build_dep_description = pkgSrcRecords::Parser::BuildDepType(it->Type);; + for(BuildDepList::const_iterator it2 = or_group_start; + it2 <= it; ++it2) + { + if(it2 != or_group_start) + build_dep_description += " | "; + build_dep_description += it2->Package; + if((it2->Op & ~pkgCache::Dep::Or) != pkgCache::Dep::NoOp) + { + build_dep_description += " ("; + build_dep_description += pkgCache::CompType(it2->Type); + build_dep_description += " "; + build_dep_description += it2->Version; + build_dep_description += ")"; + } + } + printf(_("Unable to satisfy the build-depends %s: ."), + build_dep_description.c_str()); + } + } + + return rval; + } +} + bool cmdline_applyaction(cmdline_pkgaction_type action, pkgCache::PkgIterator pkg, pkgset &to_install, pkgset &to_hold, @@ -25,6 +210,8 @@ bool cmdline_applyaction(cmdline_pkgaction_type action, int verbose, cmdline_version_source source, const string &sourcestr, + pkgPolicy &policy, + bool arch_only, bool allow_auto) { // Handle virtual packages. @@ -185,6 +372,16 @@ bool cmdline_applyaction(cmdline_pkgaction_type action, (*apt_cache_file)->forbid_upgrade(pkg, candver.VerStr(), NULL); } break; + case cmdline_build_depends: + return cmdline_do_build_depends(pkg.Name(), + source, + sourcestr, + arch_only, + policy, + to_install, to_hold, + to_remove, to_purge, + verbose, + allow_auto); default: fprintf(stderr, "Internal error: impossible pkgaction type\n"); abort(); @@ -198,6 +395,7 @@ bool cmdline_applyaction(string s, pkgset &to_install, pkgset &to_hold, pkgset &to_remove, pkgset &to_purge, int verbose, + pkgPolicy &policy, bool arch_only, bool allow_auto) { using namespace aptitude::matching; @@ -227,7 +425,9 @@ bool cmdline_applyaction(string s, rval=cmdline_applyaction(action, pkg, to_install, to_hold, to_remove, to_purge, verbose, source, - sourcestr, allow_auto) && rval; + sourcestr, + policy, arch_only, + allow_auto) && rval; } // break out. @@ -241,7 +441,8 @@ bool cmdline_applyaction(string s, if(source == cmdline_version_version && action != cmdline_install && action != cmdline_forbid_version && - action != cmdline_installauto) + action != cmdline_installauto && + action != cmdline_build_depends) { printf(_("You can only specify a package version with an 'install' command or a 'forbid-version' command.\n")); return false; @@ -249,7 +450,8 @@ bool cmdline_applyaction(string s, if(source == cmdline_version_archive && action != cmdline_install && - action != cmdline_installauto) + action != cmdline_installauto && + action != cmdline_build_depends) { printf(_("You can only specify a package archive with an 'install' command.\n")); return false; @@ -260,6 +462,18 @@ bool cmdline_applyaction(string s, pkgCache::PkgIterator pkg=(*apt_cache_file)->FindPkg(package.c_str()); if(pkg.end()) { + // Assume the user asked for a source package. + if(action == cmdline_build_depends) + return cmdline_do_build_depends(package, + source, + sourcestr, + arch_only, + policy, + to_install, to_hold, + to_remove, to_purge, + verbose, + allow_auto); + // Maybe they misspelled the package name? pkgvector possible; pkg_matcher *m = parse_pattern(package); @@ -325,10 +539,10 @@ bool cmdline_applyaction(string s, return false; } - rval=cmdline_applyaction(action, pkg, - to_install, to_hold, to_remove, to_purge, - verbose, source, - sourcestr, allow_auto); + rval = cmdline_applyaction(action, pkg, + to_install, to_hold, to_remove, to_purge, + verbose, source, + sourcestr, policy, arch_only, allow_auto); } else { @@ -345,10 +559,12 @@ bool cmdline_applyaction(string s, pkgCache::VerIterator testver; if(apply_matcher(m, pkg, *apt_cache_file, *apt_package_records)) - rval=cmdline_applyaction(action, pkg, - to_install, to_hold, to_remove, to_purge, - verbose, source, - sourcestr, allow_auto) && rval; + rval = cmdline_applyaction(action, pkg, + to_install, to_hold, to_remove, to_purge, + verbose, source, + sourcestr, + policy, arch_only, + allow_auto) && rval; } delete m; @@ -398,6 +614,18 @@ static bool parse_action_str(const string &s, if(loc<s.size()) switch(s[loc]) { + case 'B': + // &BD to install build-deps. + ++loc; + if(loc < s.size() && s[loc] == 'D') + { + action = cmdline_build_depends; + ++loc; + } + else + return false; + + break; case 'M': action=cmdline_markauto; ++loc; @@ -423,6 +651,7 @@ void cmdline_parse_action(string s, pkgset &to_install, pkgset &to_hold, pkgset &to_remove, pkgset &to_purge, int verbose, + pkgPolicy &policy, bool arch_only, bool allow_auto) { string::size_type loc=0; @@ -457,7 +686,8 @@ void cmdline_parse_action(string s, if(!cmdline_applyaction(pkgname, action, to_install, to_hold, to_remove, to_purge, - verbose, allow_auto)) + verbose, policy, + arch_only, allow_auto)) return; } } diff --git a/src/cmdline/cmdline_action.h b/src/cmdline/cmdline_action.h index 88b99c3c..08b3c6fc 100644 --- a/src/cmdline/cmdline_action.h +++ b/src/cmdline/cmdline_action.h @@ -7,6 +7,8 @@ #include "cmdline_common.h" +class pkgPolicy; + /// \todo The command-line state should probably be encapsulated /// as an object. @@ -45,6 +47,13 @@ * \param sourcestr The string associated with the version source, or * "" if there is no associated string. * + * \param policy A current policy object (passed as a parameter to + * avoid creating a separate one for each action). + * + * \param arch_only If \b true, when packages' build-depends are + * satisfied, only architecture-dependent build depends are used; + * Build-Depends-Indep and Build-Conflicts-Indep lines are ignored. + * * \param allow_auto If \b false, auto-installation of dependencies * will be disabled regardless of the value of Auto-Install. */ @@ -55,6 +64,8 @@ bool cmdline_applyaction(cmdline_pkgaction_type action, int verbose, cmdline_version_source source, const string &sourcestr, + pkgPolicy &policy, + bool arch_only, bool allow_auto); /** \brief Apply the given command-line action to the given package, @@ -83,6 +94,13 @@ bool cmdline_applyaction(cmdline_pkgaction_type action, * \param verbose The verbosity level at which this command should * operate. * + * \param policy A current policy object (passed as a parameter to + * avoid creating a separate one for each action). + * + * \param arch_only If \b true, when packages' build-depends are + * satisfied, only architecture-dependent build depends are used; + * Build-Depends-Indep and Build-Conflicts-Indep lines are ignored. + * * \param allow_auto If \b false, auto-installation of dependencies * will be disabled regardless of the value of Auto-Install. */ @@ -90,7 +108,9 @@ bool cmdline_applyaction(string s, cmdline_pkgaction_type action, pkgset &to_install, pkgset &to_hold, pkgset &to_remove, pkgset &to_purge, - int verbose, bool allow_auto); + int verbose, + pkgPolicy &policy, bool arch_only, + bool allow_auto); /** \brief Parses a list of actions and executes them. * @@ -118,12 +138,21 @@ bool cmdline_applyaction(string s, * \param verbose The verbosity level at which this command should * operate. * + * \param policy A current policy object (passed as a parameter to + * avoid creating a separate one for each action). + * + * \param arch_only If \b true, when packages' build-depends are + * satisfied, only architecture-dependent build depends are used; + * Build-Depends-Indep and Build-Conflicts-Indep lines are ignored. + * * \param allow_auto If \b false, auto-installation of dependencies * will be disabled regardless of the value of Auto-Install. */ void cmdline_parse_action(string s, pkgset &to_install, pkgset &to_hold, pkgset &to_remove, pkgset &to_purge, - int verbose, bool allow_auto); + int verbose, + pkgPolicy &policy, bool arch_only, + bool allow_auto); #endif // CMDLINE_ACTION_H diff --git a/src/cmdline/cmdline_common.h b/src/cmdline/cmdline_common.h index 17c3681e..39a01a9b 100644 --- a/src/cmdline/cmdline_common.h +++ b/src/cmdline/cmdline_common.h @@ -25,7 +25,7 @@ enum cmdline_pkgaction_type {cmdline_install, cmdline_installauto, cmdline_remove, cmdline_purge, cmdline_hold, cmdline_unhold, cmdline_markauto, cmdline_unmarkauto, cmdline_forbid_version, cmdline_reinstall, - cmdline_keep}; + cmdline_keep, cmdline_build_depends}; enum cmdline_version_source {cmdline_version_cand, /** \brief The current version, if any; diff --git a/src/cmdline/cmdline_do_action.cc b/src/cmdline/cmdline_do_action.cc index fad999d7..a23782ea 100644 --- a/src/cmdline/cmdline_do_action.cc +++ b/src/cmdline/cmdline_do_action.cc @@ -20,6 +20,7 @@ #include <apt-pkg/algorithms.h> #include <apt-pkg/error.h> +#include <apt-pkg/policy.h> #include <apt-pkg/progress.h> using namespace std; @@ -37,6 +38,7 @@ int cmdline_do_action(int argc, char *argv[], bool safe_resolver, bool no_new_installs, bool no_new_upgrades, const std::vector<aptitude::cmdline::tag_application> &user_tags, + bool arch_only, bool queue_only, int verbose) { _error->DumpErrors(); @@ -71,6 +73,9 @@ int cmdline_do_action(int argc, char *argv[], default_action=cmdline_unmarkauto; else if(!strcasecmp(argv[0], "forbid-version")) default_action=cmdline_forbid_version; + else if(!strcasecmp(argv[0], "build-depends") || + !strcasecmp(argv[0], "build-dep")) + default_action = cmdline_build_depends; else { // Should never happen. @@ -109,6 +114,9 @@ int cmdline_do_action(int argc, char *argv[], return -1; } + pkgPolicy policy(&(*apt_cache_file)->GetCache()); + ReadPinFile(policy); + pkgset to_upgrade, to_install, to_hold, to_remove, to_purge; if(dist_upgrade) @@ -191,6 +199,16 @@ int cmdline_do_action(int argc, char *argv[], action = cmdline_keep; target = std::string(argv[i], 0, tmp); break; + case 'D': + // "&BD" for installing build depends. + if(tmp >= 2 && + argv[i][tmp - 1] == 'B' && + argv[i][tmp - 2] == '&') + { + action = cmdline_build_depends; + target = std::string(argv[i], 0, strlen(argv[i]) - 3); + } + break; case 'm': case 'M': if(tmp > 0 && argv[i][tmp - 1] == '&') @@ -233,7 +251,7 @@ int cmdline_do_action(int argc, char *argv[], { cmdline_applyaction(it->second, it->first, to_install, to_hold, to_remove, to_purge, - verbose, pass > 0); + verbose, policy, arch_only, pass > 0); } } } @@ -257,7 +275,8 @@ int cmdline_do_action(int argc, char *argv[], return cmdline_simulate(dist_upgrade, to_install, to_hold, to_remove, to_purge, showvers, showdeps, showsize, always_prompt, verbose, assume_yes, - !fix_broken); + !fix_broken, + policy, arch_only); else if(queue_only) { aptitude::cmdline::apply_user_tags(user_tags); @@ -276,7 +295,8 @@ int cmdline_do_action(int argc, char *argv[], to_install, to_hold, to_remove, to_purge, showvers, showdeps, showsize, always_prompt, verbose, assume_yes, - !fix_broken)) + !fix_broken, + policy, arch_only)) { printf(_("Abort.\n")); return 0; diff --git a/src/cmdline/cmdline_do_action.h b/src/cmdline/cmdline_do_action.h index a37848f6..ed623796 100644 --- a/src/cmdline/cmdline_do_action.h +++ b/src/cmdline/cmdline_do_action.h @@ -17,6 +17,7 @@ int cmdline_do_action(int argc, char *argv[], // it's enabled: bool no_new_installs, bool no_new_upgrades, const std::vector<aptitude::cmdline::tag_application> &user_tags, + bool arch_only, bool queue_only, int verbose); diff --git a/src/cmdline/cmdline_prompt.cc b/src/cmdline/cmdline_prompt.cc index 9b9b4a68..bcf9fe33 100644 --- a/src/cmdline/cmdline_prompt.cc +++ b/src/cmdline/cmdline_prompt.cc @@ -794,6 +794,8 @@ static void prompt_help(ostream &out, bool show_resolver_key) cw::fragf(_("'&M' to mark packages as automatically installed")))); fragments.push_back(flowindentbox(0, 4, cw::fragf(_("'&m' to mark packages as manually installed")))); + fragments.push_back(flowindentbox(0, 4, + cw::fragf(_("'&BD' to install the build-dependencies of a package.")))); cw::fragment *f = indentbox(2, 2, cw::sequence_fragment(fragments)); @@ -813,7 +815,9 @@ bool cmdline_do_prompt(bool as_upgrade, bool always_prompt, int verbose, bool assume_yes, - bool force_no_change) + bool force_no_change, + pkgPolicy &policy, + bool arch_only) { bool exit=false; bool rval=true; @@ -848,7 +852,9 @@ bool cmdline_do_prompt(bool as_upgrade, to_purge, assume_yes, force_no_change, - verbose)) + verbose, + policy, + arch_only)) { have_broken = true; use_internal_resolver = false; @@ -998,7 +1004,8 @@ bool cmdline_do_prompt(bool as_upgrade, case ':': case '&': cmdline_parse_action(response, to_install, to_hold, - to_remove, to_purge, verbose, true); + to_remove, to_purge, verbose, + policy, arch_only, true); break; case 'E': ui_preview(); diff --git a/src/cmdline/cmdline_prompt.h b/src/cmdline/cmdline_prompt.h index c7169cd5..d97c7b1e 100644 --- a/src/cmdline/cmdline_prompt.h +++ b/src/cmdline/cmdline_prompt.h @@ -9,6 +9,8 @@ #include <cwidget/generic/util/exception.h> +class pkgPolicy; + /** Thrown when we get EOF on stdin. Should never be thrown * to the cwidget::toplevel. */ @@ -40,6 +42,10 @@ public: * \param force_no_change if \b true, try extra-hard to preserve * the user's explicit requests (as * specified in to_install et al) + * \param policy a policy object, used to look up version priorities. + * \param arch_only if \b true, when the user asks to have build-dependencies + * for a package installed, only the architecture-dependent dependencies + * will be considered. * * \throws StdinEOFException */ @@ -54,7 +60,9 @@ bool cmdline_do_prompt(bool as_upgrade, bool always_prompt, int verbose, bool assume_yes, - bool force_no_change); + bool force_no_change, + pkgPolicy &policy, + bool arch_only); /** Prompt for a single line of input from the user. * diff --git a/src/cmdline/cmdline_resolver.cc b/src/cmdline/cmdline_resolver.cc index 93fed295..fc4a52cd 100644 --- a/src/cmdline/cmdline_resolver.cc +++ b/src/cmdline/cmdline_resolver.cc @@ -579,7 +579,9 @@ bool cmdline_resolve_deps(pkgset &to_install, pkgset &to_purge, bool assume_yes, bool force_no_change, - int verbose) + int verbose, + pkgPolicy &policy, + bool arch_only) { bool story_is_default = aptcfg->FindB(PACKAGE "::CmdLine::Resolver-Show-Steps", false); @@ -690,7 +692,8 @@ bool cmdline_resolve_deps(pkgset &to_install, /// \todo Maybe only do auto-installation of dependencies /// after the parse? cmdline_parse_action(response, to_install, to_hold, - to_remove, to_purge, verbose, false); + to_remove, to_purge, verbose, + policy, arch_only, false); modified_pkgs=true; break; // Undocumented debug feature: diff --git a/src/cmdline/cmdline_resolver.h b/src/cmdline/cmdline_resolver.h index fa54da6b..f2798363 100644 --- a/src/cmdline/cmdline_resolver.h +++ b/src/cmdline/cmdline_resolver.h @@ -27,6 +27,8 @@ #include <generic/problemresolver/solution.h> class aptitude_universe; +class pkgPolicy; + /** \brief Compute the current solution with a command-line-appropriate * UI. * @@ -79,6 +81,10 @@ void cmdline_dump_resolver(); * heavily bias the resolver against changing any packages in the * supplied sets. * \param verbose the verbosity level set by the user + * + * \param policy the package policy object used to look up priorities. + * \param arch_only if \b true, architecture-independent build-dependencies + * are ignored. */ bool cmdline_resolve_deps(pkgset &to_install, pkgset &to_hold, @@ -86,7 +92,9 @@ bool cmdline_resolve_deps(pkgset &to_install, pkgset &to_purge, bool assume_yes, bool force_no_change, - int verbose); + int verbose, + pkgPolicy &policy, + bool arch_only); namespace aptitude { diff --git a/src/cmdline/cmdline_simulate.cc b/src/cmdline/cmdline_simulate.cc index 38674f04..ed5a95a2 100644 --- a/src/cmdline/cmdline_simulate.cc +++ b/src/cmdline/cmdline_simulate.cc @@ -21,12 +21,14 @@ int cmdline_simulate(bool as_upgrade, pkgset &to_purge, bool showvers, bool showdeps, bool showsize, bool always_prompt, int verbose, - bool assume_yes, bool force_no_change) + bool assume_yes, bool force_no_change, + pkgPolicy &policy, bool arch_only) { if(!cmdline_do_prompt(as_upgrade, to_install, to_hold, to_remove, to_purge, showvers, showdeps, showsize, always_prompt, verbose, - assume_yes, force_no_change)) + assume_yes, force_no_change, + policy, arch_only)) { printf(_("Abort.\n")); return 0; diff --git a/src/cmdline/cmdline_simulate.h b/src/cmdline/cmdline_simulate.h index 263dfd8e..88c7ad76 100644 --- a/src/cmdline/cmdline_simulate.h +++ b/src/cmdline/cmdline_simulate.h @@ -7,6 +7,8 @@ #include "cmdline_common.h" +class pkgPolicy; + /** Simulate an install run. to_install and friends are meant to be * the sets the user explicitly selected (so the prompt can be * displayed only when extra stuff is added or removed). @@ -26,6 +28,9 @@ * \param fornce_no_change if \b true, make an effort to avoid * undoing the user's explicit requests as * given in to_install et al. + * \param policy the policy object used to look up version priorities. + * \param arch_only if \b true, architecture-independent build-dependencies + * will be ignored when the user installs build-dependencies. */ int cmdline_simulate(bool as_upgrade, @@ -33,7 +38,8 @@ int cmdline_simulate(bool as_upgrade, pkgset &to_purge, bool showvers, bool showdeps, bool showsize, bool always_prompt, int verbose, - bool assume_yes, bool force_no_change); + bool assume_yes, bool force_no_change, + pkgPolicy &policy, bool arch_only); #endif // CMDLINE_SIMULATE_H diff --git a/src/cmdline/cmdline_upgrade.cc b/src/cmdline/cmdline_upgrade.cc index c24fda37..2edcdb28 100644 --- a/src/cmdline/cmdline_upgrade.cc +++ b/src/cmdline/cmdline_upgrade.cc @@ -24,6 +24,7 @@ #include <apt-pkg/depcache.h> #include <apt-pkg/error.h> #include <apt-pkg/packagemanager.h> +#include <apt-pkg/policy.h> #include <apt-pkg/progress.h> int cmdline_upgrade(int argc, char *argv[], @@ -33,8 +34,8 @@ int cmdline_upgrade(int argc, char *argv[], bool showvers, bool showdeps, bool showsize, const std::vector<aptitude::cmdline::tag_application> &user_tags, bool visual_preview, - bool always_prompt, bool queue_only, - int verbose) + bool always_prompt, bool arch_only, + bool queue_only, int verbose) { pkgset to_install, to_hold, to_remove, to_purge; @@ -52,6 +53,9 @@ int cmdline_upgrade(int argc, char *argv[], OpTextProgress progress(aptcfg->FindI("Quiet", 0)); apt_init(&progress, false, status_fname); + pkgPolicy policy(&(*apt_cache_file)->GetCache()); + ReadPinFile(policy); + if(_error->PendingError()) { _error->DumpErrors(); @@ -123,7 +127,8 @@ int cmdline_upgrade(int argc, char *argv[], return cmdline_simulate(true, to_install, to_hold, to_remove, to_purge, showvers, showdeps, showsize, always_prompt, verbose, assume_yes, - false); + false, + policy, arch_only); else if(queue_only) { aptitude::cmdline::apply_user_tags(user_tags); @@ -138,7 +143,8 @@ int cmdline_upgrade(int argc, char *argv[], if(!cmdline_do_prompt(true, to_install, to_hold, to_remove, to_purge, showvers, showdeps, showsize, always_prompt, verbose, - assume_yes, false)) + assume_yes, false, + policy, arch_only)) { printf(_("Abort.\n")); return 0; diff --git a/src/cmdline/cmdline_upgrade.h b/src/cmdline/cmdline_upgrade.h index bb065c95..cf800bd1 100644 --- a/src/cmdline/cmdline_upgrade.h +++ b/src/cmdline/cmdline_upgrade.h @@ -16,6 +16,7 @@ int cmdline_upgrade(int argc, char *argv[], bool showvers, bool showdeps, bool showsize, const std::vector<aptitude::cmdline::tag_application> &user_tags, bool visual_preview, bool always_prompt, - bool queue_only, int verbose); + bool arch_only, bool queue_only, + int verbose); #endif // CMDLINE_UPGRADE_H diff --git a/src/main.cc b/src/main.cc index 2fa49f5a..25dd34f1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -193,7 +193,9 @@ enum { OPTION_REMOVE_USER_TAG, OPTION_REMOVE_USER_TAG_FROM, OPTION_SAFE_RESOLVER, - OPTION_FULL_RESOLVER + OPTION_FULL_RESOLVER, + OPTION_ARCH_ONLY, + OPTION_NOT_ARCH_ONLY }; int getopt_result; @@ -228,6 +230,8 @@ option opts[]={ {"add-user-tag-to", 1, &getopt_result, OPTION_ADD_USER_TAG_TO}, {"remove-user-tag", 1, &getopt_result, OPTION_REMOVE_USER_TAG}, {"remove-user-tag-from", 1, &getopt_result, OPTION_REMOVE_USER_TAG_FROM}, + {"arch-only", 0, &getopt_result, OPTION_ARCH_ONLY}, + {"not-arch-only", 0, &getopt_result, OPTION_NOT_ARCH_ONLY}, {0,0,0,0} }; @@ -256,6 +260,7 @@ int main(int argc, char *argv[]) bool simulate = aptcfg->FindB(PACKAGE "::CmdLine::Simulate", false) || aptcfg->FindB(PACKAGE "::Simulate", false); bool download_only=aptcfg->FindB(PACKAGE "::CmdLine::Download-Only", false);; + bool arch_only = aptcfg->FindB("Apt::Get::Arch-Only", false); bool update_only=false, install_only=false, queue_only=false; bool assume_yes=aptcfg->FindB(PACKAGE "::CmdLine::Assume-Yes", false); @@ -492,6 +497,12 @@ int main(int argc, char *argv[]) user_tags.push_back(tag_application(is_add, optarg, m)); } } + case OPTION_NOT_ARCH_ONLY: + arch_only = false; + break; + case OPTION_ARCH_ONLY: + arch_only = true; + break; default: fprintf(stderr, "%s", _("WEIRDNESS: unknown option code received\n")); @@ -589,7 +600,9 @@ int main(int argc, char *argv[]) (!strcasecmp(argv[optind], "unmarkauto")) || (!strcasecmp(argv[optind], "forbid-version")) || (!strcasecmp(argv[optind], "keep")) || - (!strcasecmp(argv[optind], "keep-all")) ) + (!strcasecmp(argv[optind], "keep-all")) || + (!strcasecmp(argv[optind], "build-dep")) || + (!strcasecmp(argv[optind], "build-depends"))) { return cmdline_do_action(argc-optind, argv+optind, status_fname, @@ -599,7 +612,7 @@ int main(int argc, char *argv[]) always_use_safe_resolver, safe_resolver_no_new_installs, safe_resolver_no_new_upgrades, user_tags, - queue_only, verbose); + arch_only, queue_only, verbose); } else if(!strcasecmp(argv[optind], "safe-upgrade") || !strcasecmp(argv[optind], "upgrade")) @@ -618,7 +631,7 @@ int main(int argc, char *argv[]) showvers, showdeps, showsize, user_tags, visual_preview, always_prompt, - queue_only, verbose); + arch_only, queue_only, verbose); } else if(!strcasecmp(argv[optind], "add-user-tag") || !strcasecmp(argv[optind], "remove-user-tag")) |