aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-22 22:11:15 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-22 22:11:15 +0100
commit729bc1a815c1abba572213e885d5d654b09b35b4 (patch)
tree832e70a1f4338e5b39455cfd2fd416c7dddf28e7
parent1b8bbb1a910d35e4e3da18d976ed96d965eb55aa (diff)
downloadpaludis-729bc1a815c1abba572213e885d5d654b09b35b4.tar.gz
paludis-729bc1a815c1abba572213e885d5d654b09b35b4.tar.xz
Distribution-defined config file names
-rw-r--r--paludis/distributions/exherbo/Makefile.am2
-rw-r--r--paludis/distributions/exherbo/paludis.conf10
-rw-r--r--paludis/distributions/gentoo/Makefile.am2
-rw-r--r--paludis/distributions/gentoo/paludis.conf10
-rw-r--r--paludis/environments/paludis/Makefile.am4
-rw-r--r--paludis/environments/paludis/extra_distribution_data.cc58
-rw-r--r--paludis/environments/paludis/extra_distribution_data.hh62
-rw-r--r--paludis/environments/paludis/paludis_config.cc86
8 files changed, 192 insertions, 42 deletions
diff --git a/paludis/distributions/exherbo/Makefile.am b/paludis/distributions/exherbo/Makefile.am
index c82a21c..9b85d03 100644
--- a/paludis/distributions/exherbo/Makefile.am
+++ b/paludis/distributions/exherbo/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS =
distributiondir = $(datadir)/paludis/distributions/exherbo/
-distribution_DATA = e.conf gems.conf
+distribution_DATA = e.conf gems.conf paludis.conf
EXTRA_DIST = $(distribution_DATA)
diff --git a/paludis/distributions/exherbo/paludis.conf b/paludis/distributions/exherbo/paludis.conf
new file mode 100644
index 0000000..b3d12cf
--- /dev/null
+++ b/paludis/distributions/exherbo/paludis.conf
@@ -0,0 +1,10 @@
+bashrc_filename = bashrc
+keywords_filename_part = platforms
+licenses_filename_part = licences
+mirrors_filename_part = mirrors
+package_mask_filename_part = package_mask
+package_unmask_filename_part = package_unmask
+repositories_directory = repositories
+repository_defaults_filename_part = repository_defaults
+use_filename_part = options
+
diff --git a/paludis/distributions/gentoo/Makefile.am b/paludis/distributions/gentoo/Makefile.am
index 90ecf18..4ba0c73 100644
--- a/paludis/distributions/gentoo/Makefile.am
+++ b/paludis/distributions/gentoo/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS =
distributiondir = $(datadir)/paludis/distributions/gentoo/
-distribution_DATA = e.conf gems.conf
+distribution_DATA = e.conf gems.conf paludis.conf
EXTRA_DIST = $(distribution_DATA)
diff --git a/paludis/distributions/gentoo/paludis.conf b/paludis/distributions/gentoo/paludis.conf
new file mode 100644
index 0000000..204670e
--- /dev/null
+++ b/paludis/distributions/gentoo/paludis.conf
@@ -0,0 +1,10 @@
+bashrc_filename = bashrc
+keywords_filename_part = keywords
+licenses_filename_part = licenses
+mirrors_filename_part = mirrors
+package_mask_filename_part = package_mask
+package_unmask_filename_part = package_unmask
+repositories_directory = repositories
+repository_defaults_filename_part = repository_defaults
+use_filename_part = use
+
diff --git a/paludis/environments/paludis/Makefile.am b/paludis/environments/paludis/Makefile.am
index 74e9cc6..c6b11c2 100644
--- a/paludis/environments/paludis/Makefile.am
+++ b/paludis/environments/paludis/Makefile.am
@@ -20,6 +20,7 @@ libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_SOURCES = \
world.cc world.hh \
paludis_config.cc paludis_config.hh \
paludis_environment.cc paludis_environment.hh \
+ extra_distribution_data.cc extra_distribution_data.hh \
registration.cc
libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
@@ -55,7 +56,8 @@ paludis_environment_paludis_include_HEADERS = \
bashable_conf.hh \
package_mask_conf.hh \
world.hh \
- mirrors_conf.hh
+ mirrors_conf.hh \
+ extra_distribution_data.hh
EXTRA_DIST = \
paludis_environment_TEST_setup.sh \
diff --git a/paludis/environments/paludis/extra_distribution_data.cc b/paludis/environments/paludis/extra_distribution_data.cc
new file mode 100644
index 0000000..968eb9a
--- /dev/null
+++ b/paludis/environments/paludis/extra_distribution_data.cc
@@ -0,0 +1,58 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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 <paludis/environments/paludis/extra_distribution_data.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/distribution-impl.hh>
+
+using namespace paludis;
+using namespace paludis::paludis_environment;
+
+namespace paludis
+{
+ template <>
+ struct ExtraDistributionDataData<PaludisDistribution>
+ {
+ static std::string config_file_name()
+ {
+ return "paludis.conf";
+ }
+
+ static std::tr1::shared_ptr<PaludisDistribution> make_data(const KeyValueConfigFile & k)
+ {
+ return make_shared_ptr(new PaludisDistribution(make_named_values<PaludisDistribution>(
+ value_for<n::bashrc_filename>(k.get("bashrc_filename")),
+ value_for<n::keywords_filename_part>(k.get("keywords_filename_part")),
+ value_for<n::licenses_filename_part>(k.get("licenses_filename_part")),
+ value_for<n::mirrors_filename_part>(k.get("mirrors_filename_part")),
+ value_for<n::package_mask_filename_part>(k.get("package_mask_filename_part")),
+ value_for<n::package_unmask_filename_part>(k.get("package_unmask_filename_part")),
+ value_for<n::repositories_directory>(k.get("repositories_directory")),
+ value_for<n::repository_defaults_filename_part>(k.get("repository_defaults_filename_part")),
+ value_for<n::use_filename_part>(k.get("use_filename_part"))
+ )));
+ }
+ };
+}
+
+template class ExtraDistributionData<PaludisDistribution>;
+template class InstantiationPolicy<ExtraDistributionData<PaludisDistribution>, instantiation_method::SingletonTag>;
+
+
diff --git a/paludis/environments/paludis/extra_distribution_data.hh b/paludis/environments/paludis/extra_distribution_data.hh
new file mode 100644
index 0000000..7c4de48
--- /dev/null
+++ b/paludis/environments/paludis/extra_distribution_data.hh
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_EXTRA_DISTRIBUTION_DATA_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_EXTRA_DISTRIBUTION_DATA_HH 1
+
+#include <paludis/distribution-fwd.hh>
+#include <paludis/util/named_value.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace n
+ {
+ struct bashrc_filename;
+ struct keywords_filename_part;
+ struct licenses_filename_part;
+ struct mirrors_filename_part;
+ struct package_mask_filename_part;
+ struct package_unmask_filename_part;
+ struct repositories_directory;
+ struct repository_defaults_filename_part;
+ struct use_filename_part;
+ }
+
+ namespace paludis_environment
+ {
+ struct PaludisDistribution
+ {
+ NamedValue<n::bashrc_filename, std::string> bashrc_filename;
+ NamedValue<n::keywords_filename_part, std::string> keywords_filename_part;
+ NamedValue<n::licenses_filename_part, std::string> licenses_filename_part;
+ NamedValue<n::mirrors_filename_part, std::string> mirrors_filename_part;
+ NamedValue<n::package_mask_filename_part, std::string> package_mask_filename_part;
+ NamedValue<n::package_unmask_filename_part, std::string> package_unmask_filename_part;
+ NamedValue<n::repositories_directory, std::string> repositories_directory;
+ NamedValue<n::repository_defaults_filename_part, std::string> repository_defaults_filename_part;
+ NamedValue<n::use_filename_part, std::string> use_filename_part;
+ };
+
+ typedef ExtraDistributionData<PaludisDistribution> PaludisExtraDistributionData;
+ }
+}
+
+
+#endif
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index f819f0a..3033d8e 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -25,6 +25,7 @@
#include <paludis/environments/paludis/licenses_conf.hh>
#include <paludis/environments/paludis/package_mask_conf.hh>
#include <paludis/environments/paludis/world.hh>
+#include <paludis/environments/paludis/extra_distribution_data.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/destringify.hh>
@@ -327,7 +328,6 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
Log::get_instance()->message("paludis_environment.paludis_config.initial_dir", ll_debug, lc_no_context)
<< "PaludisConfig initial directory is '" << local_config_dir << "'";
- // Prefer specpath.conf over specpath. Warn if specpath is used.
if ((local_config_dir / "specpath.conf").exists() || (local_config_dir / "specpath").exists())
{
KeyValueConfigFile* specpath;
@@ -370,6 +370,10 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
}
}
+ const std::tr1::shared_ptr<const PaludisDistribution> dist(
+ PaludisExtraDistributionData::get_instance()->data_from_distribution(
+ *DistributionData::get_instance()->distribution_from_string(distribution())));
+
std::tr1::function<std::string (const std::string &)> predefined_conf_vars_func(
std::tr1::bind(&initial_conf_vars, root_prefix, std::tr1::placeholders::_1));
@@ -381,21 +385,21 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
{
/* add normal repositories. start by getting defaults for config files... */
- if ((local_config_dir / "repository_defaults.conf").exists())
+ if ((local_config_dir / (dist->repository_defaults_filename_part() + ".conf")).exists())
{
predefined_conf_vars_func = std::tr1::bind(&from_kv, make_shared_ptr(new KeyValueConfigFile(
- local_config_dir / "repository_defaults.conf", KeyValueConfigFileOptions(),
+ local_config_dir / (dist->repository_defaults_filename_part() + ".conf"), KeyValueConfigFileOptions(),
std::tr1::bind(&to_kv_func, predefined_conf_vars_func, std::tr1::placeholders::_1, std::tr1::placeholders::_2),
&KeyValueConfigFile::no_transformation)),
std::tr1::placeholders::_1);
}
- else if ((local_config_dir / "repository_defaults.bash").exists())
+ else if ((local_config_dir / (dist->repository_defaults_filename_part() + ".bash")).exists())
{
std::stringstream s;
- Command cmd(Command("bash '" + stringify(local_config_dir / "repository_defaults.bash") + "'")
+ Command cmd(Command("bash '" + stringify(local_config_dir / (dist->repository_defaults_filename_part() + ".bash")) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix("repository_defaults.bash> ")
+ .with_stderr_prefix(dist->repository_defaults_filename_part() + ".bash> ")
.with_captured_stdout_stream(&s));
int exit_status(run_command(cmd));
predefined_conf_vars_func = std::tr1::bind(&from_kv, make_shared_ptr(new KeyValueConfigFile(
@@ -405,13 +409,13 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::placeholders::_1);
if (exit_status != 0)
Log::get_instance()->message("paludis_environment.repository_defaults.failure", ll_warning, lc_context)
- << "Script '" << (local_config_dir / "repository_defaults.bash")
+ << "Script '" << (local_config_dir / (dist->repository_defaults_filename_part() + ".bash"))
<< "' returned non-zero exit status '" << exit_status << "'";
}
/* find candidate config directories */
std::list<FSEntry> dirs;
- dirs.push_back(local_config_dir / "repositories");
+ dirs.push_back(local_config_dir / dist->repositories_directory());
/* find repo config files */
std::list<FSEntry> repo_files;
@@ -547,13 +551,13 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* keywords */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "keywords.conf");
- files.push_back(local_config_dir / "keywords.bash");
- if ((local_config_dir / "keywords.conf.d").exists())
+ files.push_back(local_config_dir / (dist->keywords_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->keywords_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->keywords_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "keywords.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->keywords_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "keywords.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->keywords_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -572,13 +576,13 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* use */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "use.conf");
- files.push_back(local_config_dir / "use.bash");
- if ((local_config_dir / "use.conf.d").exists())
+ files.push_back(local_config_dir / (dist->use_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->use_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->use_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "use.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->use_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "use.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->use_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -597,13 +601,13 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* licenses */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "licenses.conf");
- files.push_back(local_config_dir / "licenses.bash");
- if ((local_config_dir / "licenses.conf.d").exists())
+ files.push_back(local_config_dir / (dist->licenses_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->licenses_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->licenses_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "licenses.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->licenses_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "licenses.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->licenses_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -622,13 +626,15 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* user mask */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "package_mask.conf");
- files.push_back(local_config_dir / "package_mask.bash");
- if ((local_config_dir / "package_mask.conf.d").exists())
+ files.push_back(local_config_dir / (dist->package_mask_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->package_mask_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->package_mask_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "package_mask.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->package_mask_filename_part() + ".conf.d")),
+ DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "package_mask.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->package_mask_filename_part() + ".conf.d")),
+ DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -647,13 +653,15 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* user unmask */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "package_unmask.conf");
- files.push_back(local_config_dir / "package_unmask.bash");
- if ((local_config_dir / "package_unmask.conf.d").exists())
+ files.push_back(local_config_dir / (dist->package_unmask_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->package_unmask_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->package_unmask_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "package_unmask.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->package_unmask_filename_part() + ".conf.d")),
+ DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "package_unmask.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->package_unmask_filename_part() + ".conf.d")),
+ DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -672,13 +680,13 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
/* mirrors */
{
std::list<FSEntry> files;
- files.push_back(local_config_dir / "mirrors.conf");
- files.push_back(local_config_dir / "mirrors.bash");
- if ((local_config_dir / "mirrors.conf.d").exists())
+ files.push_back(local_config_dir / (dist->mirrors_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->mirrors_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->mirrors_filename_part() + ".conf.d")).exists())
{
- std::remove_copy_if(DirIterator(local_config_dir / "mirrors.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->mirrors_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::remove_copy_if(DirIterator(local_config_dir / "mirrors.conf.d"), DirIterator(), std::back_inserter(files),
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->mirrors_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
@@ -694,7 +702,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
}
}
- _imp->bashrc_files->push_back(local_config_dir / "bashrc");
+ _imp->bashrc_files->push_back(local_config_dir / dist->bashrc_filename());
}
PaludisConfig::~PaludisConfig()