[paludis-commits] r4598 - in trunk: . doc/configuration doc/overview paludis paludis/environments/paludis paludis/environments/portage paludis/repositories/cran paludis/repositories/e paludis/repositories/fake paludis/repositories/gems paludis/repositories/unpackaged paludis/repositories/virtuals ruby

dleverton at svn.pioto.org dleverton at svn.pioto.org
Tue Apr 22 12:00:44 UTC 2008


Author: dleverton
Date: 2008-04-22 12:00:43 +0000 (Tue, 22 Apr 2008)
New Revision: 4598

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/doc/configuration/environment.html.part.in
   trunk/doc/overview/gettingstarted.html.part
   trunk/paludis/environments/paludis/paludis_config.cc
   trunk/paludis/environments/paludis/paludis_config.hh
   trunk/paludis/environments/paludis/paludis_environment.cc
   trunk/paludis/environments/portage/portage_environment.cc
   trunk/paludis/package_id.hh
   trunk/paludis/repositories/cran/cran_package_id.cc
   trunk/paludis/repositories/cran/cran_package_id.hh
   trunk/paludis/repositories/e/e_repository_id.cc
   trunk/paludis/repositories/e/e_repository_id.hh
   trunk/paludis/repositories/fake/fake_package_id.cc
   trunk/paludis/repositories/fake/fake_package_id.hh
   trunk/paludis/repositories/gems/gem_specification.cc
   trunk/paludis/repositories/gems/gem_specification.hh
   trunk/paludis/repositories/unpackaged/installed_id.cc
   trunk/paludis/repositories/unpackaged/installed_id.hh
   trunk/paludis/repositories/unpackaged/unpackaged_id.cc
   trunk/paludis/repositories/unpackaged/unpackaged_id.hh
   trunk/paludis/repositories/virtuals/package_id.cc
   trunk/paludis/repositories/virtuals/package_id.hh
   trunk/paludis/version_spec.cc
   trunk/paludis/version_spec.hh
   trunk/paludis/version_spec_TEST.cc
   trunk/ruby/package_id.cc
   trunk/ruby/package_id_TEST.rb
Log:
Replace portage_compatible in environment.conf with accept_breaks_portage, and add a similar PALUDIS_IGNORE_BREAKS_PORTAGE for PortageEnvironment.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/ChangeLog	2008-04-22 12:00:43 UTC (rev 4598)
@@ -5,6 +5,13 @@
 only listed in SVN log. For a summary of what has changed between releases,
 see the NEWS file. This file is occasionally pruned to ChangeLog.old.bz2.
 
+2008-04-22 David Leverton
+
+	* doc/, paludis/, paludis/environments/, paludis/repositories/,
+	ruby/: Replace portage_compatible in environment.conf with
+	accept_breaks_portage, and add a similar
+	PALUDIS_IGNORE_BREAKS_PORTAGE for PortageEnvironment.
+
 2008-04-22 Ciaran McCreesh
 
 	* NEWS, configure.ac: Preparation for 0.26.0_pre3.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/NEWS	2008-04-22 12:00:43 UTC (rev 4598)
@@ -4,6 +4,14 @@
 This file lists the major changes between versions. For a more detailed list
 of every change, see the ChangeLog.
 
+trunk/:
+    * portage_compatible in environment.conf is deprecated in favour of the new,
+      more fine-grained accept_breaks_portage.  When using Portage configuration
+      files, this is also supported as PALUDIS_IGNORE_BREAKS_PORTAGE in
+      make.conf, for the convenience of users who prefer to use
+      Portage-compatible configuration files without caring about Portage
+      compatibility.
+
 0.26.0_pre3:
     * reconcilio no longer accepts the --verbose switch; verbose display is
       now turned on unconditionally.

Modified: trunk/doc/configuration/environment.html.part.in
===================================================================
--- trunk/doc/configuration/environment.html.part.in	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/doc/configuration/environment.html.part.in	2008-04-22 12:00:43 UTC (rev 4598)
@@ -8,26 +8,34 @@
 key=value configuration file, and may optionally be in bash format. Recognised keys are as follows:</p>
 
 <dl>
-    <dt>world</dt>
+    <dt><code>world</code></dt>
     <dd>The location of the world file.</dd>
 
