aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-05-25 05:58:32 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-05-25 05:58:32 +0000
commitb672c8592fba32dc313d67822a781676c82cbea3 (patch)
treebc541a36a3a95a9c3bdadaad0fe873acaae0a14d
parentd68ec5a53b8c92d74b2df9be84658fd0eb34e6cd (diff)
downloadpaludis-b672c8592fba32dc313d67822a781676c82cbea3.tar.gz
paludis-b672c8592fba32dc313d67822a781676c82cbea3.tar.xz
Make pkg_pretend abort properly. Fixes: ticket:579
-rw-r--r--paludis/install_task.cc12
-rw-r--r--paludis/repositories/e/e_repository_entries.hh2
-rw-r--r--paludis/repositories/e/ebuild_id.cc9
-rw-r--r--src/clients/paludis/Makefile.am3
-rwxr-xr-xsrc/clients/paludis/pretend_TEST28
-rwxr-xr-xsrc/clients/paludis/pretend_TEST_cleanup.sh9
-rwxr-xr-xsrc/clients/paludis/pretend_TEST_setup.sh85
7 files changed, 138 insertions, 10 deletions
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 8dfa0f8..00cfa90 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -628,7 +628,11 @@ InstallTask::_pretend()
PretendAction pretend_action;
dep->package_id->perform_action(pretend_action);
- pretend_failed |= pretend_action.failed();
+ if (pretend_action.failed())
+ {
+ pretend_failed = true;
+ dep->handled.reset(new DepListEntryHandledFailed);
+ }
on_pretend_post(*dep);
}
@@ -1025,15 +1029,15 @@ InstallTask::_execute()
_display_task_list();
bool pretend_failed(_pretend());
- if (_imp->pretend)
- return;
-
if (_imp->dep_list.has_errors() || pretend_failed)
{
on_not_continuing_due_to_errors();
return;
}
+ if (_imp->pretend)
+ return;
+
_main_actions();
}
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 330d344..86e0d01 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -102,7 +102,7 @@ namespace paludis
* Handle a pretend.
*/
virtual bool pretend(const std::tr1::shared_ptr<const ERepositoryID> &,
- std::tr1::shared_ptr<const ERepositoryProfile>) const = 0;
+ std::tr1::shared_ptr<const ERepositoryProfile>) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Handle an info.
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index d93cb0e..ededd33 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -868,11 +868,12 @@ namespace
std::tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
- void visit(PretendAction &)
+ void visit(PretendAction & action)
{
- std::tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->pretend(
- std::tr1::static_pointer_cast<const ERepositoryID>(id),
- std::tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
+ if (! std::tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->pretend(
+ std::tr1::static_pointer_cast<const ERepositoryID>(id),
+ std::tr1::static_pointer_cast<const ERepository>(id->repository())->profile()))
+ action.set_failed();
}
void visit(InfoAction &)
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index d3a6ee5..5a8cbf3 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -76,13 +76,14 @@ TESTS_ENVIRONMENT = env \
TESTS = version_TEST help_TEST \
list_repository_formats_TEST list_dep_tag_categories_TEST \
- exception_TEST install_TEST upgrade_TEST args_from_environment_TEST \
+ exception_TEST install_TEST pretend_TEST upgrade_TEST args_from_environment_TEST \
continue_on_failure_TEST
EXTRA_DIST = \
$(man_MANS) \
$(TESTS) \
install_TEST_setup.sh install_TEST_cleanup.sh \
+ pretend_TEST_setup.sh pretend_TEST_cleanup.sh \
upgrade_TEST_setup.sh upgrade_TEST_cleanup.sh \
continue_on_failure_TEST_setup.sh continue_on_failure_TEST_cleanup.sh
diff --git a/src/clients/paludis/pretend_TEST b/src/clients/paludis/pretend_TEST
new file mode 100755
index 0000000..d646547
--- /dev/null
+++ b/src/clients/paludis/pretend_TEST
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --list-packages || exit 12
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --query test-category/target || exit 13
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --has-version test-category/target && exit 1
+
+export PRETEND_SHOULD_FAIL=yes
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --pretend --install test-category/target && exit 2
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --install test-category/target && exit 3
+
+export PRETEND_SHOULD_FAIL=
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --pretend --install test-category/target || exit 4
+
+PALUDIS_HOME=./pretend_TEST_dir/config/ ./paludis --environment :pretend-test \
+ --install test-category/target || exit 5
+
+
diff --git a/src/clients/paludis/pretend_TEST_cleanup.sh b/src/clients/paludis/pretend_TEST_cleanup.sh
new file mode 100755
index 0000000..9f78057
--- /dev/null
+++ b/src/clients/paludis/pretend_TEST_cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d pretend_TEST_dir ] ; then
+ rm -fr pretend_TEST_dir
+else
+ true
+fi
+
diff --git a/src/clients/paludis/pretend_TEST_setup.sh b/src/clients/paludis/pretend_TEST_setup.sh
new file mode 100755
index 0000000..7fd72cb
--- /dev/null
+++ b/src/clients/paludis/pretend_TEST_setup.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir pretend_TEST_dir || exit 1
+cd pretend_TEST_dir || exit 1
+mkdir -p build
+
+mkdir -p config/.paludis-pretend-test
+cat <<END > config/.paludis-pretend-test/specpath.conf
+root = `pwd`/root
+END
+
+mkdir -p root/${SYSCONFDIR}/paludis/repositories
+cat <<END > root/${SYSCONFDIR}/paludis/use.conf
+*/* foo
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/environment.conf
+world = `pwd`/root/world
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
+*/* *
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
+*/* test
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/bashrc
+export CHOST="my-chost"
+export USER_BASHRC_WAS_USED=yes
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
+location = `pwd`/repo1
+cache = /var/empty
+format = ebuild
+names_cache = /var/empty
+profiles = \${location}/profiles/profile
+builddir = `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
+builddir = `pwd`/build
+END
+mkdir -p root/tmp
+mkdir -p root/var/db/pkg
+mkdir -p root/var/db/exndbam
+touch root/${SYSCONFDIR}/ld.so.conf
+
+mkdir -p repo1/{eclass,distfiles,profiles/profile,test-category/target/files} || exit 1
+
+cd repo1 || exit 1
+echo "test-repo-1" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+test-category
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+USE_EXPAND="USERLAND KERNEL"
+END
+
+cat <<"END" > test-category/target/target-1.exheres-0 || exit 1
+DESCRIPTION="Test target"
+HOMEPAGE="http://paludis.pioto.org/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+
+pkg_pretend() {
+ [[ ${PRETEND_SHOULD_FAIL} == yes ]] && die "pretend failure"
+}
+
+END
+cd ..
+