aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2006-11-23 08:30:45 +0000
committerAvatar Mike Kelly <pioto@pioto.org> 2006-11-23 08:30:45 +0000
commitfcb88a945bf7bc64ef4d317b587eb1869626a203 (patch)
tree42b8620418a489ce4e09c8343d0355e772fc7bf9
parentbc31972e8c19b43d9861efa7ea00181a95081742 (diff)
downloadpaludis-fcb88a945bf7bc64ef4d317b587eb1869626a203.tar.gz
paludis-fcb88a945bf7bc64ef4d317b587eb1869626a203.tar.xz
Add the --resume-command-template option, to alternatively save the resume command in a file made with a call to mkstemp(3).
-rw-r--r--bash-completion/paludis1
-rw-r--r--src/paludis/command_line.cc1
-rw-r--r--src/paludis/command_line.hh3
-rw-r--r--src/paludis/install.cc27
-rw-r--r--src/paludis/paludis.cc8
5 files changed, 36 insertions, 4 deletions
diff --git a/bash-completion/paludis b/bash-completion/paludis
index 3b1bc6c..0e1eb78 100644
--- a/bash-completion/paludis
+++ b/bash-completion/paludis
@@ -38,6 +38,7 @@ _paludis() {
--no-colour \
--no-color \
--config-suffix -c \
+ --resume-command-template \
--show-slot -S \
--show-deps -D \
--show-metadata -M \
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index 2a947e4..1ffbbc6 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -65,6 +65,7 @@ CommandLine::CommandLine() :
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
a_no_color(&a_no_colour, "no-color"),
a_config_suffix(&general_args, "config-suffix", 'c', "Config directory suffix"),
+ a_resume_command_template(&general_args, "resume-command-template", '\0', "Save the resume command to a file made using mkstemp(3)"),
query_args(this, "Query options",
"Options which are relevant for --query."),
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index 1c8ee73..ffe7a73 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -148,6 +148,9 @@ class CommandLine :
/// --config-suffix
paludis::args::StringArg a_config_suffix;
+ /// --resume-command-template
+ paludis::args::StringArg a_resume_command_template;
+
///}
/// \name Query arguments
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index f606187..99fa9cb 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -25,12 +25,15 @@
#include <iostream>
#include <limits>
#include <set>
+#include <cstdlib>
+#include <cstring>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <paludis/tasks/install_task.hh>
+#include <paludis/util/fd_output_stream.hh>
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/environment/default/default_environment.hh>
@@ -599,8 +602,8 @@ namespace
if (task.current_dep_list_entry() != task.dep_list().end())
{
- cerr << "Resume command: " << DefaultEnvironment::get_instance()->paludis_command() << " "
- "--dl-installed-deps-pre discard "
+ std::string resume_command = DefaultEnvironment::get_instance()->paludis_command()
+ + " --dl-installed-deps-pre discard "
"--dl-installed-deps-runtime discard "
"--dl-installed-deps-post discard "
"--dl-uninstalled-deps-pre discard "
@@ -610,8 +613,24 @@ namespace
for (DepList::Iterator i(task.current_dep_list_entry()), i_end(task.dep_list().end()) ;
i != i_end ; ++i)
if (! i->skip_install)
- cerr << " =" << i->package.name << "-" << i->package.version << "::" << i->package.repository;
- cerr << endl;
+ resume_command = resume_command + " ="
+ + stringify(i->package.name) + "-"
+ + stringify(i->package.version) + "::"
+ + stringify(i->package.repository);
+
+ if (CommandLine::get_instance()->a_resume_command_template.specified())
+ {
+ std::string file_name(CommandLine::get_instance()->a_resume_command_template.argument());
+ char* resume_template = strdup(file_name.c_str());
+ FDOutputStream resume_command_file(mkstemp(resume_template));
+ cerr << endl;
+ cerr << "Resume command saved to file: " << resume_template;
+ cerr << endl;
+ resume_command_file << resume_command << endl;
+ std::free(resume_template);
+ }
+ else
+ cerr << "Resume command: " << resume_command << endl;
}
}
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index 788eb14..fafb8b3 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -283,6 +283,14 @@ main(int argc, char *argv[])
throw;
}
+ if (CommandLine::get_instance()->a_resume_command_template.specified())
+ {
+ // The template should contain at least XXXXXX
+ std::string resume_template = CommandLine::get_instance()->a_resume_command_template.argument();
+ if (resume_template.find("XXXXXX", 0) == std::string::npos )
+ throw DoHelp("resume-command-template must contain at least XXXXXX");
+ }
+
if (CommandLine::get_instance()->a_info.specified())
{
display_version();