aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-02 13:35:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-02 13:35:17 +0000
commitfbe3f4eb235c2f8d3bb8bed193509555d3687ca8 (patch)
tree9e05c2fc673b4ab42411ed62080132a8f07669ea
parent53d1d9bd9acff62c69cc231d15a9b50c08923142 (diff)
downloadpaludis-fbe3f4eb235c2f8d3bb8bed193509555d3687ca8.tar.gz
paludis-fbe3f4eb235c2f8d3bb8bed193509555d3687ca8.tar.xz
Don't require XXXXXX in resume-command-template. Don't bother generating --add-to-world-spec if --preserve-world. Fixes: ticket:176. Fixes: ticket:209.
-rw-r--r--src/clients/paludis/command_line.cc2
-rw-r--r--src/clients/paludis/install.cc40
-rwxr-xr-xsrc/clients/paludis/install_TEST21
-rwxr-xr-xsrc/clients/paludis/install_TEST_setup.sh2
-rw-r--r--src/clients/paludis/paludis.cc8
5 files changed, 41 insertions, 32 deletions
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 29769be..f7f9b97 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -67,7 +67,7 @@ CommandLine::CommandLine() :
a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
a_no_color(&a_no_colour, "no-color"),
a_environment(&general_args, "environment", 'E', "Environment specification (class:suffix, both parts optional)"),
- a_resume_command_template(&general_args, "resume-command-template", '\0', "Save the resume command to a file made using mkstemp(3)"),
+ a_resume_command_template(&general_args, "resume-command-template", '\0', "Save the resume command to a file. If the filename contains 'XXXXXX', use mkstemp(3) to generate the filename"),
query_args(this, "Query options",
"Options which are relevant for --query."),
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index 6b56ffd..3814dca 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@@ -78,12 +79,15 @@ namespace
if (CommandLine::get_instance()->a_add_to_world_spec.specified())
resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
+ " '" + CommandLine::get_instance()->a_add_to_world_spec.argument() + "'";
- else if (task.had_set_targets())
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
- + " '( )'";
- else
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
- + " '( " + join(task.begin_targets(), task.end_targets(), " ") + " )'";
+ else if (! CommandLine::get_instance()->a_preserve_world.specified())
+ {
+ if (task.had_set_targets())
+ resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
+ + " '( )'";
+ else
+ resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
+ + " '( " + join(task.begin_targets(), task.end_targets(), " ") + " )'";
+ }
if (CommandLine::get_instance()->a_destinations.specified())
for (args::StringSetArg::Iterator i(CommandLine::get_instance()->a_destinations.begin_args()),
@@ -108,8 +112,17 @@ namespace
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());
- int fd(mkstemp(resume_template));
+ int fd;
+ if (std::string::npos == file_name.find("XXXXXX"))
+ fd = open(file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC);
+ else
+ {
+ char * resume_template = strdup(file_name.c_str());
+ fd = mkstemp(resume_template);
+ file_name = resume_template;
+ std::free(resume_template);
+ }
+
if (-1 != fd)
{
::fchmod(fd, 0644);
@@ -119,23 +132,22 @@ namespace
if (resume_command_file)
{
cerr << endl;
- cerr << "Resume command saved to file: " << resume_template;
+ cerr << "Resume command saved to file: " << file_name;
cerr << endl;
}
else
{
- cerr << "Resume command NOT saved to file: " << resume_template << " due to error "
+ cerr << "Resume command NOT saved to file: " << file_name << " due to error "
<< strerror(errno) << endl;
- cerr << "Resume command: " << resume_command << endl;
+ cerr << "Resume command: " << file_name << endl;
}
}
else
{
- cerr << "Resume command NOT saved to file: " << resume_template << " due to error "
+ cerr << "Resume command NOT saved to file: " << file_name << " due to error "
<< strerror(errno) << endl;
- cerr << "Resume command: " << resume_command << endl;
+ cerr << "Resume command: " << file_name << endl;
}
- std::free(resume_template);
}
else
{
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index 1929ad7..45b10ac 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -2,17 +2,20 @@
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
--has-version test-category/target && exit 1
+PALUDIS_INSTALL_TEST_DIE_PLEASE=yes \
+ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
+ --install target --resume-command-template `pwd`/install_TEST_dir/resume && exit 2
+( echo -n './paludis ' ; cut -d ' ' -f2- < install_TEST_dir/resume ) > install_TEST_dir/fixedresume
+PALUDIS_HOME=./install_TEST_dir/config/ bash `pwd`/install_TEST_dir/fixedresume || exit 3
+./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 4
+grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 5
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --install target || exit 2
-./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 3
-grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 4
+ --has-version test-category/target || exit 6
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --has-version test-category/target || exit 5
+ --uninstall target || exit 7
+[[ -f ./install_TEST_dir/root/usr/bin/testbin ]] && exit 8
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --uninstall target || exit 6
-[[ -f ./install_TEST_dir/root/usr/bin/testbin ]] && exit 7
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
- --has-version test-category/target && exit 8
-grep target install_TEST_dir/root/var/db/pkg/world >/dev/null && exit 9
+ --has-version test-category/target && exit 9
+grep target install_TEST_dir/root/var/db/pkg/world >/dev/null && exit 10
true
diff --git a/src/clients/paludis/install_TEST_setup.sh b/src/clients/paludis/install_TEST_setup.sh
index bcf616d..802a9b1 100755
--- a/src/clients/paludis/install_TEST_setup.sh
+++ b/src/clients/paludis/install_TEST_setup.sh
@@ -113,6 +113,8 @@ pkg_setup() {
use userland_test || die "bad use for userland"
use kernel_test || die "bad use for kernel"
use test || die "bad use for arch"
+
+ [[ -n "${PALUDIS_INSTALL_TEST_DIE_PLEASE}" ]] && die "told to die"
}
src_unpack() {
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index eef32c9..716122a 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -321,14 +321,6 @@ main(int argc, char *argv[])
try
{
- 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 args::DoHelp("resume-command-template must contain at least XXXXXX");
- }
-
if (CommandLine::get_instance()->a_list_sync_protocols.specified())
{
if (! CommandLine::get_instance()->empty())