aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-05-06 01:00:45 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-05-06 01:00:45 +0000
commitabca94a068ec3a1051d887ba4c8a5248533b20d2 (patch)
tree69ed6863ab0ab086b9064707c7d02923e3dba436
parent07b9024ca9121911654b1325aac5058931e0f50a (diff)
downloadpaludis-abca94a068ec3a1051d887ba4c8a5248533b20d2.tar.gz
paludis-abca94a068ec3a1051d887ba4c8a5248533b20d2.tar.xz
use.force, package.use.force support
-rw-r--r--paludis/fake_repository.cc6
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc94
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/portage_repository_TEST.cc3
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh8
-rw-r--r--paludis/repository.hh15
-rw-r--r--paludis/vdb_repository.cc6
-rw-r--r--paludis/vdb_repository.hh2
9 files changed, 136 insertions, 2 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 3038f68..47c671c 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -208,6 +208,12 @@ FakeRepository::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntr
}
bool
+FakeRepository::do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const
+{
+ return false;
+}
+
+bool
FakeRepository::do_is_arch_flag(const UseFlagName &) const
{
return false;
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 1e8dece..dcdb44d 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -75,6 +75,8 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+
virtual bool do_is_arch_flag(const UseFlagName &) const;
virtual bool do_is_expand_flag(const UseFlagName &) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 1c3993e..ca53f3e 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -175,6 +175,12 @@ namespace paludis
/// Package use mask.
mutable PackageUseMaskMap package_use_mask;
+ /// Use force.
+ mutable UseMaskSet use_force;
+
+ /// Package use force.
+ mutable PackageUseMaskMap package_use_force;
+
/// Use.
mutable UseMap use;
@@ -388,6 +394,49 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
}
}
+ if ((f / "use.force").exists())
+ {
+ Context context_local("When reading use.force file:");
+
+ LineConfigFile use_force_f(f / "use.force");
+ for (LineConfigFile::Iterator line(use_force_f.begin()), line_end(use_force_f.end());
+ line != line_end; ++line)
+ {
+ if ('-' == line->at(0))
+ use_force.erase(UseFlagName(line->substr(1)));
+ else
+ use_force.insert(UseFlagName(*line));
+ }
+ }
+
+ if ((f / "package.use.force").exists())
+ {
+ Context context_local("When reading package use.force file:");
+
+ LineConfigFile package_use_force_f(f / "package.use.force");
+ for (LineConfigFile::Iterator line(package_use_force_f.begin()), line_end(package_use_force_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_force.find(p);
+ if (package_use_force.end() == i)
+ i = package_use_force.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:");
@@ -972,7 +1021,49 @@ PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabas
if (_imp->package_use_mask.end() == it)
return false;
- for (std::list<std::pair<PackageDepAtom::ConstPointer, UseFlagName> >::iterator i = it->second.begin(),
+ for (std::list<std::pair<PackageDepAtom::ConstPointer, UseFlagName> >::iterator i = it->second.begin(),
+ i_end = it->second.end(); i != i_end; ++i)
+ {
+ static bool recursive(false);
+ if (recursive)
+ {
+ if (i->first->use_requirements_ptr())
+ continue;
+ if (match_package(_imp->env, i->first, e) && u == i->second)
+ return true;
+ }
+ else
+ {
+ Save<bool> save_recursive(&recursive, true);
+ if (match_package(_imp->env, i->first, e) && u == i->second)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+PortageRepository::do_query_use_force(const UseFlagName & u, const PackageDatabaseEntry *e) const
+{
+ if (! _imp->has_profile)
+ {
+ Context context("When checking USE force for '" + stringify(u) + "':");
+ _imp->add_profile(_imp->profile.realpath());
+ _imp->has_profile = true;
+ }
+
+ if (_imp->use_force.end() != _imp->use_force.find(u))
+ return true;
+
+ if (0 == e)
+ return false;
+
+ PackageUseMaskMap::iterator it = _imp->package_use_force.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)
{
static bool recursive(false);
@@ -994,6 +1085,7 @@ PortageRepository::do_query_use_mask(const UseFlagName & u, const PackageDatabas
return false;
}
+
void
PortageRepository::need_virtual_names() const
{
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 91c3bf1..17be931 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -149,6 +149,8 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+
virtual bool do_is_arch_flag(const UseFlagName &) const;
virtual bool do_is_expand_flag(const UseFlagName &) const;
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index 899496a..6e99f1b 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -565,6 +565,9 @@ namespace test_cases
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_CHECK(repo->query_use(UseFlagName("flag4"), &p3) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag5"), &p2) == use_enabled);
+ TEST_CHECK(repo->query_use(UseFlagName("flag5"), &p1) == use_disabled);
}
}
} test_portage_repository_query_use;
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 78b6536..30b5d95 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -177,15 +177,21 @@ cat-two
END
cat <<END >profiles/profile/make.defaults || exit 1
ARCH=test
-USE="flag1 flag2 flag3"
+USE="flag1 flag2 flag3 -flag4 -flag5"
END
cat <<END >profiles/profile/use.mask || exit 1
flag2
END
+cat <<END >profiles/profile/use.force || exit 1
+flag4
+END
cat <<END >profiles/profile/package.use.mask || exit 1
cat-two/pkg-two flag3
>=cat-one/pkg-one-2 flag3
END
+cat <<END >profiles/profile/package.use.force || exit 1
+cat-two/pkg-two flag5
+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
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 18bdb6c..7164b6b 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -176,6 +176,11 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
+ * Override in descendents: get use force.
+ */
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
+
+ /**
* Override in descendents: is this an arch flag?
*/
virtual bool do_is_arch_flag(const UseFlagName &) const = 0;
@@ -408,6 +413,8 @@ namespace paludis
{
if (do_query_use_mask(u, pde))
return use_disabled;
+ else if (do_query_use_force(u, pde))
+ return use_enabled;
else
return do_query_use(u, pde);
}
@@ -421,6 +428,14 @@ namespace paludis
}
/**
+ * Query whether the specified use flag is forced.
+ */
+ bool query_use_force(const UseFlagName & u, const PackageDatabaseEntry *pde) const
+ {
+ return do_query_use_mask(u, pde);
+ }
+
+ /**
* Query whether the specified use flag is an arch flag.
*/
bool is_arch_flag(const UseFlagName & u) const
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 17dc998..bc3792b 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -622,6 +622,12 @@ VDBRepository::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry
return false;
}
+bool
+VDBRepository::do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const
+{
+ return false;
+}
+
CountedPtr<Repository>
VDBRepository::make_vdb_repository(
const Environment * const env,
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index 3989eb1..9bcbcd9 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -122,6 +122,8 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+
virtual bool do_is_arch_flag(const UseFlagName &) const;
virtual bool do_is_expand_flag(const UseFlagName &) const;