-    <dt>reduced_username</dt>
+    <dt><code>reduced_username</code></dt>
     <dd>If set, Paludis will use this username rather than <code>paludisbuild</code> when a reduced privilege user is
     required.</dd>
 
-    <dt>portage_compatible</dt>
-    <dd>If set to a non-empty string, Paludis will automatically mask any packages that would break Portage. This can be
-    used if Paludis and Portage are to be used on the same machine. This does <em>not</em> disable cache options that
-    would cause interoperability problems.</dd>
+    <dt><code>accept_breaks_portage</code></dt>
+    <dd>Possibly-empty list of characteristics that can cause a package to be incompatible
+    with Portage, but that should <em>not</em> cause the package to be masked, or
+    <code>*</code> (the default) to ignore Portage compatibility entirely.  Currently
+    available characteristics are:
+    <dl><dt><code>eapi</code></dt><dd>ebuilds with an EAPI that is not supported by Portage</dd>
+    <dt><code>version</code></dt><dd>ebuilds that use Paludis-specific features of the package version syntax</dd>
+    <dt><code>format</code></dt><dd>packages other than ebuilds</dd></dl>
+    Note that this does <em>not</em> disable cache options that would cause interoperability problems.</dd>
 
-    <dt>distribution</dt>
+    <dt><code>portage_compatible</code></dt>
+    <dd>If set to a non-empty string, deprecated equivalent of <code>accept_breaks_portage =</code>.</dd>
+
+    <dt><code>distribution</code></dt>
     <dd>If set, overrides the distribution used when distribution-specific defaults are used.</dd>
 </dl>
 
 <p>The following keys are predefined. They should not be modified.</p>
 
 <dl>
-    <dt>root</dt>
+    <dt><code>root</code></dt>
     <dd>The filesystem root. Relevant if <code>specpath.conf</code> is in use. Using this variable can create a
     configuration system that works both inside and outside of a chroot (e.g. <code>world =
         ${root}/var/db/pkg/world</code>).</dd>

Modified: trunk/doc/overview/gettingstarted.html.part
===================================================================
--- trunk/doc/overview/gettingstarted.html.part	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/doc/overview/gettingstarted.html.part	2008-04-22 12:00:43 UTC (rev 4598)
@@ -18,9 +18,6 @@
         is less widely used, and so may not support all Portage options perfectly.</li>
 
         <li>It is only available on Gentoo and Gentoo-derived distributions.</li>
-
-        <li>You will be unable to use packages that use EAPIs that Portage does not support. The packages in the Paludis
-        overlay fall into this category.</li>
     </ul>
     </li>
 
@@ -45,6 +42,12 @@
 <code>--environment portage</code> (or <code>--environment portage:/other/root</code> to use configuration files in
 another filesystem root).</p>
 
+<p>By default, will be unable to use packages that use EAPIs that Portage does not support. The packages in the Paludis
+overlay fall into this category.  You may override this by setting the <code>PALUDIS_IGNORE_BREAKS_PORTAGE</code>
+in <code>make.conf</code>; the allowed values are the same as for the <code>accept_breaks_portage</code>
+key in Paludis's <a href="../configuration/environment.html"><code>environment.conf</code></a>,
+except that the default is an empty string.</p>
+
 <p>Next, proceed to <a href="#testing">Testing a configuration</a>.</p>
 
 <h2 id="automatic">Automatically migrating</h2>

Modified: trunk/paludis/environments/paludis/paludis_config.cc
===================================================================
--- trunk/paludis/environments/paludis/paludis_config.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/environments/paludis/paludis_config.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -109,7 +109,8 @@
 
         mutable Mutex environment_conf_mutex;
         mutable bool has_environment_conf;
-        mutable bool accept_breaks_portage;
+        mutable bool accept_all_breaks_portage;
+        mutable Set<std::string> accept_breaks_portage;
         mutable std::string reduced_username;
 
         Implementation(PaludisEnvironment * const);
@@ -129,7 +130,7 @@
         package_unmask_conf(new PackageMaskConf(e)),
         mirrors_conf(new MirrorsConf(e)),
         has_environment_conf(false),
-        accept_breaks_portage(true),
+        accept_all_breaks_portage(false),
         reduced_username(getenv_with_default("PALUDIS_REDUCED_USERNAME", "paludisbuild"))
     {
     }
