aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-17 21:06:37 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-17 21:06:37 +0000
commitbeb64c91af4fd4d8cca54ed8b2f940d832810f33 (patch)
tree72780cf838f36499a8e54eda9c86abcb0bbb6219
parentd4b1c1e4aabdd2cfceb3efa72ebd9ce9c545bd56 (diff)
downloadpaludis-beb64c91af4fd4d8cca54ed8b2f940d832810f33.tar.gz
paludis-beb64c91af4fd4d8cca54ed8b2f940d832810f33.tar.xz
Handle ebuilds with really broken metadata more gracefully
-rw-r--r--paludis/ebuild.cc47
-rw-r--r--paludis/portage_repository_TEST.cc35
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh7
3 files changed, 69 insertions, 20 deletions
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index aec5314..8810cf8 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -163,23 +163,35 @@ EbuildMetadataCommand::do_run_command(const std::string & cmd)
KeyValueConfigFile f(&prog);
_metadata.assign(new VersionMetadata::Ebuild(PortageDepParser::parse_depend));
- _metadata->get<vm_deps>().set<vmd_build_depend_string>(f.get("DEPEND"));
- _metadata->get<vm_deps>().set<vmd_run_depend_string>(f.get("RDEPEND"));
- _metadata->set<vm_slot>(SlotName(f.get("SLOT")));
- _metadata->get_ebuild_interface()->set<evm_src_uri>(f.get("SRC_URI"));
- _metadata->get_ebuild_interface()->set<evm_restrict>(f.get("RESTRICT"));
- _metadata->set<vm_homepage>(f.get("HOMEPAGE"));
- _metadata->set<vm_license>(f.get("LICENSE"));
- _metadata->set<vm_description>(f.get("DESCRIPTION"));
- _metadata->get_ebuild_interface()->set<evm_keywords>(f.get("KEYWORDS"));
- _metadata->get_ebuild_interface()->set<evm_inherited>(f.get("INHERITED"));
- _metadata->get_ebuild_interface()->set<evm_iuse>(f.get("IUSE"));
- _metadata->get<vm_deps>().set<vmd_post_depend_string>(f.get("PDEPEND"));
- _metadata->get_ebuild_interface()->set<evm_provide>(f.get("PROVIDE"));
- _metadata->set<vm_eapi>(f.get("EAPI"));
- _metadata->get_ebuild_interface()->set<evm_virtual>("");
-
- if (prog.exit_status())
+ bool ok(false);
+ try
+ {
+ _metadata->get<vm_deps>().set<vmd_build_depend_string>(f.get("DEPEND"));
+ _metadata->get<vm_deps>().set<vmd_run_depend_string>(f.get("RDEPEND"));
+ _metadata->set<vm_slot>(SlotName(f.get("SLOT")));
+ _metadata->get_ebuild_interface()->set<evm_src_uri>(f.get("SRC_URI"));
+ _metadata->get_ebuild_interface()->set<evm_restrict>(f.get("RESTRICT"));
+ _metadata->set<vm_homepage>(f.get("HOMEPAGE"));
+ _metadata->set<vm_license>(f.get("LICENSE"));
+ _metadata->set<vm_description>(f.get("DESCRIPTION"));
+ _metadata->get_ebuild_interface()->set<evm_keywords>(f.get("KEYWORDS"));
+ _metadata->get_ebuild_interface()->set<evm_inherited>(f.get("INHERITED"));
+ _metadata->get_ebuild_interface()->set<evm_iuse>(f.get("IUSE"));
+ _metadata->get<vm_deps>().set<vmd_post_depend_string>(f.get("PDEPEND"));
+ _metadata->get_ebuild_interface()->set<evm_provide>(f.get("PROVIDE"));
+ _metadata->set<vm_eapi>(f.get("EAPI"));
+ _metadata->get_ebuild_interface()->set<evm_virtual>("");
+
+ if (prog.exit_status())
+ ok = true;
+ }
+ catch (const NameError &)
+ {
+ }
+
+ if (ok)
+ return true;
+ else
{
Log::get_instance()->message(ll_warning, "Could not generate cache for '"
+ stringify(*params.get<ecpk_db_entry>()) + "'");
@@ -187,7 +199,6 @@ EbuildMetadataCommand::do_run_command(const std::string & cmd)
return false;
}
- return true;
}
std::string
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index e94dc64..57acd5f 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -530,6 +530,41 @@ namespace test_cases
} test_portage_repository_metadata_uncached;
/**
+ * \test Test PortageRepository unparsable metadata.
+ *
+ * \ingroup grptestcases
+ */
+ struct PortageRepositoryMetadataUnparsableTest : TestCase
+ {
+ PortageRepositoryMetadataUnparsableTest() : TestCase("metadata unparsable") { }
+
+ bool skip() const
+ {
+ return ! getenv_with_default("SANDBOX_ON", "").empty();
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo7"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo7/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ for (int pass = 1 ; pass <= 2 ; ++pass)
+ {
+ TestMessageSuffix pass_suffix(stringify(pass), true);
+ VersionMetadata::ConstPointer m(0);
+
+ m = repo->version_metadata(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("1"));
+ TEST_CHECK_EQUAL(m->get<vm_eapi>(), "UNKNOWN");
+ }
+ }
+ } test_portage_repository_metadata_unparsable;
+
+ /**
* \test Test PortageRepository query_use and query_use_mask functions.
*
* \ingroup grptestcases
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 30b5d95..d63ad62 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -115,8 +115,8 @@ cd ..
mkdir -p repo7/{eclass,distfiles,profiles/profile} || exit 1
-mkdir -p repo7/cat-one/pkg-one || exit 1
-mkdir -p repo7/metadata/cache/cat-one
+mkdir -p repo7/cat-one/pkg-{one,two} || exit 1
+mkdir -p repo7/metadata/cache/cat-{one,two}
cd repo7 || exit 1
echo "test-repo-7" > profiles/repo_name || exit 1
cat <<END > profiles/categories || exit 1
@@ -134,6 +134,9 @@ IUSE=""
LICENSE="GPL-2"
KEYWORDS="test"
END
+cat <<END > cat-one/pkg-two/pkg-two-1.ebuild || exit 1
+i am a fish
+END
cd ..