aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Danny van Dyk <dvandyk@exherbo.org> 2007-03-18 22:24:21 +0000
committerAvatar Danny van Dyk <dvandyk@exherbo.org> 2007-03-18 22:24:21 +0000
commitf02ee9142fe25e5aad29984d9ca26e9f90a4da8c (patch)
treee55c71f7fdf4a1a82ac42ba2a89e377da09eb49b
parent99adebb5b301440a17f9349cd305bab6e82689f9 (diff)
downloadpaludis-f02ee9142fe25e5aad29984d9ca26e9f90a4da8c.tar.gz
paludis-f02ee9142fe25e5aad29984d9ca26e9f90a4da8c.tar.xz
Remove package selection per command line. Add support for package selection via configuration file. Add AuxiliaryStage for non-cross-compiled dependencies.
-rw-r--r--src/clients/contrarius/Makefile.am11
-rw-r--r--src/clients/contrarius/contrarius.cc28
-rw-r--r--src/clients/contrarius/default_config.txt10
-rw-r--r--src/clients/contrarius/install.cc4
-rw-r--r--src/clients/contrarius/install.hh2
-rw-r--r--src/clients/contrarius/stage.cc167
-rw-r--r--src/clients/contrarius/stage.hh65
7 files changed, 159 insertions, 128 deletions
diff --git a/src/clients/contrarius/Makefile.am b/src/clients/contrarius/Makefile.am
index 09817a4..7002330 100644
--- a/src/clients/contrarius/Makefile.am
+++ b/src/clients/contrarius/Makefile.am
@@ -1,5 +1,6 @@
AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
DEFS= \
+ -DDATADIR=\"$(datadir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DBIGTEMPDIR=\"/var/tmp\" \
@@ -22,7 +23,9 @@ contrarius_SOURCES = \
stage.hh \
stage.cc \
stage_builder.hh \
- stage_builder.cc
+ stage_builder.cc \
+ target_config.hh \
+ target_config.cc
contrarius_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
@@ -81,7 +84,11 @@ EXTRA_DIST = \
$(man_pages) \
contrarius_stage_options.sr \
contrarius_stage_options-sr.hh \
- contrarius_stage_options-sr.cc
+ contrarius_stage_options-sr.cc \
+ default_config.txt
+
+contrarius_datadir = $(datadir)/paludis/contrarius/
+contrarius_data_DATA = default_config.txt
built-sources : $(BUILT_SOURCES)
for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
diff --git a/src/clients/contrarius/contrarius.cc b/src/clients/contrarius/contrarius.cc
index ab8840c..8e93928 100644
--- a/src/clients/contrarius/contrarius.cc
+++ b/src/clients/contrarius/contrarius.cc
@@ -29,6 +29,7 @@
#include <libebt/libebt.hh>
#include <libwrapiter/libwrapiter.hh>
+#include "target_config.hh"
#include "command_line.hh"
#include "stage.hh"
#include "config.h"
@@ -71,17 +72,7 @@ int main(int argc, char *argv[])
else
stage = "cxx";
- ContrariusStageOptions contrarius_opts(
- EnvironmentMaker::get_instance()->make_from_spec(""),
- HostTupleName(CommandLine::get_instance()->a_target.argument()),
- CommandLine::get_instance()->a_binutils_name.argument(),
- CommandLine::get_instance()->a_binutils_version.argument(),
- CommandLine::get_instance()->a_gcc_name.argument(),
- CommandLine::get_instance()->a_gcc_version.argument(),
- CommandLine::get_instance()->a_headers_name.argument(),
- CommandLine::get_instance()->a_headers_version.argument(),
- CommandLine::get_instance()->a_libc_name.argument(),
- CommandLine::get_instance()->a_libc_version.argument());
+ std::tr1::shared_ptr<Environment> env(EnvironmentMaker::get_instance()->make_from_spec(""));
StageOptions stage_opts(CommandLine::get_instance()->a_pretend.specified(),
CommandLine::get_instance()->a_fetch.specified(),
@@ -91,31 +82,34 @@ int main(int argc, char *argv[])
do
{
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new BinutilsStage(contrarius_opts)));
+ if (! TargetConfig::get_instance()->aux().empty())
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new AuxiliaryStage(env)));
+
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new BinutilsStage(env)));
if (stage == "binutils")
break;
if (CommandLine::get_instance()->a_headers.specified())
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new KernelHeadersStage(contrarius_opts)));
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new KernelHeadersStage(env)));
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new MinimalStage(contrarius_opts)));
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new MinimalStage(env)));
if (stage == "minimal")
break;
if (! CommandLine::get_instance()->a_headers.specified())
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new KernelHeadersStage(contrarius_opts)));
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new KernelHeadersStage(env)));
if (stage == "headers")
break;
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new LibCStage(contrarius_opts)));
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new LibCStage(env)));
if (stage == "libc")
break;
- builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new FullStage(contrarius_opts)));
+ builder.queue_stage(std::tr1::shared_ptr<const StageBase>(new FullStage(env)));
} while (false);
diff --git a/src/clients/contrarius/default_config.txt b/src/clients/contrarius/default_config.txt
new file mode 100644
index 0000000..b04a5a7
--- /dev/null
+++ b/src/clients/contrarius/default_config.txt
@@ -0,0 +1,10 @@
+*-*-linux-* headers linux-headers
+*-*-freebsd*-* headers freebsd-lib
+*-*-mingw*-* headers w32api
+*-*-*-gnu libc glibc
+*-*-*-freebsd*-* libc freebds-lib
+*-*-*-mingw* libc mingw-runtime
+*-*-*-uclibc libc uclibc
+*-*-*-* binutils binutils
+*-*-*-* gcc gcc
+*-*-*-* aux
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index db7a60f..7af4e4e 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -203,7 +203,7 @@ namespace
}
int
-do_install(std::tr1::shared_ptr<Environment> env, std::tr1::shared_ptr<const PackageDepSpec> spec)
+do_install(std::tr1::shared_ptr<Environment> env, std::string spec_str)
{
int return_code(0);
@@ -240,7 +240,7 @@ do_install(std::tr1::shared_ptr<Environment> env, std::tr1::shared_ptr<const Pac
try
{
- task.add_target(stringify(*spec));
+ task.add_target(spec_str);
task.execute();
diff --git a/src/clients/contrarius/install.hh b/src/clients/contrarius/install.hh
index 82c9add..2061ef4 100644
--- a/src/clients/contrarius/install.hh
+++ b/src/clients/contrarius/install.hh
@@ -30,6 +30,6 @@
/// Handle --install.
int do_install(std::tr1::shared_ptr<paludis::Environment>,
- std::tr1::shared_ptr<const paludis::PackageDepSpec> spec);
+ std::string spec_str);
#endif
diff --git a/src/clients/contrarius/stage.cc b/src/clients/contrarius/stage.cc
index 3b9379e..7f76ef7 100644
--- a/src/clients/contrarius/stage.cc
+++ b/src/clients/contrarius/stage.cc
@@ -18,58 +18,42 @@
*/
#include <paludis/util/log.hh>
-#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/config_file.hh>
+#include <paludis/portage_dep_parser.hh>
#include <paludis/query.hh>
#include <string>
+#include <tr1/memory>
#include "stage.hh"
+#include "target_config.hh"
#include "install.hh"
using namespace paludis;
-namespace
+int
+AuxiliaryStage::build(const StageOptions &) const
{
- const PackageDepSpec * make_spec(const HostTupleName & target,
- const std::string & name,
- const std::string & default_name,
- const std::string & version)
- {
- std::tr1::shared_ptr<VersionRequirements> v;
- if (! version.empty())
- {
- v.reset(new VersionRequirements::Concrete);
- v->push_back(VersionRequirement(vo_equal, VersionSpec(version)));
- }
-
- return new PackageDepSpec(
- std::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName("cross-" + stringify(target) + "/"
- + (name.empty() ? default_name : name))),
- std::tr1::shared_ptr<CategoryNamePart>(),
- std::tr1::shared_ptr<PackageNamePart>(),
- v, vr_and);
- }
+ Context context("When building AuxiliaryStage:");
+
+ return 0 == do_install(_env, TargetConfig::get_instance()->aux());
}
-#include <src/clients/contrarius/contrarius_stage_options-sr.cc>
-
-ContrariusStageOptions::ContrariusStageOptions(
- std::tr1::shared_ptr<Environment> env,
- const HostTupleName & _target,
- const std::string & binutils_name,
- const std::string & binutils_version,
- const std::string & gcc_name,
- const std::string & gcc_version,
- const std::string & headers_name,
- const std::string & headers_version,
- const std::string & libc_name,
- const std::string & libc_version) :
- environment(env),
- target(_target),
- binutils(::make_spec(target, binutils_name, "binutils", binutils_version)),
- gcc(::make_spec(target, gcc_name, "gcc", gcc_version)),
- headers(::make_spec(target, headers_name, "linux-headers", headers_version)),
- libc(::make_spec(target, libc_name, "glibc", libc_version))
+bool
+AuxiliaryStage::is_rebuild() const
{
+ std::list<std::string> packages;
+ WhitespaceTokeniser::get_instance()->tokenise(TargetConfig::get_instance()->aux(), std::back_inserter(packages));
+
+ for (std::list<std::string>::const_iterator p(packages.begin()), p_end(packages.end()) ;
+ p != p_end ; ++p)
+ if ( _env->package_database()->query(
+ query::Matches(PackageDepSpec(*p)) &
+ query::InstalledAtRoot(_env->root()),
+ qo_whatever)->empty())
+ return false;
+
+ return true;
}
int
@@ -77,16 +61,20 @@ BinutilsStage::build(const StageOptions &) const
{
Context context("When building BinutilsStage:");
- _options.environment->clear_forced_use();
+ std::tr1::shared_ptr<PackageDepSpec> binutils(new PackageDepSpec(TargetConfig::get_instance()->binutils(),
+ pds_pm_unspecific));
- return 0 == do_install(_options.environment, _options.binutils);
+ _env->clear_forced_use();
+
+ return 0 == do_install(_env, stringify(*binutils));
}
bool
BinutilsStage::is_rebuild() const
{
- return (! _options.environment->package_database()->query(
- query::Matches(*_options.binutils) & query::InstalledAtRoot(_options.environment->root()),
+ return (! _env->package_database()->query(
+ query::Matches(PackageDepSpec(TargetConfig::get_instance()->binutils(), pds_pm_unspecific)) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever)->empty());
}
@@ -95,20 +83,22 @@ KernelHeadersStage::build(const StageOptions &) const
{
Context context("When building KernelHeadersStage:");
- _options.environment->clear_forced_use();
+ std::tr1::shared_ptr<PackageDepSpec> headers(new PackageDepSpec(TargetConfig::get_instance()->headers(),
+ pds_pm_unspecific));
+
+ _env->clear_forced_use();
- _options.environment->force_use(
- _options.headers, UseFlagName("crosscompile_opts_headers-only"),
- use_disabled);
+ _env->force_use(headers, UseFlagName("crosscompile_opts_headers-only"), use_enabled);
- return 0 == do_install(_options.environment, _options.headers);
+ return 0 == do_install(_env, stringify(*headers));
}
bool
KernelHeadersStage::is_rebuild() const
{
- return (! _options.environment->package_database()->query(
- query::Matches(*_options.headers) & query::InstalledAtRoot(_options.environment->root()),
+ return (! _env->package_database()->query(
+ query::Matches(PackageDepSpec(TargetConfig::get_instance()->headers(), pds_pm_unspecific)) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever)->empty());
}
@@ -117,27 +107,31 @@ MinimalStage::build(const StageOptions &) const
{
Context context("When executing MinimalStage:");
- _options.environment->clear_forced_use();
+ std::tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
+ pds_pm_unspecific));
- _options.environment->force_use(_options.gcc, UseFlagName("boundschecking"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("fortran"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("gtk"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("gcj"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("mudflap"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("objc"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("objc-gc"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("nocxx"), use_enabled);
- _options.environment->force_use(_options.gcc, UseFlagName("crosscompile_opts_bootstrap"), use_enabled);
+ _env->clear_forced_use();
- return 0 == do_install(_options.environment, _options.gcc);
+ _env->force_use(gcc, UseFlagName("boundschecking"), use_disabled);
+ _env->force_use(gcc, UseFlagName("fortran"), use_disabled);
+ _env->force_use(gcc, UseFlagName("gtk"), use_disabled);
+ _env->force_use(gcc, UseFlagName("gcj"), use_disabled);
+ _env->force_use(gcc, UseFlagName("mudflap"), use_disabled);
+ _env->force_use(gcc, UseFlagName("objc"), use_disabled);
+ _env->force_use(gcc, UseFlagName("objc-gc"), use_disabled);
+ _env->force_use(gcc, UseFlagName("nocxx"), use_enabled);
+ _env->force_use(gcc, UseFlagName("crosscompile_opts_bootstrap"), use_enabled);
+
+ return 0 == do_install(_env, stringify(*gcc));
}
bool
MinimalStage::is_rebuild() const
{
- return (! _options.environment->package_database()->query(
- query::Matches(*_options.gcc) & query::InstalledAtRoot(_options.environment->root()),
- qo_whatever)->empty());
+ return (! _env->package_database()->query(
+ query::Matches(PackageDepSpec(TargetConfig::get_instance()->gcc(), pds_pm_unspecific)) &
+ query::InstalledAtRoot(_env->root()),
+ qo_whatever)->empty());
}
int
@@ -145,23 +139,26 @@ LibCStage::build(const StageOptions &) const
{
Context context("When building LibCStage:");
- _options.environment->clear_forced_use();
+ std::tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(TargetConfig::get_instance()->libc(),
+ pds_pm_unspecific));
+
+ _env->clear_forced_use();
- return 0 == do_install(_options.environment, _options.libc);
+ return 0 == do_install(_env, stringify(*libc));
}
bool
LibCStage::is_rebuild() const
{
- std::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(
- _options.environment->package_database()->query(
- query::Matches(*_options.libc) & query::InstalledAtRoot(_options.environment->root()),
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(_env->package_database()->query(
+ query::Matches(PackageDepSpec(TargetConfig::get_instance()->libc(), pds_pm_unspecific)) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever));
if (c->empty())
return false;
- return (! _options.environment->query_use(UseFlagName("crosscompile_opts_headers-only"), &(*c->last())));
+ return (! _env->query_use(UseFlagName("crosscompile_opts_headers-only"), &(*c->last())));
}
int
@@ -169,28 +166,32 @@ FullStage::build(const StageOptions &) const
{
Context context("When building FullStage:");
- _options.environment->clear_forced_use();
+ std::tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
+ pds_pm_unspecific));
- _options.environment->force_use(_options.gcc, UseFlagName("boundschecking"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("gtk"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("gcj"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("mudflap"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("objc"), use_disabled);
- _options.environment->force_use(_options.gcc, UseFlagName("objc-gc"), use_disabled);
+ _env->clear_forced_use();
- return 0 == do_install(_options.environment, _options.gcc);
+ _env->force_use(gcc, UseFlagName("boundschecking"), use_disabled);
+ _env->force_use(gcc, UseFlagName("gtk"), use_disabled);
+ _env->force_use(gcc, UseFlagName("gcj"), use_disabled);
+ _env->force_use(gcc, UseFlagName("mudflap"), use_disabled);
+ _env->force_use(gcc, UseFlagName("objc"), use_disabled);
+ _env->force_use(gcc, UseFlagName("objc-gc"), use_disabled);
+
+ return 0 == do_install(_env, stringify(*gcc));
}
bool
FullStage::is_rebuild() const
{
- std::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(
- _options.environment->package_database()->query(
- query::Matches(*_options.gcc) & query::InstalledAtRoot(_options.environment->root()), qo_whatever));
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(_env->package_database()->query(
+ query::Matches(PackageDepSpec(TargetConfig::get_instance()->gcc(), pds_pm_unspecific)) &
+ query::InstalledAtRoot(_env->root()),
+ qo_whatever));
if (c->empty())
return false;
- return (! _options.environment->query_use(UseFlagName("nocxx"), &(*c->last())));
+ return (! _env->query_use(UseFlagName("nocxx"), &(*c->last())));
}
diff --git a/src/clients/contrarius/stage.hh b/src/clients/contrarius/stage.hh
index 4779bd1..312d149 100644
--- a/src/clients/contrarius/stage.hh
+++ b/src/clients/contrarius/stage.hh
@@ -37,21 +37,45 @@ namespace paludis
public StageBase
{
protected:
- ContrariusStageOptions _options;
+ std::tr1::shared_ptr<Environment> _env;
public:
- ContrariusStage(const ContrariusStageOptions & o) :
- _options(o)
+ ContrariusStage(std::tr1::shared_ptr<Environment> e) :
+ _env(e)
{
}
};
+ class AuxiliaryStage :
+ public ContrariusStage
+ {
+ public:
+ AuxiliaryStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
+ {
+ }
+
+ virtual int build(const StageOptions &) const;
+
+ virtual std::string description() const
+ {
+ return "Building auxiliary dependencies of the cross toolchain";
+ }
+
+ virtual bool is_rebuild() const;
+
+ virtual std::string short_name() const
+ {
+ return "cross-auxiliary stage";
+ }
+ };
+
class BinutilsStage :
public ContrariusStage
{
public:
- BinutilsStage(const ContrariusStageOptions & o) :
- ContrariusStage(o)
+ BinutilsStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
{
}
@@ -59,8 +83,7 @@ namespace paludis
virtual std::string description() const
{
- return "Building the GNU binutils (" + stringify(*_options.binutils)
- + ") as part of the cross toolchain";
+ return "Building the GNU binutils as part of the cross toolchain";
};
virtual bool is_rebuild() const;
@@ -75,8 +98,8 @@ namespace paludis
public ContrariusStage
{
public:
- KernelHeadersStage(const ContrariusStageOptions & o) :
- ContrariusStage(o)
+ KernelHeadersStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
{
}
@@ -84,8 +107,7 @@ namespace paludis
virtual std::string description() const
{
- return "Building the kernel headers (" + stringify(*_options.headers)
- + ") as part of the cross toolchain";
+ return "Building the kernel headers as part of the cross toolchain";
};
virtual bool is_rebuild() const;
@@ -100,8 +122,8 @@ namespace paludis
public ContrariusStage
{
public:
- MinimalStage(const ContrariusStageOptions & o) :
- ContrariusStage(o)
+ MinimalStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
{
}
@@ -109,8 +131,7 @@ namespace paludis
virtual std::string description() const
{
- return "Building a minimal GNU C compiler (" + stringify(*_options.gcc)
- + ") as part of the cross toolchain";
+ return "Building a minimal GNU C compiler as part of the cross toolchain";
};
virtual bool is_rebuild() const;
@@ -125,8 +146,8 @@ namespace paludis
public ContrariusStage
{
public:
- LibCStage(const ContrariusStageOptions & o) :
- ContrariusStage(o)
+ LibCStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
{
}
@@ -134,8 +155,7 @@ namespace paludis
virtual std::string description() const
{
- return "Building C standard library (" + stringify(*_options.gcc)
- + ") as part of the cross toolchain";
+ return "Building the C standard library as part of the cross toolchain";
};
virtual bool is_rebuild() const;
@@ -151,8 +171,8 @@ namespace paludis
public ContrariusStage
{
public:
- FullStage(const ContrariusStageOptions & o) :
- ContrariusStage(o)
+ FullStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(e)
{
}
@@ -160,8 +180,7 @@ namespace paludis
virtual std::string description() const
{
- return "Building full GNU compiler collection (" + stringify(*_options.gcc)
- + ") as part of the cross toolchain";
+ return "Building the full GNU compiler collection as part of the cross toolchain";
};
virtual bool is_rebuild() const;