@@ -149,6 +150,7 @@
                 new Map<std::string, std::string>);
         conf_vars->insert("ROOT", root);
         conf_vars->insert("root", root);
+        conf_vars->insert("accept_breaks_portage", "*");
         tr1::shared_ptr<FSEntry> world_file;
 
         if ((FSEntry(config_dir) / "environment.conf").exists())
@@ -181,7 +183,25 @@
             if (! kv->get("reduced_username").empty())
                 reduced_username = kv->get("reduced_username");
 
-            accept_breaks_portage = kv->get("portage_compatible").empty();
+            if (! kv->get("portage_compatible").empty())
+                Log::get_instance()->message("paludis_environment.portage_compatible.deprecated", ll_warning, lc_context)
+                    << "The 'portage_compatible' variable in environment.conf is deprecated,"
+                    << " set 'accept_breaks_portage' to empty instead.";
+            else
+            {
+                std::list<std::string> breakages;
+                tokenise_whitespace(kv->get("accept_breaks_portage"), std::back_inserter(breakages));
+                for (std::list<std::string>::const_iterator it(breakages.begin()),
+                         it_end(breakages.end()); it_end != it; ++it)
+                    if ("*" == *it)
+                    {
+                        accept_all_breaks_portage = true;
+                        break;
+                    }
+                    else
+                        accept_breaks_portage.insert(*it);
+            }
+
             distribution = kv->get("distribution");
 
             if (! kv->get("world").empty())
@@ -678,6 +698,14 @@
 }
 
 bool
+PaludisConfig::accept_all_breaks_portage() const
+{
+    _imp->need_environment_conf();
+
+    return _imp->accept_all_breaks_portage;
+}
+
+const Set<std::string> &
 PaludisConfig::accept_breaks_portage() const
 {
     _imp->need_environment_conf();

Modified: trunk/paludis/environments/paludis/paludis_config.hh
===================================================================
--- trunk/paludis/environments/paludis/paludis_config.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/environments/paludis/paludis_config.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -147,10 +147,15 @@
                 std::string root() const;
 
                 /**
-                 * Whether it's ok to unmask things that break Portage.
+                 * Whether it's ok to unmask things that break Portage, regardless of the reason.
                  */
-                bool accept_breaks_portage() const;
+                bool accept_all_breaks_portage() const;
 
+                /**
+                 * Specific reasons why a package might break Portage that it's ok to ignore.
+                 */
+                const Set<std::string> & accept_breaks_portage() const;
+
                 ///\name Userpriv
                 ///\{
 

Modified: trunk/paludis/environments/paludis/paludis_environment.cc
===================================================================
--- trunk/paludis/environments/paludis/paludis_environment.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/environments/paludis/paludis_environment.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -506,20 +506,29 @@
     class BreaksPortageMask :
         public UnsupportedMask
     {
-        char key() const
-        {
-            return 'B';
-        }
+        private:
+            std::string breakages;
 
-        const std::string description() const
-        {
-            return "breaks Portage";
-        }
+        public:
+            BreaksPortageMask(const std::string & b) :
+                breakages(b)
+            {
+            }
 
-        const std::string explanation() const
-        {
-            return "";
-        }
+            char key() const
+            {
+                return 'B';
+            }
+
+            const std::string description() const
+            {
+                return "breaks Portage";
+            }
+
+            const std::string explanation() const
+            {
+                return breakages;
+            }
     };
 
     class UserConfigMask :
@@ -540,8 +549,19 @@
 const tr1::shared_ptr<const Mask>
 PaludisEnvironment::mask_for_breakage(const PackageID & id) const
 {
-    if ((! _imp->config->accept_breaks_portage()) && id.breaks_portage())
-        return make_shared_ptr(new BreaksPortageMask);
+    if (! _imp->config->accept_all_breaks_portage())
+    {
+        tr1::shared_ptr<const Set<std::string> > breakages(id.breaks_portage());
+        if (breakages)
+        {
+            std::list<std::string> bad_breakages;
+            std::set_difference(breakages->begin(), breakages->end(),
+                     _imp->config->accept_breaks_portage().begin(), _imp->config->accept_breaks_portage().end(),
+                     std::back_inserter(bad_breakages));
+            if (! bad_breakages.empty())
+                return make_shared_ptr(new BreaksPortageMask(join(breakages->begin(), breakages->end(), " ")));
+        }
+    }
 
     return tr1::shared_ptr<const Mask>();
 }

Modified: trunk/paludis/environments/portage/portage_environment.cc
===================================================================
--- trunk/paludis/environments/portage/portage_environment.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/environments/portage/portage_environment.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -89,6 +89,9 @@
         PackageMask package_mask;
         PackageUnmask package_unmask;
 
+        std::set<std::string> ignore_breaks_portage;
+        bool ignore_all_breaks_portage;
+
         mutable Mutex hook_mutex;
         mutable bool done_hooks;
         mutable tr1::shared_ptr<Hooker> hooker;
@@ -104,6 +107,7 @@
         Implementation(Environment * const e, const std::string & s) :
             conf_dir(FSEntry(s.empty() ? "/" : s) / SYSCONFDIR),
             paludis_command("paludis"),
+            ignore_all_breaks_portage(false),
             done_hooks(false),
             overlay_importance(10),
             package_database(new PackageDatabase(e)),
@@ -264,6 +268,18 @@
                 _imp->mirrors.insert(std::make_pair(tokens.at(0), *t));
         }
     }
