diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-06-28 12:09:44 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-06-28 12:09:44 +0800 |
commit | 590590d0eef2fe6903574a956f83f0fd3d0a31f1 (patch) | |
tree | 0210facdef7844a8306c6bbec611e386e8e7d22b | |
parent | 1ecf9a268973b0ab85dddd7f898e246abee3bb31 (diff) | |
download | aptitude-590590d0eef2fe6903574a956f83f0fd3d0a31f1.tar.gz |
?architecture supports arch specification strings, wildcards
See Debian Policy § 11.1 for more info.
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | doc/en/aptitude.xml | 12 | ||||
-rw-r--r-- | src/generic/apt/matching/compare_patterns.cc | 3 | ||||
-rw-r--r-- | src/generic/apt/matching/match.cc | 6 | ||||
-rw-r--r-- | src/generic/apt/matching/pattern.cc | 11 | ||||
-rw-r--r-- | src/generic/apt/matching/pattern.h | 53 | ||||
-rw-r--r-- | src/generic/apt/matching/serialize.cc | 2 |
7 files changed, 80 insertions, 12 deletions
@@ -118,6 +118,11 @@ behaviour is desirable for two reasons: * New configuration item: Aptitude::CmdLine::Sorting, equivalent to --sort + * [all]: ?architecture search terms now support using specification + strings and wildcards (for example, “linux-any”) as defined + in Debian Policy § 11.1 “Architecture specification + strings”. + - Minor bugs: * handle "-qq" like other apt-utils diff --git a/doc/en/aptitude.xml b/doc/en/aptitude.xml index 3c3711b5..4f448720 100644 --- a/doc/en/aptitude.xml +++ b/doc/en/aptitude.xml @@ -6212,6 +6212,18 @@ e: Examine !: Apply .: Next ,: Previous</screen> special values <literal>native</literal> and <literal>foreign</literal>. </para> + + <para> + The value of <replaceable>architecture</replaceable> can + also be an architecture specification string as defined + in Debian Policy § 11.1 <quote>Architecture + specification strings</quote>. These are strings of the + form <quote><replaceable>os</replaceable>-<replaceable>arch</replaceable></quote>, + where either component can be the wildcard + <quote><literal>any</literal></quote>. For example, + <quote><literal>any-i386</literal></quote> or + <quote><literal>linux-any</literal></quote>. + </para> </listitem> </varlistentry> diff --git a/src/generic/apt/matching/compare_patterns.cc b/src/generic/apt/matching/compare_patterns.cc index 7e5159ef..f8414aef 100644 --- a/src/generic/apt/matching/compare_patterns.cc +++ b/src/generic/apt/matching/compare_patterns.cc @@ -99,7 +99,8 @@ namespace aptitude p2->get_any_version_pattern()); case pattern::architecture: - return p1->get_architecture_architecture().compare(p2->get_architecture_architecture()); + return p1->get_architecture_arch_specification()->get_specification() + .compare(p2->get_architecture_arch_specification()->get_specification()); case pattern::automatic: return 0; diff --git a/src/generic/apt/matching/match.cc b/src/generic/apt/matching/match.cc index 0fc2e191..20545294 100644 --- a/src/generic/apt/matching/match.cc +++ b/src/generic/apt/matching/match.cc @@ -31,6 +31,7 @@ #include <apt-pkg/pkgrecords.h> #include <apt-pkg/pkgsystem.h> #include <apt-pkg/version.h> +#include <apt-pkg/cachefilter.h> #include <cwidget/generic/util/transcode.h> @@ -907,8 +908,9 @@ namespace aptitude { pkgCache::VerIterator ver(target.get_version_iterator(cache)); - if(p->get_architecture_architecture().empty() == true || - p->get_architecture_architecture() == ver.Arch()) + const ref_ptr<arch_specification> spec(p->get_architecture_arch_specification()); + + if(spec->matches(ver.Arch()) == true) return match::make_atomic(p, ver.Arch()); else return NULL; diff --git a/src/generic/apt/matching/pattern.cc b/src/generic/apt/matching/pattern.cc index 5743a2a7..56cea314 100644 --- a/src/generic/apt/matching/pattern.cc +++ b/src/generic/apt/matching/pattern.cc @@ -71,6 +71,17 @@ namespace aptitude return 0 == regexec(&r, s, num_matches, matches, eflags); } + arch_specification::arch_specification(const std::string &_spec) + : pams(_spec), + spec(_spec) + { + } + + bool arch_specification::matches(const char * const &arch) + { + return pams(arch); + } + cwidget::util::ref_ptr<pattern> pattern::make_action(const action_type act) { diff --git a/src/generic/apt/matching/pattern.h b/src/generic/apt/matching/pattern.h index 5aad42f8..b1870acd 100644 --- a/src/generic/apt/matching/pattern.h +++ b/src/generic/apt/matching/pattern.h @@ -33,6 +33,8 @@ #include <sys/types.h> #include <apt-pkg/pkgcache.h> +#include <apt-pkg/cachefilter.h> + namespace aptitude { @@ -55,6 +57,28 @@ namespace aptitude std::string errmsg() const; }; + /** \brief Ref-counted wrapper for PackageArchitectureMatchesSpecification. + */ + class arch_specification : public util::refcounted_base_threadsafe + { + APT::CacheFilter::PackageArchitectureMatchesSpecification pams; + const std::string spec; + + public: + arch_specification(const std::string &_spec); + + bool matches(const char * const &arch); + inline bool matches(const pkgCache::VerIterator &ver) + { + return matches(ver.Arch()); + } + + inline const std::string &get_specification() const + { + return spec; + } + }; + /** \brief C++ wrapper for regular expression objects. * * This class turns compilation errors into exceptions and @@ -238,11 +262,12 @@ namespace aptitude * Fields: pattern. */ any_version, - /** \brief ?architecture(PATTERN) + /** \brief ?architecture(SPECIFICATION) * - * Matches packages by their architecture. + * Matches packages whose architecture meets the given + * SPECIFICATION string (see Debian Policy section 11.1). * - * Fields: regex_info. + * Fields: arch_specification. */ architecture, /** \brief ?automatic @@ -669,6 +694,8 @@ namespace aptitude // to the action match information. std::string string_info; + cwidget::util::ref_ptr<arch_specification> arch_spec; + // Groups several POD values that aren't used simultaneously. union { @@ -804,6 +831,14 @@ namespace aptitude info.multiarch = multiarch_type; } + // Allocate a pattern that has an architecture specification. + pattern(type _tp, + const cwidget::util::ref_ptr<arch_specification> &spec) + : tp(_tp), + arch_spec(spec) + { + } + public: /** \name archive term constructor and accessors. */ @@ -907,19 +942,21 @@ namespace aptitude /** \brief Create an ?architecture term. * - * \param arch The architecture to match. + * \param spec The architecture specification string to match. */ static cwidget::util::ref_ptr<pattern> - make_architecture(const std::string &arch) + make_architecture(const std::string &spec) { - return new pattern(architecture, arch); + return new pattern(architecture, + new arch_specification(spec)); } - const std::string &get_architecture_architecture() const + const cwidget::util::ref_ptr<arch_specification> & + get_architecture_arch_specification() const { eassert(tp == architecture); - return string_info; + return arch_spec; } // @} diff --git a/src/generic/apt/matching/serialize.cc b/src/generic/apt/matching/serialize.cc index 428bc30c..ea506b1f 100644 --- a/src/generic/apt/matching/serialize.cc +++ b/src/generic/apt/matching/serialize.cc @@ -254,7 +254,7 @@ namespace aptitude case pattern::architecture: out << "?architecture("; - serialize_string(p->get_architecture_architecture(), out); + serialize_string(p->get_architecture_arch_specification()->get_specification(), out); out.put(')'); break; |