aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-01 00:58:56 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-01 00:58:56 +0000
commit49583055efb39760f34d430a9ce2727d02e5c7a9 (patch)
tree344dd4c2275e21cd8d199a7f0adc11e6ce6cb64e
parent74ca4f53127a71b7f4ef37d1175ac275d9799b4d (diff)
downloadpaludis-49583055efb39760f34d430a9ce2727d02e5c7a9.tar.gz
paludis-49583055efb39760f34d430a9ce2727d02e5c7a9.tar.xz
Don't lose world changes on resume command
-rw-r--r--ebuild/portage_stubs.bash4
-rw-r--r--paludis/tasks/install_task.cc28
-rw-r--r--paludis/tasks/install_task.hh3
-rw-r--r--src/clients/paludis/Makefile.am1
-rw-r--r--src/clients/paludis/command_line.cc4
-rw-r--r--src/clients/paludis/command_line.hh5
-rw-r--r--src/clients/paludis/install.cc56
-rwxr-xr-xsrc/clients/paludis/install_TEST9
-rwxr-xr-xsrc/clients/paludis/install_TEST_setup.sh9
-rw-r--r--src/clients/paludis/paludis.cc31
-rwxr-xr-xsrc/clients/paludis/upgrade_TEST2
11 files changed, 124 insertions, 28 deletions
diff --git a/ebuild/portage_stubs.bash b/ebuild/portage_stubs.bash
index bd5f96c..a5fa2b1 100644
--- a/ebuild/portage_stubs.bash
+++ b/ebuild/portage_stubs.bash
@@ -60,7 +60,9 @@ best_version()
vdb_path()
{
- ${PALUDIS_COMMAND} --configuration-variable installed location
+ if ! ${PALUDIS_COMMAND} --configuration-variable installed location ; then
+ die "Could not find vdb_path"
+ fi
}
check_KV()
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index c5ce92f..1ff0eb9 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -38,6 +38,7 @@ namespace paludis
std::list<std::string> raw_targets;
AllDepAtom::Pointer targets;
+ DepAtom::ConstPointer add_to_world_atom;
bool pretend;
bool preserve_world;
@@ -51,6 +52,7 @@ namespace paludis
current_dep_list_entry(dep_list.begin()),
install_options(false, false, ido_none),
targets(new AllDepAtom),
+ add_to_world_atom(0),
pretend(false),
preserve_world(false),
had_set_targets(false),
@@ -95,6 +97,7 @@ InstallTask::add_target(const std::string & target)
Context context("When adding install target '" + target + "':");
DepAtom::Pointer s(0);
+ std::string modified_target(target);
bool done(false);
try
@@ -128,12 +131,15 @@ InstallTask::add_target(const std::string & target)
if (std::string::npos != target.find('/'))
_imp->targets->add_child(PortageDepParser::parse(target));
else
- _imp->targets->add_child(DepAtom::Pointer(new PackageDepAtom(
- _imp->env->package_database()->fetch_unique_qualified_package_name(
- PackageNamePart(target)))));
+ {
+ QualifiedPackageName q(_imp->env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(target)));
+ modified_target = stringify(q);
+ _imp->targets->add_child(DepAtom::Pointer(new PackageDepAtom(q)));
+ }
}
- _imp->raw_targets.push_back(target);
+ _imp->raw_targets.push_back(modified_target);
}
namespace
@@ -358,7 +364,10 @@ InstallTask::execute()
{
on_update_world_pre();
WorldCallbacks w(this);
- _imp->env->add_appropriate_to_world(_imp->targets, &w);
+ if (_imp->add_to_world_atom)
+ _imp->env->add_appropriate_to_world(_imp->add_to_world_atom, &w);
+ else
+ _imp->env->add_appropriate_to_world(_imp->targets, &w);
on_update_world_post();
}
else
@@ -422,6 +431,13 @@ InstallTask::set_debug_mode(const InstallDebugOption value)
_imp->install_options.debug_build = value;
}
+void
+InstallTask::set_add_to_world_atom(const std::string & value)
+{
+ Context context("When setting world atom to '" + value + "':");
+ _imp->add_to_world_atom = PortageDepParser::parse_depend(value);
+}
+
InstallTask::TargetsIterator
InstallTask::begin_targets() const
{
diff --git a/paludis/tasks/install_task.hh b/paludis/tasks/install_task.hh
index 3adb895..e536182 100644
--- a/paludis/tasks/install_task.hh
+++ b/paludis/tasks/install_task.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -87,6 +87,7 @@ namespace paludis
void set_pretend(const bool value);
void set_preserve_world(const bool value);
void set_debug_mode(const InstallDebugOption value);
+ void set_add_to_world_atom(const std::string &);
///\}
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index ca8dd69..37b84f3 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -74,6 +74,7 @@ TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_NO_GLOBAL_HOOKS="yes" \
PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 0b141fc..c7c05dc 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -78,6 +78,8 @@ CommandLine::CommandLine() :
"Options which are relevant for --install, --uninstall or --uninstall-unused."),
a_pretend(&install_args, "pretend", 'p', "Pretend only"),
a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
+ a_add_to_world_atom(&install_args, "add-to-world-atom", '\0',
+ "Use this atom, rather than all targets, for updating world (for resume commands)"),
a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
a_debug_build(&install_args, "debug-build", '\0'),
a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 3fa6f32..30386a0 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -191,6 +191,9 @@ class CommandLine :
/// --preserve-world
paludis::args::SwitchArg a_preserve_world;
+ /// --add-to-world-atom
+ paludis::args::StringArg a_add_to_world_atom;
+
/// --no-config-protection
paludis::args::SwitchArg a_no_config_protection;
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index f0dbbe2..2146f9a 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -32,6 +32,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <errno.h>
#include <paludis/tasks/install_task.hh>
#include <paludis/util/fd_output_stream.hh>
@@ -111,29 +112,61 @@ namespace
if (task.current_dep_list_entry() != task.dep_list().end())
{
- std::string resume_command = DefaultEnvironment::get_instance()->paludis_command() + " "
- "--dl-deps-default discard --install --preserve-world";
+ std::string resume_command = DefaultEnvironment::get_instance()->paludis_command()
+ + " --" + CommandLine::get_instance()->dl_deps_default.long_name() + " discard --"
+ + CommandLine::get_instance()->a_install.long_name();
+
for (DepList::Iterator i(task.current_dep_list_entry()), i_end(task.dep_list().end()) ;
i != i_end ; ++i)
if (! i->skip_install)
- resume_command = resume_command + " ="
+ resume_command = resume_command + " '="
+ stringify(i->package.name) + "-"
+ stringify(i->package.version) + "::"
- + stringify(i->package.repository);
+ + stringify(i->package.repository) + "'";
+
+ if (CommandLine::get_instance()->a_add_to_world_atom.specified())
+ resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_atom.long_name()
+ + " '" + CommandLine::get_instance()->a_add_to_world_atom.argument() + "'";
+ else
+ resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_atom.long_name()
+ + " '( " + join(task.begin_targets(), task.end_targets(), " ") + " )'";
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;
+ int fd(mkstemp(resume_template));
+ if (-1 != fd)
+ {
+ FDOutputStream resume_command_file(fd);
+ resume_command_file << resume_command << endl;
+
+ if (resume_command_file)
+ {
+ cerr << endl;
+ cerr << "Resume command saved to file: " << resume_template;
+ cerr << endl;
+ }
+ else
+ {
+ cerr << "Resume command NOT saved to file: " << resume_template << " due to error "
+ << strerror(errno) << endl;
+ cerr << "Resume command: " << resume_command << endl;
+ }
+ }
+ else
+ {
+ cerr << "Resume command NOT saved to file: " << resume_template << " due to error "
+ << strerror(errno) << endl;
+ cerr << "Resume command: " << resume_command << endl;
+ }
std::free(resume_template);
}
else
+ {
+ cerr << endl;
cerr << "Resume command: " << resume_command << endl;
+ }
}
}
@@ -304,6 +337,9 @@ do_install()
task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
+ if (CommandLine::get_instance()->a_add_to_world_atom.specified())
+ task.set_add_to_world_atom(CommandLine::get_instance()->a_add_to_world_atom.argument());
+
if (CommandLine::get_instance()->a_debug_build.specified())
task.set_debug_mode(CommandLine::get_instance()->a_debug_build.option());
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index eab20a9..bd42b58 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -1,5 +1,10 @@
#!/bin/bash
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test --install target || exit 1
-./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+ --has-version test-category/target && exit 1
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+ --install target || exit 2
+./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 3
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+ --has-version test-category/target || exit 4
diff --git a/src/clients/paludis/install_TEST_setup.sh b/src/clients/paludis/install_TEST_setup.sh
index f7c1592..ceef012 100755
--- a/src/clients/paludis/install_TEST_setup.sh
+++ b/src/clients/paludis/install_TEST_setup.sh
@@ -37,7 +37,16 @@ profiles = \${location}/profiles/testprofile \${location}/profiles/anothertestpr
buildroot = `pwd`/build
END
+cat <<END > root/${SYSCONFDIR}/paludis/repositories/installed.conf
+location = `pwd`/root/var/db/pkg
+format = vdb
+names_cache = /var/empty
+provides_cache = /var/empty
+buildroot = `pwd`/build
+END
+
mkdir -p root/tmp
+mkdir -p root/var/db/pkg
touch root/${SYSCONFDIR}/ld.so.conf
mkdir -p repo1/{eclass,distfiles,profiles/{testprofile,anothertestprofile},test-category/target/files} || exit 1
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index ca38388..50ab6a2 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -241,7 +241,7 @@ main(int argc, char *argv[])
throw args::DoHelp("you should specify exactly one action");
}
- /* these actions don't need DefaultConfig */
+ /* these actions don't need DefaultConfig or paludis_command. */
if (CommandLine::get_instance()->a_list_sync_protocols.specified())
{
@@ -267,7 +267,7 @@ main(int argc, char *argv[])
return do_list_dep_tag_categories();
}
- /* these actions do need DefaultConfig */
+ /* these actions do need DefaultConfig or paludis_command */
try
{
@@ -275,11 +275,32 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_config_suffix.specified())
{
DefaultConfig::set_config_suffix(CommandLine::get_instance()->a_config_suffix.argument());
- paludis_command.append(" --config-suffix " +
+ paludis_command.append(" --" + CommandLine::get_instance()->a_config_suffix.long_name() + " " +
CommandLine::get_instance()->a_config_suffix.argument());
}
- paludis_command.append(" --log-level " + CommandLine::get_instance()->a_log_level.argument());
+
+ paludis_command.append(" --" + CommandLine::get_instance()->a_log_level.long_name() + " " +
+ CommandLine::get_instance()->a_log_level.argument());
+
+ if (CommandLine::get_instance()->a_resume_command_template.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_resume_command_template.long_name() + " "
+ + CommandLine::get_instance()->a_resume_command_template.argument());
+
+ if (CommandLine::get_instance()->a_no_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+
+ if (CommandLine::get_instance()->a_no_config_protection.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_no_config_protection.long_name());
+
+ if (CommandLine::get_instance()->a_preserve_world.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_preserve_world.long_name());
+
+ if (CommandLine::get_instance()->a_debug_build.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_debug_build.long_name() + " "
+ + CommandLine::get_instance()->a_debug_build.argument());
+
DefaultConfig::get_instance()->set_paludis_command(paludis_command);
+
}
catch (const DefaultConfigError &)
{
diff --git a/src/clients/paludis/upgrade_TEST b/src/clients/paludis/upgrade_TEST
index 9bccff1..1d471d3 100755
--- a/src/clients/paludis/upgrade_TEST
+++ b/src/clients/paludis/upgrade_TEST
@@ -12,6 +12,6 @@ PALUDIS_HOME=./upgrade_TEST_dir/config/ \
./paludis --config-suffix upgrade-test --install target || exit 5
./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-2 >/dev/null || exit 6
-./upgrade_TEST_dir/root/usr/bin/testbin1 && exit 7
+./upgrade_TEST_dir/root/usr/bin/testbin1 2>/dev/null && exit 7
./upgrade_TEST_dir/root/usr/bin/testbin2 | grep testbin2 >/dev/null || exit 8