+
+    std::list<std::string> ignore_breaks_portage;
+    tokenise_whitespace(_imp->vars->get("PALUDIS_IGNORE_BREAKS_PORTAGE"), std::back_inserter(ignore_breaks_portage));
+    for (std::list<std::string>::const_iterator it(ignore_breaks_portage.begin()),
+             it_end(ignore_breaks_portage.end()); it_end != it; ++it)
+        if ("*" == *it)
+        {
+            _imp->ignore_all_breaks_portage = true;
+            break;
+        }
+        else
+            _imp->ignore_breaks_portage.insert(*it);
 }
 
 template<typename I_>
@@ -683,20 +699,29 @@
     class BreaksPortageMask :
         public UnsupportedMask
     {
-        char key() const
-        {
-            return 'B';
-        }
+        private:
+            std::string breakages;
 
-        const std::string description() const
-        {
-            return "breaks Portage";
-        }
+        public:
+            BreaksPortageMask(const std::string & b) :
+                breakages(b)
+            {
+            }
 
-        const std::string explanation() const
-        {
-            return "";
-        }
+            char key() const
+            {
+                return 'B';
+            }
+
+            const std::string description() const
+            {
+                return "breaks Portage";
+            }
+
+            const std::string explanation() const
+            {
+                return breakages;
+            }
     };
 
     class UserConfigMask :
@@ -717,8 +742,19 @@
 const tr1::shared_ptr<const Mask>
 PortageEnvironment::mask_for_breakage(const PackageID & id) const
 {
-    if (id.breaks_portage())
-        return make_shared_ptr(new BreaksPortageMask);
+    if (! _imp->ignore_all_breaks_portage)
+    {
+        tr1::shared_ptr<const Set<std::string> > breakages(id.breaks_portage());
+        if (breakages)
+        {
+            std::set<std::string> bad_breakages;
+            std::set_difference(breakages->begin(), breakages->end(),
+                    _imp->ignore_breaks_portage.begin(), _imp->ignore_breaks_portage.end(),
+                    std::inserter(bad_breakages, bad_breakages.end()));
+            if (! bad_breakages.empty())
+                return make_shared_ptr(new BreaksPortageMask(join(breakages->begin(), breakages->end(), " ")));
+        }
+    }
 
     return tr1::shared_ptr<const Mask>();
 }

Modified: trunk/paludis/package_id.hh
===================================================================
--- trunk/paludis/package_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/package_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -325,12 +325,12 @@
             virtual void invalidate_masks() const;
 
             /**
-             * Do we break Portage?
+             * Do we break Portage, and if so, why?
              *
              * This method may be used by Environment implementations to apply a "we don't
              * want packages that break Portage" mask.
              */
-            virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+            virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
 
             ///\}
 

Modified: trunk/paludis/repositories/cran/cran_package_id.cc
===================================================================
--- trunk/paludis/repositories/cran/cran_package_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/cran/cran_package_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -434,10 +434,12 @@
     return false;
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 CRANPackageID::breaks_portage() const
 {
-    return true;
+    tr1::shared_ptr<Set<std::string> > why(new Set<std::string>);
+    why->insert("format");
+    return why;
 }
 
 const std::string

