aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-18 15:18:46 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-18 15:18:46 +0000
commitdd0820356f45523b8fed9f3d415a6c0b0075fcb7 (patch)
treeea4df42f73b76124ca8e5bbe43becd0e7aaf3b5a
parent505d94eaee9b6a3cabf78393115dc8d95353fbe7 (diff)
downloadpaludis-dd0820356f45523b8fed9f3d415a6c0b0075fcb7.tar.gz
paludis-dd0820356f45523b8fed9f3d415a6c0b0075fcb7.tar.xz
Ignore any weird version specs with a warning, rather than bombing out.
-rw-r--r--paludis/portage_repository.cc28
-rw-r--r--paludis/portage_repository_TEST.cc37
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh30
3 files changed, 86 insertions, 9 deletions
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 6dfa976..f494d27 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -620,16 +620,26 @@ PortageRepository::need_version_names(const QualifiedPackageName & n) const
}
}
else
- std::copy(DirIterator(path), DirIterator(),
- filter_inserter(
- transform_inserter(
- transform_inserter(
- transform_inserter(v->inserter(),
- StripTrailingString(".ebuild")),
- StripLeadingString(stringify(n.get<qpn_package>()) + "-")),
- std::mem_fun_ref(&FSEntry::basename)),
- IsFileWithExtension(stringify(n.get<qpn_package>()) + "-", ".ebuild")));
+ {
+ for (DirIterator e(path), e_end ; e != e_end ; ++e)
+ {
+ if (! IsFileWithExtension(stringify(n.get<qpn_package>()) + "-", ".ebuild")(*e))
+ continue;
+ try
+ {
+ v->insert(strip_leading_string(
+ strip_trailing_string(e->basename(), ".ebuild"),
+ stringify(n.get<qpn_package>()) + "-"));
+ }
+ catch (const NameError &)
+ {
+ Log::get_instance()->message(ll_warning, "Skipping entry '"
+ + stringify(*e) + "' for '" + stringify(n) + "' in repository '"
+ + stringify(name()) + "'");
+ }
+ }
+ }
_imp->version_specs.insert(std::make_pair(n, v));
_imp->package_names[n] = true;
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index 243319a..ce718f7 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -360,6 +360,43 @@ namespace test_cases
}
} test_portage_repository_versions;
+ struct PortageRepositoryDuffVersionsTest : TestCase
+ {
+ PortageRepositoryDuffVersionsTest() : TestCase("duff versions") { }
+
+ 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/repo8"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo8/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);
+
+ VersionSpecCollection::ConstPointer versions(0);
+
+ versions = repo->version_specs(QualifiedPackageName("cat-one/pkg-one"));
+ TEST_CHECK(! versions->empty());
+ TEST_CHECK_EQUAL(2, std::distance(versions->begin(), versions->end()));
+ TEST_CHECK(versions->end() != versions->find(VersionSpec("1")));
+ TEST_CHECK(versions->end() != versions->find(VersionSpec("1.1-r1")));
+ TEST_CHECK(versions->end() == versions->find(VersionSpec("2")));
+
+ versions = repo->version_specs(QualifiedPackageName("cat-one/pkg-neither"));
+ TEST_CHECK(versions->empty());
+ TEST_CHECK_EQUAL(0, std::distance(versions->begin(), versions->end()));
+ TEST_CHECK(versions->end() == versions->find(VersionSpec("1")));
+ TEST_CHECK(versions->end() == versions->find(VersionSpec("1.1-r1")));
+ TEST_CHECK(versions->end() == versions->find(VersionSpec("2")));
+ }
+ }
+ } test_portage_repository_duff_versions;
+
struct PortageRepositoryMetadataCachedTest : TestCase
{
PortageRepositoryMetadataCachedTest() : TestCase("metadata cached") { }
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 5a667dd..4c67384 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -137,3 +137,33 @@ END
cd ..
+mkdir -p repo8/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo8/{cat-one/{pkg-one,pkg-both},cat-two/{pkg-two,pkg-both}} || exit 1
+cd repo8 || exit 1
+echo "test-repo-8" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+cat-two
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-one/pkg-one-1-monkey.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.1-r1.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-both/pkg-both-3.45.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-both/pkg-both-3.45_r1.ebuild || exit 1
+END
+cat <<END > cat-two/pkg-two/pkg-two-2.ebuild || exit 1
+END
+cat <<END > cat-two/pkg-both/pkg-both-1.23.ebuild || exit 1
+END
+cat <<END > cat-two/pkg-both/pkg-both-.ebuild || exit 1
+END
+cd ..
+
+