aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-03 23:47:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-03 23:47:00 +0000
commitc63f62adf8886154d4011e3885f86e6cb6df70f4 (patch)
tree16044bb5b75cafcbb846253d32fe215ad7747f58
parentf1b17a783b5a1094ff1baad368b17e34ab5cb706 (diff)
downloadpaludis-c63f62adf8886154d4011e3885f86e6cb6df70f4.tar.gz
paludis-c63f62adf8886154d4011e3885f86e6cb6df70f4.tar.xz
system target support
-rw-r--r--paludis/fake_repository.cc9
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc64
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/repository.hh14
-rw-r--r--paludis/vdb_repository.cc8
-rw-r--r--paludis/vdb_repository.hh2
-rw-r--r--src/command_line.hh10
-rw-r--r--src/install.cc36
-rw-r--r--src/paludis.cc12
10 files changed, 131 insertions, 28 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index fd8255e..f762137 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -215,3 +215,12 @@ void
FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &) const
{
}
+
+DepAtom::Pointer
+FakeRepository::do_system_packages() const
+{
+ AllDepAtom::Pointer result(new AllDepAtom);
+
+ return result;
+}
+
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 59fd5c9..71a75b9 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -81,6 +81,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual DepAtom::Pointer do_system_packages() const;
+
public:
/**
* Constructor.
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 9548dc3..985fb00 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -134,6 +134,9 @@ namespace paludis
/// Use.
mutable UseMap use;
+ /// Have virtual names?
+ mutable bool has_virtuals;
+
/// Old style virtuals name mapping.
mutable VirtualsMap virtuals_map;
@@ -158,6 +161,9 @@ namespace paludis
/// Profile env vars.
mutable ProfileEnvMap profile_env;
+ /// Sustem packages.
+ mutable AllDepAtom::Pointer system_packages;
+
/// Constructor.
Implementation(const Environment * const,
const PackageDatabase * const d, const FSEntry & l, const FSEntry & p,
@@ -184,9 +190,11 @@ Implementation<PortageRepository>::Implementation(const Environment * const env,
distdir(dd),
has_category_names(false),
has_repo_mask(false),
+ has_virtuals(false),
has_profile(false),
has_arch_list(false),
- has_mirrors(false)
+ has_mirrors(false),
+ system_packages(new AllDepAtom)
{
}
@@ -277,6 +285,23 @@ Implementation<PortageRepository>::add_profile(const FSEntry & f) const
PackageDepAtom::Pointer(new PackageDepAtom(tokens[1]))));
}
}
+
+ if ((f / "packages").exists())
+ {
+ Context context_local("When reading packages file:");
+
+ LineConfigFile virtuals_f(f / "packages");
+ for (LineConfigFile::Iterator line(virtuals_f.begin()), line_end(virtuals_f.end()) ;
+ line != line_end ; ++line)
+ {
+ if (line->empty() || '*' != line->at(0))
+ continue;
+
+ Context context_line("When parsing line '" + *line + "':");
+ system_packages->add_child(PackageDepAtom::Pointer(new PackageDepAtom(
+ line->substr(1))));
+ }
+ }
}
PortageRepository::PortageRepository(
@@ -803,18 +828,24 @@ PortageRepository::do_query_use_mask(const UseFlagName & u) const
void
PortageRepository::need_virtual_names() const
{
+ if (_imp->has_virtuals)
+ return;
+
if (! _imp->has_profile)
{
Context context("When loading virtual names:");
_imp->add_profile(_imp->profile.realpath());
_imp->has_profile = true;
-
- for (VirtualsMap::const_iterator
- v(_imp->virtuals_map.begin()), v_end(_imp->virtuals_map.end()) ;
- v != v_end ; ++v)
- _imp->package_names.insert(
- std::make_pair(v->first, false));
}
+
+ need_category_names();
+
+ for (VirtualsMap::const_iterator
+ v(_imp->virtuals_map.begin()), v_end(_imp->virtuals_map.end()) ;
+ v != v_end ; ++v)
+ _imp->package_names.insert(std::make_pair(v->first, false));
+
+ _imp->has_virtuals = true;
}
CountedPtr<Repository>
@@ -942,6 +973,12 @@ PortageRepository::do_is_mirror(const std::string & s) const
void
PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v) const
{
+ if (! _imp->has_profile)
+ {
+ _imp->add_profile(_imp->profile.realpath());
+ _imp->has_profile = true;
+ }
+
VersionMetadata::ConstPointer metadata(0);
if (! has_version(q, v))
{
@@ -1087,3 +1124,16 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
}
+DepAtom::Pointer
+PortageRepository::do_system_packages() const
+{
+ if (! _imp->has_profile)
+ {
+ Context c("When loading system packages list:");
+ _imp->add_profile(_imp->profile.realpath());
+ _imp->has_profile = true;
+ }
+
+ return _imp->system_packages;
+}
+
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index c103aa4..542b918 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -92,6 +92,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual DepAtom::Pointer do_system_packages() const;
+
public:
/**
* Constructor.
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 0edaae5..9274ba5 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORY_HH 1
+#include <paludis/dep_atom.hh>
#include <paludis/name.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/counted_ptr.hh>
@@ -152,6 +153,11 @@ namespace paludis
*/
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const = 0;
+ /**
+ * Override in descendents: system package list.
+ */
+ virtual DepAtom::Pointer do_system_packages() const = 0;
+
public:
/**
* Destructor.
@@ -381,6 +387,14 @@ namespace paludis
* No NVI indirection here, it's not worth it.
*/
virtual bool installed() const = 0;
+
+ /**
+ * Fetch our system packages list.
+ */
+ virtual DepAtom::Pointer system_packages() const
+ {
+ return do_system_packages();
+ }
};
/**
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 58afd31..b45c4d1 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -461,3 +461,11 @@ VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &) con
throw InternalError(PALUDIS_HERE, "TODO");
}
+DepAtom::Pointer
+VDBRepository::do_system_packages() const
+{
+ AllDepAtom::Pointer result(new AllDepAtom);
+
+ return result;
+}
+
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index e79410f..53ecce9 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -72,6 +72,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &,
const VersionSpec &) const PALUDIS_ATTRIBUTE((noreturn));
+ virtual DepAtom::Pointer do_system_packages() const;
+
public:
/**
* Constructor.
diff --git a/src/command_line.hh b/src/command_line.hh
index a047e20..ca4d581 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -160,4 +160,14 @@ class CommandLine :
/// }
};
+struct DoHelp
+{
+ const std::string message;
+
+ DoHelp(const std::string & m = "") :
+ message(m)
+ {
+ }
+};
+
#endif
diff --git a/src/install.cc b/src/install.cc
index 8d905cf..d4ac319 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -46,19 +46,37 @@ do_install()
CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
q_end(CommandLine::get_instance()->end_parameters());
+
+ bool had_set_targets(false), had_pkg_targets(false);
for ( ; q != q_end ; ++q)
{
- /* we might have a dep atom, but we might just have a simple package name
- * without a category. either should work. also allow full atoms, to make
- * it easy to test things like '|| ( foo/bar foo/baz )'. */
- if (std::string::npos != q->find('/'))
- targets->add_child(p::DepParser::parse(*q));
+ if (*q == "system")
+ {
+ had_set_targets = true;
+
+ for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ targets->add_child((*r)->system_packages());
+ }
else
- targets->add_child(p::DepAtom::Pointer(new p::PackageDepAtom(
- env->package_database()->fetch_unique_qualified_package_name(
- p::PackageNamePart(*q)))));
+ {
+ had_pkg_targets = true;
+
+ /* we might have a dep atom, but we might just have a simple package name
+ * without a category. either should work. also allow full atoms, to make
+ * it easy to test things like '|| ( foo/bar foo/baz )'. */
+ if (std::string::npos != q->find('/'))
+ targets->add_child(p::DepParser::parse(*q));
+ else
+ targets->add_child(p::DepAtom::Pointer(new p::PackageDepAtom(
+ env->package_database()->fetch_unique_qualified_package_name(
+ p::PackageNamePart(*q)))));
+ }
}
+ if (had_set_targets && had_pkg_targets)
+ throw DoHelp("You should not specify set and package targets at the same time.");
+
p::DepList dep_list(env);
dep_list.set_drop_self_circular(CommandLine::get_instance()->a_dl_drop_self_circular.specified());
dep_list.set_drop_circular(CommandLine::get_instance()->a_dl_drop_circular.specified());
@@ -121,7 +139,7 @@ do_install()
return return_code;
int current_count = 0, max_count = std::distance(dep_list.begin(), dep_list.end());
-
+
for (p::DepList::Iterator dep(dep_list.begin()), dep_end(dep_list.end()) ;
dep != dep_end ; ++dep)
{
diff --git a/src/paludis.cc b/src/paludis.cc
index 75e1407..f528956 100644
--- a/src/paludis.cc
+++ b/src/paludis.cc
@@ -38,21 +38,9 @@ using std::cout;
using std::cerr;
using std::endl;
-#ifndef DOXYGEN
-struct DoHelp
-{
- const std::string message;
-
- DoHelp(const std::string & m = "") :
- message(m)
- {
- }
-};
-
struct DoVersion
{
};
-#endif
int
main(int argc, char *argv[])