Modified: trunk/paludis/repositories/cran/cran_package_id.hh
===================================================================
--- trunk/paludis/repositories/cran/cran_package_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/cran/cran_package_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -82,7 +82,7 @@
                 virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
                 virtual void perform_action(Action &) const PALUDIS_ATTRIBUTE((noreturn));
 
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
 
                 virtual bool arbitrary_less_than_comparison(const PackageID &) const
                     PALUDIS_ATTRIBUTE((warn_unused_result));

Modified: trunk/paludis/repositories/e/e_repository_id.cc
===================================================================
--- trunk/paludis/repositories/e/e_repository_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/e/e_repository_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -21,14 +21,19 @@
 #include <paludis/repositories/e/eapi.hh>
 #include <paludis/repositories/e/e_repository_id.hh>
 #include <paludis/util/kc.hh>
+#include <paludis/util/set.hh>
 
 using namespace paludis;
 using namespace paludis::erepository;
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 ERepositoryID::breaks_portage() const
 {
-    return (version().has_try_part() || version().has_scm_part()
-            || (! (*eapi())[k::supported()]) || (*((*eapi())[k::supported()]))[k::breaks_portage()]);
+    tr1::shared_ptr<Set<std::string> > why(new Set<std::string>);
+    if (version().has_try_part() || version().has_scm_part() || version().has_local_revision())
+        why->insert("version");
+    if ((! (*eapi())[k::supported()]) || (*((*eapi())[k::supported()]))[k::breaks_portage()])
+        why->insert("eapi");
+    return why;
 }
 

Modified: trunk/paludis/repositories/e/e_repository_id.hh
===================================================================
--- trunk/paludis/repositories/e/e_repository_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/e/e_repository_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -38,7 +38,7 @@
                 virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use_key() const = 0;
                 virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > eclass_keywords_key() const = 0;
 
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
         };
     }
 }

Modified: trunk/paludis/repositories/fake/fake_package_id.cc
===================================================================
--- trunk/paludis/repositories/fake/fake_package_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/fake/fake_package_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -920,10 +920,10 @@
     a.accept(b);
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 FakePackageID::breaks_portage() const
 {
-    return (version().has_try_part() || version().has_scm_part());
+    return tr1::shared_ptr<const Set<std::string> >();
 }
 
 const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >

Modified: trunk/paludis/repositories/fake/fake_package_id.hh
===================================================================
--- trunk/paludis/repositories/fake/fake_package_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/fake/fake_package_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -265,7 +265,7 @@
             virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
             virtual void perform_action(Action &) const;
 
-            virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+            virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
 
             virtual void invalidate_masks() const;
 

Modified: trunk/paludis/repositories/gems/gem_specification.cc
===================================================================
--- trunk/paludis/repositories/gems/gem_specification.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/gems/gem_specification.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -624,9 +624,11 @@
     PackageID::invalidate_masks();
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 GemSpecification::breaks_portage() const
 {
-    return true;
+    tr1::shared_ptr<Set<std::string> > why(new Set<std::string>);
+    why->insert("format");
+    return why;
 }
 

Modified: trunk/paludis/repositories/gems/gem_specification.hh
===================================================================
--- trunk/paludis/repositories/gems/gem_specification.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/gems/gem_specification.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -119,7 +119,7 @@
                 virtual bool arbitrary_less_than_comparison(const PackageID &) const;
                 virtual std::size_t extra_hash_value() const;
 
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
 
                 virtual void invalidate_masks() const;
         };

