aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-14 18:15:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-14 18:15:21 +0000
commit922d4d57968498b322198de49c675423a21790d4 (patch)
tree1f561cbf870821802c38cdaf41cd2fc2b94c46c6
parent2c2aafa16c3a66ee694558aec048aceca5ea2f98 (diff)
downloadpaludis-922d4d57968498b322198de49c675423a21790d4.tar.gz
paludis-922d4d57968498b322198de49c675423a21790d4.tar.xz
More CRAN work
-rw-r--r--paludis/repositories/cran/cran_package_id.cc67
-rw-r--r--paludis/repositories/cran/keys.cc65
-rw-r--r--paludis/repositories/cran/keys.hh29
3 files changed, 67 insertions, 94 deletions
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index 07a9847..612f7de 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -63,9 +63,10 @@ namespace paludis
VersionSpec version;
tr1::shared_ptr<LiteralMetadataFSEntryKey> fs_location_key;
- tr1::shared_ptr<SimpleURIKey> homepage_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> url_key;
tr1::shared_ptr<LiteralMetadataStringKey> short_description_key;
tr1::shared_ptr<LiteralMetadataStringKey> long_description_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> license_key;
tr1::shared_ptr<PackageIDKey> contained_in_key;
tr1::shared_ptr<PackageIDSequenceKey> contains_key;
tr1::shared_ptr<DepKey> depends_key;
@@ -149,11 +150,20 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
_imp->version = VersionSpec(cran_version_to_internal(file.get("Version")));
}
+ if (! file.get("License").empty())
+ {
+ /* License often isn't in the format the spec requires, so we can't parse it. */
+ Context local_context("When handling License: key:");
+ _imp->license_key.reset(new LiteralMetadataStringKey("License", "License", mkt_dependencies, file.get("License")));
+ add_metadata_key(_imp->license_key);
+ }
+
if (! file.get("URL").empty())
{
+ /* URL is also in stupid formats */
Context local_context("When handling URL: key:");
- _imp->homepage_key.reset(new SimpleURIKey("URL", "URL", file.get("URL"), mkt_significant));
- add_metadata_key(_imp->homepage_key);
+ _imp->url_key.reset(new LiteralMetadataStringKey("URL", "URL", mkt_significant, file.get("URL")));
+ add_metadata_key(_imp->url_key);
}
if (! file.get("Title").empty())
@@ -176,16 +186,23 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
mkt_normal, file.get("BundleDescription")));
}
+ if (! file.get("Date").empty())
+ {
+ Context local_context("When handling Date: key:");
+ /* no guarantee on the format */
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Date", "Date", mkt_normal, file.get("Date"))));
+ }
+
if (! file.get("Author").empty())
{
Context local_context("When handling Author: key:");
- add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Author", "Author", mkt_normal, file.get("Author"))));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Author", "Author", mkt_author, file.get("Author"))));
}
if (! file.get("Maintainer").empty())
{
Context local_context("When handling Maintainer: key:");
- add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Maintainer", "Maintainer", mkt_normal, file.get("Maintainer"))));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Maintainer", "Maintainer", mkt_author, file.get("Maintainer"))));
}
if (! file.get("Contains").empty())
@@ -216,6 +233,13 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
add_metadata_key(_imp->suggests_key);
}
+ if (! file.get("SystemRequirements").empty())
+ {
+ Context local_context("When handling SystemRequirements: key:");
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("SystemRequirements", "System Requirements", mkt_normal,
+ file.get("SystemRequirements"))));
+ }
+
if (! file.get("Depends").empty())
{
Context local_context("When handling Depends: key:");
@@ -231,37 +255,6 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
<< e.message() << "' (" << e.what() << ")";
add_mask(make_shared_ptr(new BrokenMask('B', "Broken", "Got exception '" + stringify(e.message()) + "' (" + e.what() + "')")));
}
-
-#if 0
- for (cranrepository::DescriptionFile::Iterator i(file.begin()), i_end(file.end()) ;
- i != i_end ; ++i)
- {
- if (("Package" == key) || ("Bundle" == key))
- {
- metadata->set_homepage("http://cran.r-project.org/src/contrib/Descriptions/" + value + ".html");
- if ("Package" == key)
- {
- CRANDescription::normalise_name(value);
- if (n != value)
- Log::get_instance()->message(ll_warning, lc_context) << "Inconsistent package name in file '" <<
- f << "': '" << value << "'";
- }
- else
- metadata->cran_interface->is_bundle = true;
- }
- else if ("Depends" == key)
- {
- if (value.empty())
- value = "R";
- else
- value.append(", R");
- metadata->deps_interface->set_build_depend(value);
- metadata->deps_interface->set_run_depend(value);
- }
- else if ("Suggests" == key)
- metadata->deps_interface->set_suggested_depend(value);
- }
-#endif
}
CRANPackageID::CRANPackageID(const Environment * const e,
@@ -370,7 +363,7 @@ CRANPackageID::fetches_key() const
const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >
CRANPackageID::homepage_key() const
{
- return _imp->homepage_key;
+ return tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >();
}
const tr1::shared_ptr<const MetadataStringKey>
diff --git a/paludis/repositories/cran/keys.cc b/paludis/repositories/cran/keys.cc
index e49fadd..a195802 100644
--- a/paludis/repositories/cran/keys.cc
+++ b/paludis/repositories/cran/keys.cc
@@ -35,30 +35,6 @@
using namespace paludis;
using namespace paludis::cranrepository;
-SimpleURIKey::SimpleURIKey(const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
- MetadataSpecTreeKey<SimpleURISpecTree>(r, h, t),
- _v(v)
-{
-}
-
-const tr1::shared_ptr<const SimpleURISpecTree::ConstItem>
-SimpleURIKey::value() const
-{
- return make_shared_ptr(new TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>(make_shared_ptr(new SimpleURIDepSpec(_v))));
-}
-
-std::string
-SimpleURIKey::pretty_print(const SimpleURISpecTree::ItemFormatter & f) const
-{
- return f.format(_v, format::Plain());
-}
-
-std::string
-SimpleURIKey::pretty_print_flat(const SimpleURISpecTree::ItemFormatter & f) const
-{
- return f.format(_v, format::Plain());
-}
-
PackageIDSequenceKey::PackageIDSequenceKey(const Environment * const e,
const std::string & r, const std::string & h, const MetadataKeyType t) :
MetadataCollectionKey<PackageIDSequence>(r, h, t),
@@ -102,31 +78,54 @@ PackageIDKey::value() const
return _v->shared_from_this();
}
+namespace paludis
+{
+ template <>
+ struct Implementation<DepKey>
+ {
+ const Environment * const env;
+ const std::string v;
+
+ mutable Mutex mutex;
+ mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> c;
+
+ Implementation(const Environment * const e, const std::string & vv) :
+ env(e),
+ v(vv)
+ {
+ }
+ };
+}
+
DepKey::DepKey(const Environment * const e, const std::string & r, const std::string & h, const std::string & v,
const MetadataKeyType t) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
- _env(e),
- _v(v)
+ PrivateImplementationPattern<DepKey>(new Implementation<DepKey>(e, v)),
+ _imp(PrivateImplementationPattern<DepKey>::_imp)
+{
+}
+
+DepKey::~DepKey()
{
}
const tr1::shared_ptr<const DependencySpecTree::ConstItem>
DepKey::value() const
{
- Lock l(_m);
- if (_c)
- return _c;
+ Lock l(_imp->mutex);
+ if (_imp->c)
+ return _imp->c;
Context context("When parsing CRAN dependency string:");
- _c = parse_depends(_v);
- return _c;
+ _imp->c = parse_depends(_imp->v);
+ return _imp->c;
}
std::string
DepKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_env, ff, 12, true);
+ DepSpecPrettyPrinter p(_imp->env, ff, 12, true);
value()->accept(p);
return stringify(p);
}
@@ -135,7 +134,7 @@ std::string
DepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_env, ff, 0, false);
+ DepSpecPrettyPrinter p(_imp->env, ff, 0, false);
value()->accept(p);
return stringify(p);
}
diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh
index bc23d14..a77d39c 100644
--- a/paludis/repositories/cran/keys.hh
+++ b/paludis/repositories/cran/keys.hh
@@ -31,25 +31,6 @@ namespace paludis
{
class CRANPackageID;
- class SimpleURIKey :
- public MetadataSpecTreeKey<SimpleURISpecTree>
- {
- private:
- const std::string _v;
-
- public:
- SimpleURIKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType);
-
- virtual const tr1::shared_ptr<const SimpleURISpecTree::ConstItem> value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual std::string pretty_print(const SimpleURISpecTree::ItemFormatter &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual std::string pretty_print_flat(const SimpleURISpecTree::ItemFormatter &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
class PackageIDSequenceKey :
public MetadataCollectionKey<PackageIDSequence>
{
@@ -84,18 +65,18 @@ namespace paludis
};
class DepKey :
- public MetadataSpecTreeKey<DependencySpecTree>
+ public MetadataSpecTreeKey<DependencySpecTree>,
+ private PrivateImplementationPattern<DepKey>
{
private:
- const Environment * const _env;
- mutable Mutex _m;
- mutable tr1::shared_ptr<DependencySpecTree::ConstItem> _c;
- const std::string _v;
+ PrivateImplementationPattern<DepKey>::ImpPtr & _imp;
public:
DepKey(const Environment * const,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ ~DepKey();
+
virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));