aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-23 00:15:06 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-23 00:15:06 +0000
commit0975d014c1afcc3b5217fe76db2f6205ee8e1be3 (patch)
treefd59670fac037bdd4bdb888e88043ee6f509c2ca
parent97f0c87df64c8f820c4fb959631ef6e49cfbbc6e (diff)
downloadpaludis-0975d014c1afcc3b5217fe76db2f6205ee8e1be3.tar.gz
paludis-0975d014c1afcc3b5217fe76db2f6205ee8e1be3.tar.xz
Per-package use.mask support
-rw-r--r--paludis/fake_repository.cc2
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc56
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/portage_repository_TEST.cc40
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh25
-rw-r--r--paludis/repository.hh8
-rw-r--r--paludis/vdb_repository.cc2
-rw-r--r--paludis/vdb_repository.hh2
-rw-r--r--src/install.cc2
10 files changed, 127 insertions, 14 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 64dcf9b..eb593eb 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -193,7 +193,7 @@ FakeRepository::do_query_use(const UseFlagName &, const PackageDatabaseEntry *)
}
bool
-FakeRepository::do_query_use_mask(const UseFlagName &) const
+FakeRepository::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const
{
return false;
}
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 5a25aa8..a816dfc 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -69,7 +69,7 @@ namespace paludis
virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool do_is_arch_flag(const UseFlagName &) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index af2e5c8..7d8144b 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -84,6 +84,9 @@ namespace paludis
/// Map for USE masking.
typedef MakeHashedSet<UseFlagName>::Type UseMaskSet;
+ /// Map for package USE masking.
+ typedef MakeHashedMap<QualifiedPackageName, std::list<std::pair<PackageDepAtom::ConstPointer, UseFlagName> > >::Type PackageUseMaskMap;
+
/// Map for USE flag sets.
typedef MakeHashedSet<UseFlagName>::Type UseFlagSet;
@@ -161,6 +164,9 @@ namespace paludis
/// Use mask.
mutable UseMaskSet use_mask;
+ /// Package use mask.
+ mutable PackageUseMaskMap package_use_mask;
+
/// Use.
mutable UseMap use;
@@ -340,6 +346,34 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
use_mask.insert(UseFlagName(*line));
}
+ if ((f / "package.use.mask").exists())
+ {
+ Context context_local("When reading package use.mask file:");
+
+ LineConfigFile package_use_mask_f(f / "package.use.mask");
+ for (LineConfigFile::Iterator line(package_use_mask_f.begin()), line_end(package_use_mask_f.end());
+ line != line_end; ++line)
+ {
+ std::deque<std::string> tokens;
+ tokeniser.tokenise(*line, std::back_inserter(tokens));
+ if (tokens.size() < 2)
+ continue;
+
+ std::deque<std::string>::iterator t=tokens.begin(), t_end=tokens.end();
+ PackageDepAtom::ConstPointer d(new PackageDepAtom(*t++));
+ QualifiedPackageName p(d->package());
+
+ PackageUseMaskMap::iterator i = package_use_mask.find(p);
+ if (package_use_mask.end() == i)
+ i = package_use_mask.insert(make_pair(p, std::list<std::pair<PackageDepAtom::ConstPointer, UseFlagName> >())).first;
+
+ for ( ; t != t_end; ++t)
+ {
+ (*i).second.push_back(std::make_pair(d, UseFlagName(*t)));
+ }
+ }
+ }
+
if ((f / "virtuals").exists())
{
Context context_local("When reading virtuals file:");
@@ -875,7 +909,7 @@ PortageRepository::do_query_profile_masks(const CategoryNamePart &,
}
UseFlagState
-PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry *) const
+PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry *e) const
{
if (! _imp->has_profile)
{
@@ -885,7 +919,7 @@ PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntr
}
UseMap::iterator p(_imp->use.end());
- if (query_use_mask(f))
+ if (query_use_mask(f, e))
return use_disabled;
else if (_imp->use.end() == ((p = _imp->use.find(f))))
return use_unspecified;
@@ -894,7 +928,7 @@ PortageRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntr
}
bool
-PortageRepository::do_query_use_mask(const UseFlagName & u) const
+PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabaseEntry *e) const
{
if (! _imp->has_profile)
{
@@ -903,7 +937,21 @@ PortageRepository::do_query_use_mask(const UseFlagName & u) const
_imp->has_profile = true;
}
- return _imp->use_mask.end() != _imp->use_mask.find(u);
+ if (_imp->use_mask.end() != _imp->use_mask.find(u))
+ return true;
+
+ PackageUseMaskMap::iterator it = _imp->package_use_mask.find(e->get<pde_name>());
+ if (_imp->package_use_mask.end() == it)
+ return false;
+
+ for (std::list<std::pair<PackageDepAtom::ConstPointer, UseFlagName> >::iterator i = it->second.begin(),
+ i_end = it->second.end(); i != i_end; ++i)
+ {
+ if (match_package(_imp->env, i->first, e) && u == i->second)
+ return true;
+ }
+
+ return false;
}
void
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 11eb43b..8ee88da 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -137,7 +137,7 @@ namespace paludis
virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool do_is_arch_flag(const UseFlagName &) const;
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index f987bd4..ec3af72 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -522,5 +522,45 @@ namespace test_cases
}
}
} test_portage_repository_metadata_uncached;
+
+ /**
+ * \test Test PortageRepository query_use and query_use_mask functions.
+ *
+ * \ingroup grptestcases
+ */
+ struct PortageRepositoryQueryUseTest : TestCase
+ {
+ PortageRepositoryQueryUseTest() : TestCase("USE query") { }
+
+ 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/repo9"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo9/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);
+
+ PackageDatabaseEntry p1(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p2(QualifiedPackageName("cat-two/pkg-two"), VersionSpec("1"), RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p3(QualifiedPackageName("cat-one/pkg-none"), VersionSpec("1"), RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p4(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"), RepositoryName("test-repo-9"));
+
+ TEST_CHECK(repo->query_use(UseFlagName("flag1"), &p1) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag2"), &p1) == use_disabled);
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), &p1));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag2"), &p3));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), &p2));
+ TEST_CHECK(! repo->query_use_mask(UseFlagName("flag3"), &p1));
+ TEST_CHECK(repo->query_use_mask(UseFlagName("flag3"), &p4));
+ TEST_CHECK(repo->query_use(UseFlagName("flag3"), &p1) == use_enabled);
+ }
+ }
+ } test_portage_repository_query_use;
}
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 4c67384..78b6536 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -167,3 +167,28 @@ END
cd ..
+mkdir -p repo9/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo9/{cat-one/pkg-one,cat-two/pkg-two} || exit 1
+cd repo9 || exit 1
+echo "test-repo-9" > profiles/repo_name || exit 1
+cat <<END >profiles/categories || exit 1
+cat-one
+cat-two
+END
+cat <<END >profiles/profile/make.defaults || exit 1
+ARCH=test
+USE="flag1 flag2 flag3"
+END
+cat <<END >profiles/profile/use.mask || exit 1
+flag2
+END
+cat <<END >profiles/profile/package.use.mask || exit 1
+cat-two/pkg-two flag3
+>=cat-one/pkg-one-2 flag3
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
+END
+cat <<END > cat-one/pkg-one/pkg-one-2.ebuild || exit 1
+cat <<END > cat-two/pkg-two/pkg-two-1.ebuild || exit 1
+END
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 6b4d287..197e066 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -165,7 +165,7 @@ namespace paludis
/**
* Override in descendents: get use mask.
*/
- virtual bool do_query_use_mask(const UseFlagName &) const = 0;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
* Override in descendents: is this an arch flag?
@@ -378,7 +378,7 @@ namespace paludis
*/
UseFlagState query_use(const UseFlagName & u, const PackageDatabaseEntry *pde) const
{
- if (do_query_use_mask(u))
+ if (do_query_use_mask(u, pde))
return use_disabled;
else
return do_query_use(u, pde);
@@ -387,9 +387,9 @@ namespace paludis
/**
* Query whether the specified use flag is masked.
*/
- bool query_use_mask(const UseFlagName & u) const
+ bool query_use_mask(const UseFlagName & u, const PackageDatabaseEntry *pde) const
{
- return do_query_use_mask(u);
+ return do_query_use_mask(u, pde);
}
/**
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index c2158af..80eca26 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -519,7 +519,7 @@ VDBRepository::do_query_use(const UseFlagName & f, const PackageDatabaseEntry *
}
bool
-VDBRepository::do_query_use_mask(const UseFlagName &) const
+VDBRepository::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const
{
return false;
}
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index a0ab204..8110494 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -116,7 +116,7 @@ namespace paludis
virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
- virtual bool do_query_use_mask(const UseFlagName &) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool do_is_arch_flag(const UseFlagName &) const;
diff --git a/src/install.cc b/src/install.cc
index 6322a97..3949de5 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -257,7 +257,7 @@ do_install()
if (env->query_use(*i, &p))
cout << " " << colour(cl_flag_on, *i);
else if (env->package_database()->fetch_repository(
- dep->get<p::dle_repository>())->query_use_mask(*i))
+ dep->get<p::dle_repository>())->query_use_mask(*i, &p))
cout << " " << colour(cl_flag_off, "(-" + p::stringify(*i) + ")");
else
cout << " " << colour(cl_flag_off, "-" + p::stringify(*i));