Modified: trunk/paludis/repositories/unpackaged/installed_id.cc
===================================================================
--- trunk/paludis/repositories/unpackaged/installed_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/unpackaged/installed_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -660,10 +660,12 @@
 {
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 InstalledUnpackagedID::breaks_portage() const
 {
-    return true;
+    tr1::shared_ptr<Set<std::string> > why(new Set<std::string>);
+    why->insert("format");
+    return why;
 }
 
 bool

Modified: trunk/paludis/repositories/unpackaged/installed_id.hh
===================================================================
--- trunk/paludis/repositories/unpackaged/installed_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/unpackaged/installed_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -82,7 +82,7 @@
                 virtual void perform_action(Action &) const;
 
                 virtual void invalidate_masks() const;
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
                 virtual bool arbitrary_less_than_comparison(const PackageID &) const
                     PALUDIS_ATTRIBUTE((warn_unused_result));
                 virtual std::size_t extra_hash_value() const

Modified: trunk/paludis/repositories/unpackaged/unpackaged_id.cc
===================================================================
--- trunk/paludis/repositories/unpackaged/unpackaged_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/unpackaged/unpackaged_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -336,10 +336,12 @@
 {
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 UnpackagedID::breaks_portage() const
 {
-    return true;
+    tr1::shared_ptr<Set<std::string> > why(new Set<std::string>);
+    why->insert("format");
+    return why;
 }
 
 bool

Modified: trunk/paludis/repositories/unpackaged/unpackaged_id.hh
===================================================================
--- trunk/paludis/repositories/unpackaged/unpackaged_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/unpackaged/unpackaged_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -80,7 +80,7 @@
                 virtual void perform_action(Action &) const;
 
                 virtual void invalidate_masks() const;
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
                 virtual bool arbitrary_less_than_comparison(const PackageID &) const
                     PALUDIS_ATTRIBUTE((warn_unused_result));
                 virtual std::size_t extra_hash_value() const

Modified: trunk/paludis/repositories/virtuals/package_id.cc
===================================================================
--- trunk/paludis/repositories/virtuals/package_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/virtuals/package_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -498,10 +498,10 @@
     PackageID::invalidate_masks();
 }
 
-bool
+tr1::shared_ptr<const Set<std::string> >
 VirtualsPackageID::breaks_portage() const
 {
-    return (version().has_try_part() || version().has_scm_part());
+    return tr1::shared_ptr<const Set<std::string> >();
 }
 
 const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >

Modified: trunk/paludis/repositories/virtuals/package_id.hh
===================================================================
--- trunk/paludis/repositories/virtuals/package_id.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/repositories/virtuals/package_id.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -113,7 +113,7 @@
                 virtual std::size_t extra_hash_value() const
                     PALUDIS_ATTRIBUTE((warn_unused_result));
 
-                virtual bool breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+                virtual tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
 
                 virtual void invalidate_masks() const;
         };

Modified: trunk/paludis/version_spec.cc
===================================================================
--- trunk/paludis/version_spec.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/version_spec.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -649,6 +649,12 @@
     return _imp->parts.end() != std::find_if(_imp->parts.begin(), _imp->parts.end(), IsPart<scm>());
 }
 
+bool
+VersionSpec::has_local_revision() const
+{
+    return 1 < std::count_if(_imp->parts.begin(), _imp->parts.end(), IsPart<revision>());
+}
+
 VersionSpec
 VersionSpec::bump() const
 {

Modified: trunk/paludis/version_spec.hh
===================================================================
--- trunk/paludis/version_spec.hh	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/version_spec.hh	2008-04-22 12:00:43 UTC (rev 4598)
@@ -167,6 +167,11 @@
              * Use is_scm() if -9999 etc is desired.
              */
             bool has_scm_part() const;
+
+            /**
+             * Do we have a local revision (-r1.2...)?
+             */
+            bool has_local_revision() const;
     };
 }
 

Modified: trunk/paludis/version_spec_TEST.cc
===================================================================
--- trunk/paludis/version_spec_TEST.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/paludis/version_spec_TEST.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -283,6 +283,35 @@
         }
     } test_version_is_scm;
 
