aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-08 23:41:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-08 23:41:52 +0000
commit42df6101694290420b1641d4a4f03816150fcc7b (patch)
treeb3d20ba7a37ee0f281f80439e487da7ff95706f2 /src
parent1e3f66540816679cd156156d6454ac8726d64ac9 (diff)
downloadpaludis-42df6101694290420b1641d4a4f03816150fcc7b.tar.gz
paludis-42df6101694290420b1641d4a4f03816150fcc7b.tar.xz
Metadata options for importare
Diffstat (limited to 'src')
-rw-r--r--src/clients/importare/command_line.cc15
-rw-r--r--src/clients/importare/command_line.hh6
-rw-r--r--src/clients/importare/importare.cc47
3 files changed, 68 insertions, 0 deletions
diff --git a/src/clients/importare/command_line.cc b/src/clients/importare/command_line.cc
index abddbe5..f604d4d 100644
--- a/src/clients/importare/command_line.cc
+++ b/src/clients/importare/command_line.cc
@@ -46,6 +46,13 @@ CommandLine::CommandLine() :
"Options affecting the source image"),
a_location(&source_args, "location", 'l', "Location of source image (default: current directory)"),
+ metadata_args(this, "Metadata options",
+ "Options affecting generated metadata"),
+ a_description(&metadata_args, "description", 'D', "Specify a package description"),
+ a_build_dependency(&metadata_args, "build-dependency", 'B', "Specify a build dependency"),
+ a_run_dependency(&metadata_args, "run-dependency", 'R', "Specify a run dependency"),
+ a_preserve_metadata(&metadata_args, "preserve-metadata", 'P', "If replacing a package, copy its description and dependencies"),
+
install_args(this, "Install options",
"Options which are relevant for --install"),
@@ -78,6 +85,14 @@ CommandLine::CommandLine() :
"from an autotools package) as 'unpackaged/myapp' version 1.23. If 'unpackaged/myapp' is already installed, "
"it will be replaced.");
add_example(
+ "importare --location img/ unpackaged/myapp 1.23 --run-dependency dev-libs/mpfr --run-dependency dev-libs/gmp",
+ "As above, and add dependencies. Dependencies are used for resolution and to provide correct output for "
+ "paludis --uninstall(-unused).");
+ add_example(
+ "importare --location img/ unpackaged/myapp 1.23 --preserve-metadata",
+ "If an existing version of unpackaged/myapp was installed using importare, copies metadata (build and run "
+ "dependencies, and description) from that version.");
+ add_example(
"importare --location /var/empty sys-apps/portage 2.2",
"Install an empty fake package named 'sys-apps/portage', version 2.2. DANGEROUS!");
}
diff --git a/src/clients/importare/command_line.hh b/src/clients/importare/command_line.hh
index d66371c..90405d4 100644
--- a/src/clients/importare/command_line.hh
+++ b/src/clients/importare/command_line.hh
@@ -56,6 +56,12 @@ class CommandLine :
paludis::args::ArgsGroup source_args;
paludis::args::StringArg a_location;
+ paludis::args::ArgsGroup metadata_args;
+ paludis::args::StringArg a_description;
+ paludis::args::StringSetArg a_build_dependency;
+ paludis::args::StringSetArg a_run_dependency;
+ paludis::args::SwitchArg a_preserve_metadata;
+
paludis::args::InstallArgsGroup install_args;
paludis::args::DepListArgsGroup dl_args;
};
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index add6127..7125dea 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -31,6 +31,10 @@
#include <paludis/about.hh>
#include <paludis/repository_maker.hh>
#include <paludis/fuzzy_finder.hh>
+#include <paludis/query.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/stringify_formatter.hh>
#include <algorithm>
#include <iterator>
@@ -121,6 +125,46 @@ main(int argc, char *argv[])
VersionSpec v(params.size() >= 2 ? params[1] : "0");
SlotName s(params.size() >= 3 ? params[2] : "0");
+ std::string build_dependencies, run_dependencies, description;
+
+ if (CommandLine::get_instance()->a_preserve_metadata.specified())
+ {
+ tr1::shared_ptr<const PackageIDSequence> old_ids(
+ env->package_database()->query(query::Package(q), qo_order_by_version));
+ tr1::shared_ptr<const PackageID> old_id;
+ for (PackageIDSequence::ConstIterator i(old_ids->begin()), i_end(old_ids->end()) ;
+ i != i_end ; ++i)
+ {
+ if ((*i)->repository()->format() != "installed_unpackaged")
+ continue;
+ old_id = *i;
+ break;
+ }
+
+ if (! old_id)
+ throw args::DoHelp("--" + CommandLine::get_instance()->a_preserve_metadata.long_name() + " specified but "
+ "no old ID available");
+
+ StringifyFormatter f;
+ if (old_id->short_description_key())
+ description = old_id->short_description_key()->value();
+ if (old_id->build_dependencies_key())
+ build_dependencies = old_id->build_dependencies_key()->pretty_print_flat(f);
+ if (old_id->run_dependencies_key())
+ run_dependencies = old_id->run_dependencies_key()->pretty_print_flat(f);
+ }
+
+ if (CommandLine::get_instance()->a_description.specified())
+ description = CommandLine::get_instance()->a_description.argument();
+ if (CommandLine::get_instance()->a_build_dependency.specified())
+ build_dependencies = join(
+ CommandLine::get_instance()->a_build_dependency.begin_args(),
+ CommandLine::get_instance()->a_build_dependency.end_args(), ", ");
+ if (CommandLine::get_instance()->a_run_dependency.specified())
+ run_dependencies = join(
+ CommandLine::get_instance()->a_run_dependency.begin_args(),
+ CommandLine::get_instance()->a_run_dependency.end_args(), ", ");
+
tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("location", stringify(
CommandLine::get_instance()->a_location.specified() ?
@@ -130,6 +174,9 @@ main(int argc, char *argv[])
keys->insert("name", stringify(q));
keys->insert("version", stringify(v));
keys->insert("slot", stringify(s));
+ keys->insert("description", description);
+ keys->insert("build_dependencies", build_dependencies);
+ keys->insert("run_dependencies", run_dependencies);
tr1::shared_ptr<Repository> repo((*RepositoryMaker::get_instance()->find_maker("unpackaged"))(env.get(), keys));
env->package_database()->add_repository(10, repo);
tr1::shared_ptr<const PackageIDSequence> ids(repo->package_ids(q));