aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-11 00:14:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-11 00:14:49 +0000
commitebf4f209fa242c5f4388e74f33aa5cf1531ce3eb (patch)
tree93d2fe8d198ae767c9610d9aba287eb94ccecedb
parentf6d1a03fe17976d2fdcf95c7a3197f6852fa897a (diff)
downloadpaludis-ebf4f209fa242c5f4388e74f33aa5cf1531ce3eb.tar.gz
paludis-ebf4f209fa242c5f4388e74f33aa5cf1531ce3eb.tar.xz
Fake a categories file if one is not available
-rw-r--r--paludis/repositories/portage/portage_repository.cc34
1 files changed, 30 insertions, 4 deletions
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 637fdc5..127ce7e 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -441,11 +441,37 @@ PortageRepository::need_category_names() const
Context context("When loading category names for " + stringify(name()) + ":");
- LineConfigFile cats(_imp->params.location / "profiles" / "categories");
+ if (! (_imp->params.location / "profiles" / "categories").exists())
+ {
+ Log::get_instance()->message(ll_qa, lc_context, "No categories file for repository at '"
+ + stringify(_imp->params.location) + "', faking it");
+ for (DirIterator d(_imp->params.location), d_end ; d != d_end ; ++d)
+ {
+ if (! d->is_directory())
+ continue;
- for (LineConfigFile::Iterator line(cats.begin()), line_end(cats.end()) ;
- line != line_end ; ++line)
- _imp->category_names.insert(std::make_pair(CategoryNamePart(*line), false));
+ std::string n(d->basename());
+ if (n == "CVS" || n == "distfiles" || n == "scripts" || n == "eclass" || n == "licences"
+ || n == "packages")
+ continue;
+
+ try
+ {
+ _imp->category_names.insert(std::make_pair(CategoryNamePart(n), false));
+ }
+ catch (const NameError &)
+ {
+ }
+ }
+ }
+ else
+ {
+ LineConfigFile cats(_imp->params.location / "profiles" / "categories");
+
+ for (LineConfigFile::Iterator line(cats.begin()), line_end(cats.end()) ;
+ line != line_end ; ++line)
+ _imp->category_names.insert(std::make_pair(CategoryNamePart(*line), false));
+ }
_imp->has_category_names = true;
}