+    /**
+     * \test VersionSpec has_*
+     *
+     */
+    struct VersionHasStuffTest : TestCase
+    {
+        VersionHasStuffTest() : TestCase("version spec has_*") {}
+
+        void run()
+        {
+            TEST_CHECK(! VersionSpec("1.2").has_scm_part());
+            TEST_CHECK(VersionSpec("1.2-scm").has_scm_part());
+            TEST_CHECK(VersionSpec("1.2-scm-r99").has_scm_part());
+            TEST_CHECK(! VersionSpec("9999").has_scm_part());
+            TEST_CHECK(VersionSpec("scm").has_scm_part());
+
+            TEST_CHECK(! VersionSpec("1").has_try_part());
+            TEST_CHECK(VersionSpec("1-try2").has_try_part());
+            TEST_CHECK(VersionSpec("1.2-try3-r4").has_try_part());
+
+            TEST_CHECK(! VersionSpec("1.2").has_local_revision());
+            TEST_CHECK(! VersionSpec("1.2-r0").has_local_revision());
+            TEST_CHECK(! VersionSpec("1.2-r3").has_local_revision());
+            TEST_CHECK(VersionSpec("1.2-r3.0").has_local_revision());
+            TEST_CHECK(VersionSpec("1.2-r3.4").has_local_revision());
+            TEST_CHECK(VersionSpec("1.2-r3.4.5").has_local_revision());
+        }
+    } test_version_has_stuff;
+
     struct VersionSpecHashTest : TestCase
     {
         VersionSpecHashTest() : TestCase("version spec hash_value()") { }

Modified: trunk/ruby/package_id.cc
===================================================================
--- trunk/ruby/package_id.cc	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/ruby/package_id.cc	2008-04-22 12:00:43 UTC (rev 4598)
@@ -230,22 +230,34 @@
     }
 
     /*
-     * Document-method: masked?
-     *
      * call-seq:
-     *     masked? -> true or false
+     *     breaks_portage -> [:reason, :reason, ...]
      *
-     * Do we have any masks?
+     *  Do we break Portage, and if so, why?
+     *
+     *  This method may be used by Environment implementations to apply a "we don't want packages that break Portage" mask.
      */
+    VALUE
+    package_id_breaks_portage(VALUE self)
+    {
+        VALUE result(rb_ary_new());
+        tr1::shared_ptr<const PackageID> * self_ptr;
+        Data_Get_Struct(self, tr1::shared_ptr<const PackageID>, self_ptr);
+        tr1::shared_ptr<const Set<std::string> > breakages((*self_ptr)->breaks_portage());
+        if (breakages)
+            for (Set<std::string>::ConstIterator it(breakages->begin()),
+                     it_end(breakages->end()); it_end != it; ++it)
+                rb_ary_push(result, ID2SYM(rb_intern(it->c_str())));
+        return result;
+    }
+
     /*
-     * Document-method: breaks_portage?
+     * Document-method: masked?
      *
      * call-seq:
-     *     breaks_portage? -> true or false
+     *     masked? -> true or false
      *
-     *  Do we break Portage?
-     *
-     *  This method may be used by Environment implementations to apply a "we don't want packages that break Portage" mask.
+     * Do we have any masks?
      */
     template <bool (PackageID::* m_) () const>
     struct PackageIDBool
@@ -431,7 +443,7 @@
         rb_define_method(c_package_id, "masks", RUBY_FUNC_CAST(&package_id_masks), 0);
         rb_define_method(c_package_id, "masked?", RUBY_FUNC_CAST((&PackageIDBool<&PackageID::masked>::fetch)), 0);
         rb_define_method(c_package_id, "invalidate_masks", RUBY_FUNC_CAST(&package_id_invalidate_masks), 0);
-        rb_define_method(c_package_id, "breaks_portage?", RUBY_FUNC_CAST((&PackageIDBool<&PackageID::breaks_portage>::fetch)), 0);
+        rb_define_method(c_package_id, "breaks_portage", RUBY_FUNC_CAST(&package_id_breaks_portage), 0);
 
         rb_define_method(c_package_id, "virtual_for_key", RUBY_FUNC_CAST((&KeyValue<MetadataValueKey<tr1::shared_ptr<const PackageID> > , &PackageID::virtual_for_key>::fetch)), 0);
         rb_define_method(c_package_id, "keywords_key", RUBY_FUNC_CAST((&KeyValue<MetadataCollectionKey<KeywordNameSet>,&PackageID::keywords_key>::fetch)), 0);

Modified: trunk/ruby/package_id_TEST.rb
===================================================================
--- trunk/ruby/package_id_TEST.rb	2008-04-22 07:43:10 UTC (rev 4597)
+++ trunk/ruby/package_id_TEST.rb	2008-04-22 12:00:43 UTC (rev 4598)
@@ -172,8 +172,8 @@
             assert !pid_installed.masked?
         end
 
-        def test_breaks_portage?
-            assert !pid_testrepo.breaks_portage?
+        def test_breaks_portage
+            assert pid_testrepo.breaks_portage.empty?
         end
 
         def test_masks



More information about the paludis-commits mailing list