aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-21 13:13:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-21 13:13:59 +0000
commitef30feada12c02381e32b649b132e6a6c5efaf25 (patch)
tree25e069e0a7a8dcacaee95ba53856570b075ad122
parentedb238fcd23455460b8011da94290c0127d53d8d (diff)
downloadpaludis-ef30feada12c02381e32b649b132e6a6c5efaf25.tar.gz
paludis-ef30feada12c02381e32b649b132e6a6c5efaf25.tar.xz
importare --install-under
-rw-r--r--NEWS2
-rw-r--r--paludis/merger-fwd.hh3
-rw-r--r--paludis/merger.cc26
-rw-r--r--paludis/merger.hh1
-rw-r--r--paludis/merger_TEST.cc6
-rw-r--r--paludis/ndbam_merger.cc10
-rw-r--r--paludis/ndbam_merger.hh1
-rw-r--r--paludis/ndbam_merger.sr1
-rw-r--r--paludis/repositories/e/exndbam_repository.cc1
-rw-r--r--paludis/repositories/e/vdb_merger.cc10
-rw-r--r--paludis/repositories/e/vdb_merger.hh1
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc13
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc3
-rw-r--r--paludis/repositories/unpackaged/registration.cc7
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc4
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.sr1
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc59
-rwxr-xr-xpaludis/repositories/unpackaged/unpackaged_repository_TEST_setup.sh9
-rw-r--r--paludis/util/fs_entry.cc5
-rw-r--r--paludis/util/fs_entry_TEST.cc4
-rw-r--r--paludis/util/keys.hh1
-rw-r--r--src/clients/importare/command_line.cc3
-rw-r--r--src/clients/importare/command_line.hh3
-rw-r--r--src/clients/importare/importare.cc6
24 files changed, 168 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index d220830..75a7553 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ trunk/:
* All ruby demos are now installed with the executable bit set, and a
symlink for playman is installed in $(bindir).
+ * importare now has an --install-under option.
+
0.26.0_alpha12:
* The merger is able to detect hardlinks and tries to merge them as such.
diff --git a/paludis/merger-fwd.hh b/paludis/merger-fwd.hh
index 9ef7709..991d6a8 100644
--- a/paludis/merger-fwd.hh
+++ b/paludis/merger-fwd.hh
@@ -67,7 +67,8 @@ namespace paludis
kc::Field<k::image, FSEntry>,
kc::Field<k::root, FSEntry>,
kc::Field<k::no_chown, bool>,
- kc::Field<k::options, MergerOptions>
+ kc::Field<k::options, MergerOptions>,
+ kc::Field<k::install_under, FSEntry>
> MergerParams;
class MergerError;
diff --git a/paludis/merger.cc b/paludis/merger.cc
index 9abaa18..162bd40 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -18,7 +18,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "merger.hh"
+#include <paludis/merger.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/fd_holder.hh>
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <errno.h>
#include <cstring>
+#include <list>
using namespace paludis;
@@ -66,7 +67,7 @@ Merger::check()
("INSTALL_DESTINATION", stringify(_params[k::root()])))).max_exit_status)
make_check_fail();
- do_dir_recursive(true, _params[k::image()], _params[k::root()]);
+ do_dir_recursive(true, _params[k::image()], _params[k::root()] / _params[k::install_under()]);
if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_post")
@@ -111,7 +112,26 @@ Merger::merge()
Log::get_instance()->message(ll_warning, lc_context,
"Merge of '" + stringify(_params[k::image()]) + "' to '" + stringify(_params[k::root()]) + "' pre hooks returned non-zero");
- do_dir_recursive(false, _params[k::image()], _params[k::root()].realpath());
+ /* special handling for install_under */
+ {
+ Context local_context("When preparing install_under directory '" + stringify(_params[k::install_under()]) + "' under root '"
+ + stringify(_params[k::root()]) + "':");
+
+ std::list<FSEntry> dd;
+ for (FSEntry d(_params[k::root()].realpath() / _params[k::install_under()]), d_end(_params[k::root()].realpath()) ;
+ d != d_end ; d = d.dirname())
+ dd.push_front(d);
+ for (std::list<FSEntry>::iterator d(dd.begin()), d_end(dd.end()) ; d != d_end ; ++d)
+ if (! d->exists())
+ {
+ d->mkdir();
+ record_install_under_dir(*d, MergeStatusFlags());
+ }
+ else
+ record_install_under_dir(*d, MergeStatusFlags() + msi_used_existing);
+ }
+
+ do_dir_recursive(false, _params[k::image()], (_params[k::root()] / _params[k::install_under()]).realpath());
if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_post")
diff --git a/paludis/merger.hh b/paludis/merger.hh
index 2e0125b..6477cd7 100644
--- a/paludis/merger.hh
+++ b/paludis/merger.hh
@@ -148,6 +148,7 @@ namespace paludis
virtual MergeStatusFlags install_dir(const FSEntry &, const FSEntry &) PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void unlink_dir(FSEntry);
virtual void record_install_dir(const FSEntry &, const FSEntry &, const MergeStatusFlags &) = 0;
+ virtual void record_install_under_dir(const FSEntry &, const MergeStatusFlags &) = 0;
virtual void on_sym(bool is_check, const FSEntry &, const FSEntry &);
virtual void on_sym_over_nothing(bool is_check, const FSEntry &, const FSEntry &);
diff --git a/paludis/merger_TEST.cc b/paludis/merger_TEST.cc
index 9c34492..8ca6b68 100644
--- a/paludis/merger_TEST.cc
+++ b/paludis/merger_TEST.cc
@@ -98,6 +98,10 @@ namespace
{
}
+ virtual void record_install_under_dir(const FSEntry &, const MergeStatusFlags &)
+ {
+ }
+
void on_error(bool is_check, const std::string & s)
{
if (is_check)
@@ -151,6 +155,7 @@ namespace
merger(MergerParams::named_create()
(k::image(), image_dir)
(k::root(), root_dir)
+ (k::install_under(), FSEntry("/"))
(k::environment(), &env)
(k::no_chown(), true)
(k::options(), MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
@@ -165,6 +170,7 @@ namespace
merger(MergerParams::named_create()
(k::image(), image_dir)
(k::root(), root_dir)
+ (k::install_under(), FSEntry("/"))
(k::environment(), &env)
(k::no_chown(), true)
(k::options(), o))
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index 39f9a5f..5025cf6 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -70,6 +70,7 @@ NDBAMMerger::NDBAMMerger(const NDBAMMergerParams & p) :
(k::image(), p.image)
(k::root(), p.root)
(k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
+ (k::install_under(), p.install_under)
(k::options(), p.options)),
PrivateImplementationPattern<NDBAMMerger>(new Implementation<NDBAMMerger>(p))
{
@@ -172,6 +173,15 @@ NDBAMMerger::record_install_dir(const FSEntry & src, const FSEntry & dst_dir, co
}
void
+NDBAMMerger::record_install_under_dir(const FSEntry & dst, const MergeStatusFlags & flags)
+{
+ std::string tidy(stringify(dst.strip_leading(_imp->realroot)));
+ display_override(make_arrows(flags) + " [dir] " + tidy);
+
+ *_imp->contents_file << "type=dir path=" << escape(tidy) << std::endl;
+}
+
+void
NDBAMMerger::record_install_sym(const FSEntry & src, const FSEntry & dst_dir, const MergeStatusFlags & flags)
{
std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
diff --git a/paludis/ndbam_merger.hh b/paludis/ndbam_merger.hh
index 6cd6e0c..ea64c67 100644
--- a/paludis/ndbam_merger.hh
+++ b/paludis/ndbam_merger.hh
@@ -49,6 +49,7 @@ namespace paludis
virtual void record_install_file(const FSEntry &, const FSEntry &, const std::string &, const MergeStatusFlags &);
virtual void record_install_dir(const FSEntry &, const FSEntry &, const MergeStatusFlags &);
+ virtual void record_install_under_dir(const FSEntry &, const MergeStatusFlags &);
virtual void record_install_sym(const FSEntry &, const FSEntry &, const MergeStatusFlags &);
virtual void on_error(bool is_check, const std::string &);
diff --git a/paludis/ndbam_merger.sr b/paludis/ndbam_merger.sr
index 7e62760..36f6ef9 100644
--- a/paludis/ndbam_merger.sr
+++ b/paludis/ndbam_merger.sr
@@ -8,6 +8,7 @@ make_class_NDBAMMergerParams()
key environment "Environment *"
key image "FSEntry"
key root "FSEntry"
+ key install_under "FSEntry"
key contents_file "FSEntry"
key config_protect std::string
key config_protect_mask std::string
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index 06e3643..a81e8e2 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -331,6 +331,7 @@ ExndbamRepository::merge(const MergeParams & m)
.environment(_imp->params.environment)
.image(m[k::image_dir()])
.root(installed_root_key()->value())
+ .install_under(FSEntry("/"))
.contents_file(target_ver_dir / "contents")
.config_protect(config_protect)
.config_protect_mask(config_protect_mask)
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 9c10cc7..d62a470 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -66,6 +66,7 @@ VDBMerger::VDBMerger(const VDBMergerParams & p) :
Merger(MergerParams::named_create()
(k::environment(), p[k::environment()])
(k::image(), p[k::image()])
+ (k::install_under(), FSEntry("/"))
(k::root(), p[k::root()])
(k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
(k::options(), p[k::options()])),
@@ -141,6 +142,15 @@ VDBMerger::record_install_dir(const FSEntry & src, const FSEntry & dst_dir, cons
}
void
+VDBMerger::record_install_under_dir(const FSEntry & dst_dir, const MergeStatusFlags & flags)
+{
+ std::string tidy(stringify(dst_dir.strip_leading(_imp->realroot)));
+ display_override(make_arrows(flags) + " [dir] " + tidy);
+
+ *_imp->contents_file << "dir " << tidy << std::endl;
+}
+
+void
VDBMerger::record_install_sym(const FSEntry & src, const FSEntry & dst_dir, const MergeStatusFlags & flags)
{
std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
diff --git a/paludis/repositories/e/vdb_merger.hh b/paludis/repositories/e/vdb_merger.hh
index 2ff780d..9cc6a6c 100644
--- a/paludis/repositories/e/vdb_merger.hh
+++ b/paludis/repositories/e/vdb_merger.hh
@@ -77,6 +77,7 @@ namespace paludis
virtual void record_install_file(const FSEntry &, const FSEntry &, const std::string &, const MergeStatusFlags &);
virtual void record_install_dir(const FSEntry &, const FSEntry &, const MergeStatusFlags &);
+ virtual void record_install_under_dir(const FSEntry &, const MergeStatusFlags &);
virtual void record_install_sym(const FSEntry &, const FSEntry &, const MergeStatusFlags &);
virtual void on_error(bool is_check, const std::string &);
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index aeca2f7..4725854 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -31,6 +31,7 @@
#include <paludis/util/system.hh>
#include <paludis/util/cookie.hh>
#include <paludis/util/kc.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/stringify_formatter.hh>
#include <paludis/action.hh>
#include <paludis/environment.hh>
@@ -226,6 +227,17 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
if (! is_suitable_destination_for(*m[k::package_id()]))
throw InstallActionError("Not a suitable destination for '" + stringify(*m[k::package_id()]) + "'");
+ FSEntry install_under("/");
+ {
+ Repository::MetadataConstIterator k(m[k::package_id()]->repository()->find_metadata("install_under"));
+ if (k == m[k::package_id()]->repository()->end_metadata())
+ throw InstallActionError("Could not fetch install_under key from owning repository");
+ const MetadataValueKey<FSEntry> * kk(visitor_cast<const MetadataValueKey<FSEntry> >(**k));
+ if (! kk)
+ throw InstallActionError("Fetched install_under key but did not get an FSEntry key from owning repository");
+ install_under = kk->value();
+ }
+
tr1::shared_ptr<const PackageID> if_overwritten_id, if_same_name_id;
{
tr1::shared_ptr<const PackageIDSequence> ids(package_ids(m[k::package_id()]->name()));
@@ -298,6 +310,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
NDBAMMergerParams::create()
.environment(_imp->params.environment)
.image(m[k::image_dir()])
+ .install_under(install_under)
.root(installed_root_key()->value())
.contents_file(target_ver_dir / "contents")
.config_protect(getenv_with_default("CONFIG_PROTECT", ""))
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index 0b15a73..0245c95 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -376,6 +376,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4a"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -431,6 +432,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4b1"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -488,6 +490,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4b2"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index f1b122c..d85c5dd 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -40,6 +40,10 @@ namespace
if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'location' not specified or empty");
+ std::string install_under;
+ if (m->end() == m->find("install_under") || ((install_under = m->find("install_under")->second)).empty())
+ install_under = "/";
+
std::string name;
if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'name' not specified or empty");
@@ -68,6 +72,7 @@ namespace
unpackaged_repositories::UnpackagedRepositoryParams::create()
.environment(env)
.location(location)
+ .install_under(install_under)
.name(QualifiedPackageName(name))
.version(VersionSpec(version))
.slot(SlotName(slot))
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index 58f4f29..7061af0 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -46,6 +46,7 @@ namespace paludis
tr1::shared_ptr<CategoryNamePartSet> category_names;
tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key;
+ tr1::shared_ptr<const MetadataValueKey<FSEntry> > install_under_key;
tr1::shared_ptr<const MetadataValueKey<std::string> > name_key;
tr1::shared_ptr<const MetadataValueKey<std::string> > slot_key;
tr1::shared_ptr<const MetadataValueKey<std::string> > format_key;
@@ -63,6 +64,8 @@ namespace paludis
category_names(new CategoryNamePartSet),
location_key(new LiteralMetadataValueKey<FSEntry> ("location", "location",
mkt_significant, params.location)),
+ install_under_key(new LiteralMetadataValueKey<FSEntry> ("install_under", "install_under",
+ mkt_significant, params.install_under)),
name_key(new LiteralMetadataValueKey<std::string> ("name", "name",
mkt_normal, stringify(params.name))),
slot_key(new LiteralMetadataValueKey<std::string> ("slot", "slot",
@@ -114,6 +117,7 @@ UnpackagedRepository::_add_metadata_keys() const
{
clear_metadata_keys();
add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->install_under_key);
add_metadata_key(_imp->name_key);
add_metadata_key(_imp->slot_key);
add_metadata_key(_imp->format_key);
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.sr b/paludis/repositories/unpackaged/unpackaged_repository.sr
index 366006c..65043d5 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.sr
+++ b/paludis/repositories/unpackaged/unpackaged_repository.sr
@@ -7,6 +7,7 @@ make_class_UnpackagedRepositoryParams()
key environment "Environment *"
key location FSEntry
+ key install_under FSEntry
key name QualifiedPackageName
key version VersionSpec
key slot SlotName
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index a6b4dfc..09f64e8 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -54,6 +54,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -82,6 +83,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -115,6 +117,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -143,6 +146,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -184,6 +188,7 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .install_under(FSEntry("/"))
.build_dependencies("")
.run_dependencies("")
.description("")
@@ -220,5 +225,59 @@ namespace test_cases
return false;
}
} test_install;
+
+ struct InstallUnderTest : TestCase
+ {
+ InstallUnderTest() : TestCase("install under") { }
+
+ void run()
+ {
+ TestEnvironment env;
+
+ tr1::shared_ptr<Repository> repo(new UnpackagedRepository(
+ RepositoryName("unpackaged"),
+ unpackaged_repositories::UnpackagedRepositoryParams::create()
+ .environment(&env)
+ .name(QualifiedPackageName("cat/pkg"))
+ .version(VersionSpec("1.0"))
+ .slot(SlotName("foo"))
+ .location(FSEntry("unpackaged_repository_TEST_dir/under_pkg"))
+ .install_under(FSEntry("/magic/pixie"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
+ ));
+ env.package_database()->add_repository(1, repo);
+
+ tr1::shared_ptr<Repository> installed_repo(new InstalledUnpackagedRepository(
+ RepositoryName("installed-unpackaged"),
+ unpackaged_repositories::InstalledUnpackagedRepositoryParams::create()
+ .environment(&env)
+ .location(FSEntry("unpackaged_repository_TEST_dir/under_installed"))
+ .root(FSEntry("unpackaged_repository_TEST_dir/under_root"))
+ ));
+ env.package_database()->add_repository(0, installed_repo);
+
+ TEST_CHECK(! FSEntry("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").is_regular_file());
+
+ const tr1::shared_ptr<const PackageID> id(
+ *env.package_database()->query(query::All(), qo_require_exactly_one)->begin());
+
+ InstallAction action(InstallActionOptions::named_create()
+ (k::no_config_protect(), false)
+ (k::debug_build(), iado_none)
+ (k::checks(), iaco_default)
+ (k::destination(), installed_repo)
+ );
+ id->perform_action(action);
+
+ TEST_CHECK(FSEntry("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").is_regular_file());
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+ } test_install_under;
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST_setup.sh b/paludis/repositories/unpackaged/unpackaged_repository_TEST_setup.sh
index 3c51723..0f29013 100755
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST_setup.sh
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST_setup.sh
@@ -9,6 +9,11 @@ cat <<"END" > pkg/first
This is the first file.
END
-mkdir -p root
-mkdir -p installed
+mkdir -p under_pkg
+cat <<"END" > under_pkg/first
+This is also the first file.
+END
+
+mkdir -p {under_,}root
+mkdir -p {under_,}installed
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index a83f712..2758a80 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
* Copyright (c) 2006 Mark Loeser
* Copyright (c) 2008 Fernando J. Pereda
*
@@ -149,6 +149,9 @@ FSEntry::operator= (const FSEntry & other)
const FSEntry &
FSEntry::operator/= (const FSEntry & rhs)
{
+ if (rhs._imp->path == "/")
+ return *this;
+
if (_imp->path.empty() || '/' != _imp->path.at(_imp->path.length() - 1))
_imp->path.append("/");
diff --git a/paludis/util/fs_entry_TEST.cc b/paludis/util/fs_entry_TEST.cc
index 0bc3b05..3eb1d5e 100644
--- a/paludis/util/fs_entry_TEST.cc
+++ b/paludis/util/fs_entry_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
* Copyright (c) 2006 Mark Loeser
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -102,6 +102,8 @@ namespace test_cases
TEST_CHECK_EQUAL(c, FSEntry("/foo/bar/moo"));
f = FSEntry::cwd();
+
+ TEST_CHECK_EQUAL(f, f / FSEntry("/"));
}
} test_fs_entry_manipulation;
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index 5dd1041..e9e886d 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -153,6 +153,7 @@ namespace paludis
typedef kc::Key<124> description_use;
typedef kc::Key<125> debug_dir;
typedef kc::Key<126> use_ebuild_file;
+ typedef kc::Key<127> install_under;
}
}
diff --git a/src/clients/importare/command_line.cc b/src/clients/importare/command_line.cc
index 6143c37..9c1e4f2 100644
--- a/src/clients/importare/command_line.cc
+++ b/src/clients/importare/command_line.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -45,6 +45,7 @@ CommandLine::CommandLine() :
source_args(this, "Source options",
"Options affecting the source image"),
a_location(&source_args, "location", 'l', "Location of source image (default: current directory)"),
+ a_install_under(&source_args, "install-under", 'u', "Install under a given directory (default: /)"),
metadata_args(this, "Metadata options",
"Options affecting generated metadata"),
diff --git a/src/clients/importare/command_line.hh b/src/clients/importare/command_line.hh
index 90405d4..1ddf7cf 100644
--- a/src/clients/importare/command_line.hh
+++ b/src/clients/importare/command_line.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -55,6 +55,7 @@ class CommandLine :
paludis::args::ArgsGroup source_args;
paludis::args::StringArg a_location;
+ paludis::args::StringArg a_install_under;
paludis::args::ArgsGroup metadata_args;
paludis::args::StringArg a_description;
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index 6597b8a..36a39b5 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -175,6 +175,10 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_location.specified() ?
FSEntry(CommandLine::get_instance()->a_location.argument()) :
FSEntry::cwd()));
+ keys->insert("install_under", stringify(
+ CommandLine::get_instance()->a_install_under.specified() ?
+ FSEntry(CommandLine::get_instance()->a_install_under.argument()) :
+ FSEntry("/")));
keys->insert("format", "unpackaged");
keys->insert("name", stringify(q));
keys->insert("version", stringify(v));