aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2009-10-14 00:46:14 -0400
committerAvatar Mike Kelly <pioto@pioto.org> 2009-10-14 00:46:14 -0400
commitd0be18dc7459b552d673a883c64c9927b7e5fade (patch)
tree437e9686e4dcf2390415f64d8aedf728dfa46953
parent892bc68690922bdb7e7bc6617631978b43e2d766 (diff)
downloadpaludis-d0be18dc7459b552d673a883c64c9927b7e5fade.tar.gz
paludis-d0be18dc7459b552d673a883c64c9927b7e5fade.tar.xz
Factor our matching a PackageDepSpec against a QPN:S
Only, don't do anything with slots for the moment.
-rw-r--r--src/clients/cave/Makefile.am3
-rw-r--r--src/clients/cave/cmd_display_resolution.cc24
-rw-r--r--src/clients/cave/match_qpns.cc65
-rw-r--r--src/clients/cave/match_qpns.hh40
4 files changed, 110 insertions, 22 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index b332c3c..1be86c3 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -109,7 +109,8 @@ libcave_a_SOURCES = \
format_plain_metadata_key.cc format_plain_metadata_key.hh \
format_string.cc format_string.hh \
formats.cc formats.hh \
- select_format_for_spec.cc select_format_for_spec.hh
+ select_format_for_spec.cc select_format_for_spec.hh \
+ match_qpns.cc match_qpns.hh
# cmd_config.cc \
# cmd_contents.cc \
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index ea41496..ed9b626 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -23,6 +23,7 @@
#include "command_command_line.hh"
#include "formats.hh"
#include "colour_formatter.hh"
+#include "match_qpns.hh"
#include <paludis/args/do_help.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/safe_ifstream.hh>
@@ -694,27 +695,8 @@ namespace
/* decided nothing, so we can only work for cat/pkg, where
* either can be wildcards (we could work for :slot too,
* but we're lazy) */
- if (! package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
- value_for<n::has_additional_requirements>(false),
- value_for<n::has_category_name_part>(indeterminate),
- value_for<n::has_from_repository>(false),
- value_for<n::has_in_repository>(false),
- value_for<n::has_installable_to_path>(false),
- value_for<n::has_installable_to_repository>(false),
- value_for<n::has_installed_at_path>(false),
- value_for<n::has_package>(indeterminate),
- value_for<n::has_package_name_part>(indeterminate),
- value_for<n::has_slot_requirement>(false),
- value_for<n::has_tag>(false),
- value_for<n::has_version_requirements>(false)
- )))
- continue;
-
- if (spec.package_ptr() && *spec.package_ptr() != (*r)->resolvent().package())
- continue;
- if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != (*r)->resolvent().package().package())
- continue;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != (*r)->resolvent().package().category())
+ Resolvent resolvent((*r)->resolvent());
+ if (! match_qpns(*env, spec, resolvent.package()))
continue;
}
else
diff --git a/src/clients/cave/match_qpns.cc b/src/clients/cave/match_qpns.cc
new file mode 100644
index 0000000..83b7f3c
--- /dev/null
+++ b/src/clients/cave/match_qpns.cc
@@ -0,0 +1,65 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Mike Kelly
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "match_qpns.hh"
+#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_dep_spec_properties.hh>
+#include <paludis/name.hh>
+#include <paludis/util/make_named_values.hh>
+
+using namespace paludis;
+using namespace cave;
+
+// The 's' is silent...
+bool
+paludis::cave::match_qpns(
+ const Environment &,
+ const PackageDepSpec & spec,
+ const QualifiedPackageName & package)
+{
+ /* decided nothing, so we can only work for cat/pkg, where
+ * either can be wildcards (we could work for :slot too,
+ * but we're lazy) */
+ if (! package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(indeterminate),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(false),
+ value_for<n::has_version_requirements>(false)
+ )))
+ return false;
+
+ if (spec.package_ptr() && *spec.package_ptr() != package)
+ return false;
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != package.package())
+ return false;
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != package.category())
+ return false;
+
+ return true;
+}
+
diff --git a/src/clients/cave/match_qpns.hh b/src/clients/cave/match_qpns.hh
new file mode 100644
index 0000000..d17fbea
--- /dev/null
+++ b/src/clients/cave/match_qpns.hh
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Mike Kelly
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_CAVE_MATCH_QPNS_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_MATCH_QPNS_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/name-fwd.hh>
+
+namespace paludis
+{
+ namespace cave
+ {
+ bool match_qpns(
+ const Environment & env,
+ const PackageDepSpec & spec,
+ const QualifiedPackageName & package)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+ }
+}
+
+#endif