diff options
-rw-r--r-- | doc/doc_bootstrap_howto.doxygen | 5 | ||||
-rw-r--r-- | doc/doc_configuration_files.doxygen | 6 | ||||
-rw-r--r-- | doc/doc_migration_howto.doxygen | 2 | ||||
-rw-r--r-- | paludis/default_config.cc | 70 | ||||
-rw-r--r-- | paludis/default_config.hh | 11 | ||||
-rw-r--r-- | paludis/default_environment.cc | 31 | ||||
-rw-r--r-- | paludis/default_environment_TEST.cc | 98 | ||||
-rwxr-xr-x | paludis/default_environment_TEST_cleanup.sh | 11 | ||||
-rwxr-xr-x | paludis/default_environment_TEST_setup.sh | 60 | ||||
-rw-r--r-- | paludis/files.m4 | 2 |
10 files changed, 278 insertions, 18 deletions
diff --git a/doc/doc_bootstrap_howto.doxygen b/doc/doc_bootstrap_howto.doxygen index d3c8cdb..eba5821 100644 --- a/doc/doc_bootstrap_howto.doxygen +++ b/doc/doc_bootstrap_howto.doxygen @@ -90,11 +90,12 @@ flags</code> line. Again, additional per-atom lines can be specified. The <code>-apache2</code> is important, if you value your sanity, since you'll be installing subversion. We're experimenting with a slightly different way of handling <code>USE_EXPAND</code> variables that allows different settings for -different packages. This may change, but for now it looks like this: +different packages. This may change, but for now it looks like this (note the +<code>-*</code> to avoid inherinting profile values: \verbatim cat <<"END" > /mychroot/etc/paludis/use.conf -* -doc nls -apache2 LINGUAS: en INPUT_DEVICES: keyboard mouse VIDEO_CARDS: ati +* -doc nls -apache2 LINGUAS: en INPUT_DEVICES: keyboard mouse VIDEO_CARDS: -* ati app-editors/vim -nls END \endverbatim diff --git a/doc/doc_configuration_files.doxygen b/doc/doc_configuration_files.doxygen index 88301a6..79872e4 100644 --- a/doc/doc_configuration_files.doxygen +++ b/doc/doc_configuration_files.doxygen @@ -57,8 +57,8 @@ and <code>use use use ...</code> is one or more USE flag names, prefixed by a minus if they are to be disabled. For <code>USE_EXPAND</code> variables such as <code>LINGUAS</code> and -<code>VIDEO_CARDS</code>, <code>atom VARIABLE: value value ...</code> -should be used. +<code>VIDEO_CARDS</code>, <code>atom VARIABLE: value value ...</code> should be +used. To avoid inheriting values from your profile, include <code>-*</code>. \verbatim # By default, apply these to all packages @@ -74,7 +74,7 @@ app-editors/vim -nls x11-libs/gtk+:2 tiff # We like English -* LINGUAS: en_GB en +* LINGUAS: -* en_GB en \endverbatim Note that if a package matches multiple lines, <em>all</em> of these lines will diff --git a/doc/doc_migration_howto.doxygen b/doc/doc_migration_howto.doxygen index ee544ae..58171c1 100644 --- a/doc/doc_migration_howto.doxygen +++ b/doc/doc_migration_howto.doxygen @@ -135,7 +135,7 @@ cat <<"END" > /etc/paludis/use.conf * -doc nls -apache2 * LINGUAS: en * INPUT_DEVICES: keyboard mouse -* VIDEO_CARDS: ati +* VIDEO_CARDS: -* ati app-editors/vim -nls END diff --git a/paludis/default_config.cc b/paludis/default_config.cc index 72d3bf6..af25e8a 100644 --- a/paludis/default_config.cc +++ b/paludis/default_config.cc @@ -94,17 +94,25 @@ namespace paludis std::map<QualifiedPackageName, std::vector<UseConfigEntry> > use; + std::vector<std::pair<PackageDepAtom::ConstPointer, std::string> > empty_use_prefixes; + + std::map<QualifiedPackageName, std::vector<std::pair<PackageDepAtom::ConstPointer, std::string> > > + use_prefixes_that_have_minus_star; + std::vector<UseConfigEntry> empty_use; std::vector<std::pair<UseFlagName, UseFlagState> > default_use; + std::vector<std::string> default_use_prefixes_that_have_minus_star; + std::multimap<std::string, std::string> mirrors; Implementation(); }; Implementation<DefaultConfig>::Implementation() : - paludis_command("paludis") + paludis_command("paludis"), + config_dir("(unset)") { } @@ -374,12 +382,24 @@ DefaultConfig::DefaultConfig() : std::string prefix; if ("*" == tokens.at(0)) + { for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ; t != t_end ; ++t) { if ('-' == t->at(0)) - _imp->default_use.push_back(std::make_pair(UseFlagName( - prefix + t->substr(1)), use_disabled)); + { + if (*t == "-*") + { + _imp->default_use_prefixes_that_have_minus_star.push_back(prefix.empty() ? prefix : + prefix + "_"); + if (prefix.empty()) + Log::get_instance()->message(ll_warning, lc_no_context, + "Using '* -*' in use.conf is dangerous. You have been warned."); + } + else + _imp->default_use.push_back(std::make_pair(UseFlagName( + prefix + t->substr(1)), use_disabled)); + } else if (':' == t->at(t->length() - 1)) { prefix.clear(); @@ -391,6 +411,7 @@ DefaultConfig::DefaultConfig() : _imp->default_use.push_back(std::make_pair(UseFlagName( prefix + *t), use_enabled)); } + } else { PackageDepAtom::ConstPointer a(new PackageDepAtom(tokens.at(0))); @@ -398,8 +419,14 @@ DefaultConfig::DefaultConfig() : t != t_end ; ++t) { if ('-' == t->at(0)) - _imp->use[a->package()].push_back(UseConfigEntry( - a, UseFlagName(prefix + t->substr(1)), use_disabled)); + { + if ("-*" == *t) + _imp->use_prefixes_that_have_minus_star[a->package()].push_back( + std::make_pair(a, prefix.empty() ? prefix : prefix + "_")); + else + _imp->use[a->package()].push_back(UseConfigEntry( + a, UseFlagName(prefix + t->substr(1)), use_disabled)); + } else if (':' == t->at(t->length() - 1)) { prefix.clear(); @@ -679,3 +706,36 @@ DefaultConfig::end_mirrors(const std::string & m) const return MirrorIterator(_imp->mirrors.upper_bound(m)); } +DefaultConfig::UseMinusStarIterator +DefaultConfig::begin_use_prefixes_with_minus_star() const +{ + return UseMinusStarIterator(_imp->default_use_prefixes_that_have_minus_star.begin()); +} + +DefaultConfig::UseMinusStarIterator +DefaultConfig::end_use_prefixes_with_minus_star() const +{ + return UseMinusStarIterator(_imp->default_use_prefixes_that_have_minus_star.end()); +} + +DefaultConfig::PackageUseMinusStarIterator +DefaultConfig::begin_package_use_prefixes_with_minus_star(const QualifiedPackageName & d) const +{ + std::map<QualifiedPackageName, std::vector<std::pair<PackageDepAtom::ConstPointer, std::string> > >::const_iterator r; + if (_imp->use_prefixes_that_have_minus_star.end() != ((r = _imp->use_prefixes_that_have_minus_star.find(d)))) + return PackageUseMinusStarIterator(r->second.begin()); + else + return PackageUseMinusStarIterator(_imp->empty_use_prefixes.begin()); +} + +DefaultConfig::PackageUseMinusStarIterator +DefaultConfig::end_package_use_prefixes_with_minus_star(const QualifiedPackageName & d) const +{ + std::map<QualifiedPackageName, std::vector<std::pair<PackageDepAtom::ConstPointer, std::string> > >::const_iterator r; + if (_imp->use_prefixes_that_have_minus_star.end() != ((r = _imp->use_prefixes_that_have_minus_star.find(d)))) + return PackageUseMinusStarIterator(r->second.end()); + else + return PackageUseMinusStarIterator(_imp->empty_use_prefixes.end()); +} + + diff --git a/paludis/default_config.hh b/paludis/default_config.hh index b6675f4..45e995d 100644 --- a/paludis/default_config.hh +++ b/paludis/default_config.hh @@ -170,6 +170,17 @@ namespace paludis DefaultUseIterator end_default_use() const; + typedef libwrapiter::ForwardIterator<DefaultConfig, const std::string> UseMinusStarIterator; + + UseMinusStarIterator begin_use_prefixes_with_minus_star() const; + UseMinusStarIterator end_use_prefixes_with_minus_star() const; + + typedef libwrapiter::ForwardIterator<DefaultConfig, + const std::pair<PackageDepAtom::ConstPointer, std::string> > PackageUseMinusStarIterator; + + PackageUseMinusStarIterator begin_package_use_prefixes_with_minus_star(const QualifiedPackageName &) const; + PackageUseMinusStarIterator end_package_use_prefixes_with_minus_star(const QualifiedPackageName &) const; + ///} /** diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc index 7364264..3217407 100644 --- a/paludis/default_environment.cc +++ b/paludis/default_environment.cc @@ -56,12 +56,10 @@ DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry { /* first check package database use masks... */ const Repository * const repo((e ? - package_database()->fetch_repository(e->repository) : - package_database()->fetch_repository(package_database()->favourite_repository()) - ).raw_pointer()); + package_database()->fetch_repository(e->repository).raw_pointer() : + 0)); - if (repo->use_interface) - if (repo->use_interface->query_use_mask(f, e)) + if (repo && repo->use_interface && repo->use_interface->query_use_mask(f, e)) return false; /* check use: per package user config */ @@ -112,6 +110,19 @@ DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry } throw InternalError(PALUDIS_HERE, "Bad state"); } while (false); + + /* and the -* bit */ + for (DefaultConfig::PackageUseMinusStarIterator + i(DefaultConfig::get_instance()->begin_package_use_prefixes_with_minus_star(e->name)), + i_end(DefaultConfig::get_instance()->end_package_use_prefixes_with_minus_star(e->name)) ; + i != i_end ; ++i) + { + if (! match_package(this, *i->first, *e)) + continue; + + if (0 == i->second.compare(0, i->second.length(), stringify(f), 0, i->second.length())) + return false; + } } /* check use: general user config */ @@ -141,8 +152,16 @@ DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry throw InternalError(PALUDIS_HERE, "bad state " + stringify(state)); } while (false); + /* and -* again */ + for (DefaultConfig::UseMinusStarIterator + i(DefaultConfig::get_instance()->begin_use_prefixes_with_minus_star()), + i_end(DefaultConfig::get_instance()->end_use_prefixes_with_minus_star()) ; + i != i_end ; ++i) + if (0 == i->compare(0, i->length(), stringify(f), 0, i->length())) + return false; + /* check use: package database config */ - if (repo->use_interface) + if (repo && repo->use_interface) { switch (repo->use_interface->query_use(f, e)) { diff --git a/paludis/default_environment_TEST.cc b/paludis/default_environment_TEST.cc new file mode 100644 index 0000000..afad951 --- /dev/null +++ b/paludis/default_environment_TEST.cc @@ -0,0 +1,98 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "default_environment.hh" +#include "default_config.hh" +#include <paludis/util/fs_entry.hh> +#include <test/test_runner.hh> +#include <test/test_framework.hh> +#include <cstdlib> + +using namespace paludis; +using namespace test; + +namespace test_cases +{ + struct TestDefaultEnvironmentUse : TestCase + { + TestDefaultEnvironmentUse() : TestCase("use") { } + + void run() + { + setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "default_environment_TEST_dir" / "home1").c_str(), 1); + unsetenv("PALUDIS_SKIP_CONFIG"); + DefaultConfig::destroy_instance(); + DefaultEnvironment::destroy_instance(); + + Environment * env(DefaultEnvironment::get_instance()); + + TEST_CHECK(env->query_use(UseFlagName("foo"), 0)); + TEST_CHECK(! env->query_use(UseFlagName("foofoo"), 0)); + + PackageDatabaseEntry e(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("foo")); + TEST_CHECK(env->query_use(UseFlagName("foo"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("foofoo"), &e)); + TEST_CHECK(env->query_use(UseFlagName("moo"), &e)); + + TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), &e)); + TEST_CHECK(env->query_use(UseFlagName("exp_two"), &e)); + TEST_CHECK(env->query_use(UseFlagName("exp_one"), &e)); + TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), &e)); + + PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo")); + TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &f)); + TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), &f)); + } + } default_environment_use_test; + + struct TestDefaultEnvironmentUseMinusStar : TestCase + { + TestDefaultEnvironmentUseMinusStar() : TestCase("use -*") { } + + void run() + { + setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "default_environment_TEST_dir" / "home2").c_str(), 1); + unsetenv("PALUDIS_SKIP_CONFIG"); + DefaultConfig::destroy_instance(); + DefaultEnvironment::destroy_instance(); + + Environment * env(DefaultEnvironment::get_instance()); + + TEST_CHECK(env->query_use(UseFlagName("foo"), 0)); + TEST_CHECK(! env->query_use(UseFlagName("foofoo"), 0)); + + PackageDatabaseEntry e(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("foo")); + TEST_CHECK(env->query_use(UseFlagName("foo"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("foofoo"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("moo"), &e)); + + TEST_CHECK(! env->query_use(UseFlagName("more_exp_one"), &e)); + TEST_CHECK(env->query_use(UseFlagName("exp_two"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("exp_one"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), &e)); + TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), &e)); + + PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo")); + TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), &f)); + TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), &f)); + } + } default_environment_use_test_minus_star; +} + diff --git a/paludis/default_environment_TEST_cleanup.sh b/paludis/default_environment_TEST_cleanup.sh new file mode 100755 index 0000000..3cd5c8d --- /dev/null +++ b/paludis/default_environment_TEST_cleanup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +if [ -d default_environment_TEST_dir ] ; then + rm -fr default_environment_TEST_dir +else + true +fi + + + diff --git a/paludis/default_environment_TEST_setup.sh b/paludis/default_environment_TEST_setup.sh new file mode 100755 index 0000000..e4dc625 --- /dev/null +++ b/paludis/default_environment_TEST_setup.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: set ft=sh sw=4 sts=4 et : + +mkdir default_environment_TEST_dir || exit 2 +cd default_environment_TEST_dir || exit 3 + +mkdir -p repo/{profile,profiles,cat-one/pkg-one} +cat <<END > repo/profiles/repo_name +foo +END +cat <<END > repo/profiles/categories +cat-one +END +cat <<END > repo/profile/make.defaults +ARCH="foo" +USE="moo" +USE_EXPAND="EXP MORE_EXP THIRD_EXP" +EXP="one" +MORE_EXP="one" +THIRD_EXP="one" +END + +mkdir -p home1/.paludis/repositories +cat <<END > home1/.paludis/use.conf +* foo bar baz -fnord +* EXP: two +>=cat-one/pkg-two-2 THIRD_EXP: two +END +cat <<END > home1/.paludis/keywords.conf +* keyword +END +cat <<END > home1/.paludis/licenses.conf +* keyword +END +cat <<END > home1/.paludis/repositories/foo.conf +format = portage +location = `pwd`/repo +profiles = `pwd`/repo/profile +cache = /var/empty +END + +mkdir -p home2/.paludis/repositories +cat <<END > home2/.paludis/use.conf +* -* foo bar baz -fnord +* EXP: -* two +>=cat-one/pkg-two-2 THIRD_EXP: -* two +END +cat <<END > home2/.paludis/keywords.conf +* keyword +END +cat <<END > home2/.paludis/licenses.conf +* * +END +cat <<END > home2/.paludis/repositories/foo.conf +format = portage +location = `pwd`/repo +profiles = `pwd`/repo/profile +cache = /var/empty +END + diff --git a/paludis/files.m4 b/paludis/files.m4 index 4bb507e..3a2c0a0 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -12,7 +12,7 @@ add(`about', `hh', `test') add(`config_file', `hh', `cc', `test', `testscript') add(`contents', `hh', `cc') add(`default_config', `hh', `cc') -add(`default_environment', `hh', `cc') +add(`default_environment', `hh', `cc', `test', `testscript') add(`dep_atom', `hh', `cc', `test') add(`dep_atom_flattener', `hh', `cc') add(`dep_atom_pretty_printer', `hh', `cc') |