aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-08-05 21:39:12 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2008-08-06 20:04:09 +0100
commit608c7abbd898be86371153195c883693cd7489d7 (patch)
treee1ab08a3adb02b726d1b9920d648a3ccd601002c
parent9df9c709cca58917d2f32a1214b41d604ed81e25 (diff)
downloadpaludis-608c7abbd898be86371153195c883693cd7489d7.tar.gz
paludis-608c7abbd898be86371153195c883693cd7489d7.tar.xz
Support EAPI-dependent pkg_postinst phase ordering for up/downgrades.
This is currently determined by the EAPI of the version being installed, not the one being removed. The implementation is rather hackish; the new resolver will let us do better.
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/0.conf2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf2
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf2
-rw-r--r--paludis/repositories/e/exndbam_repository.cc29
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc193
-rwxr-xr-xpaludis/repositories/e/exndbam_repository_TEST_setup.sh56
-rw-r--r--paludis/repositories/e/vdb_repository.cc13
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc236
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_setup.sh73
11 files changed, 592 insertions, 17 deletions
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 0731e0d..d5e2cb2 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -170,6 +170,7 @@ namespace
value_for<n::ebuild_info>(check_get(k, "ebuild_info")),
value_for<n::ebuild_install>(check_get(k, "ebuild_install")),
value_for<n::ebuild_metadata>(check_get(k, "ebuild_metadata")),
+ value_for<n::ebuild_new_upgrade_phase_order>(destringify_key<bool>(k, "ebuild_new_upgrade_phase_order")),
value_for<n::ebuild_nofetch>(check_get(k, "ebuild_nofetch")),
value_for<n::ebuild_pretend>(check_get(k, "ebuild_pretend")),
value_for<n::ebuild_uninstall>(check_get(k, "ebuild_uninstall")),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 4b808e0..c0d0191 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -67,6 +67,7 @@ namespace paludis
struct ebuild_pretend;
struct ebuild_uninstall;
struct ebuild_variable;
+ struct ebuild_new_upgrade_phase_order;
struct eclass_must_not_set_variables;
struct env_aa;
struct env_accept_keywords;
@@ -303,6 +304,7 @@ namespace paludis
NamedValue<n::ebuild_info, std::string> ebuild_info;
NamedValue<n::ebuild_install, std::string> ebuild_install;
NamedValue<n::ebuild_metadata, std::string> ebuild_metadata;
+ NamedValue<n::ebuild_new_upgrade_phase_order, bool> ebuild_new_upgrade_phase_order;
NamedValue<n::ebuild_nofetch, std::string> ebuild_nofetch;
NamedValue<n::ebuild_pretend, std::string> ebuild_pretend;
NamedValue<n::ebuild_uninstall, std::string> ebuild_uninstall;
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 5c38dd1..a1afd7a 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -125,6 +125,8 @@ ebuild_config = \
sandbox : initmisc config ; \
: tidyupmisc
+ebuild_new_upgrade_phase_order = false
+
description_build_depend = Build dependencies
description_short_description = Description
description_eapi = EAPI
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 0b0d9a9..aaa5641 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -132,6 +132,8 @@ ebuild_config = \
sandbox : initmisc config ; \
: tidyupmisc
+ebuild_new_upgrade_phase_order = true
+
metadata_build_depend =
metadata_run_depend =
metadata_slot = SLOT
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 4a8f066..209dda9 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -130,6 +130,8 @@ ebuild_config = \
sandbox : initmisc config ; \
: tidyupmisc
+ebuild_new_upgrade_phase_order = true
+
metadata_build_depend = DEPEND
metadata_run_depend = RDEPEND
metadata_slot = SLOT
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index cb65e70..251cce2 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -373,6 +373,18 @@ ExndbamRepository::merge(const MergeParams & m)
{
perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), true);
}
+ if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
+ ->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> & replace_candidates(package_ids(m.package_id()->name()));
+ for (PackageIDSequence::ConstIterator it(replace_candidates->begin()),
+ it_end(replace_candidates->end()); it_end != it; ++it)
+ {
+ std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
+ if (candidate != if_overwritten_id && candidate->slot() == m.package_id()->slot())
+ perform_uninstall(candidate, false);
+ }
+ }
VDBPostMergeCommand post_merge_command(
make_named_values<VDBPostMergeCommandParams>(
@@ -387,19 +399,6 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
{
Context context("When uninstalling '" + stringify(*id) + (replace ? "' for a reinstall:" : "':"));
- bool last(! replace);
- if (last)
- {
- std::tr1::shared_ptr<const PackageIDSequence> ids(package_ids(id->name()));
- for (PackageIDSequence::ConstIterator v(ids->begin()), v_end(ids->end()) ;
- v != v_end ; ++v)
- if (**v != *id)
- {
- last = false;
- break;
- }
- }
-
if (! _imp->params.root.is_directory())
throw InstallActionError("Couldn't uninstall '" + stringify(*id) +
"' because root ('" + stringify(_imp->params.root) + "') is not a directory");
@@ -478,9 +477,9 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
FSEntry(*d).unlink();
ver_dir.rmdir();
- if (last)
+ FSEntry pkg_dir(ver_dir.dirname());
+ if (DirIterator() == DirIterator(pkg_dir, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort + dio_first_only))
{
- FSEntry pkg_dir(ver_dir.dirname());
pkg_dir.rmdir();
_imp->ndbam.deindex(id->name());
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index b6072e0..09c01bb 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -17,9 +17,20 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/exndbam_repository.hh>
+#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/action.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -56,5 +67,187 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
} test_exndbam_repository_repo_name;
+
+ struct PkgPostinstPhaseOrderingTest : TestCase
+ {
+ PkgPostinstPhaseOrderingTest() : TestCase("pkg_postinst phase ordering") { }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void run()
+ {
+ TestEnvironment env(FSEntry("exndbam_repository_TEST_dir/root").realpath());
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "exndbam_repository_TEST_dir/postinsttest_src1");
+ keys->insert("profiles", "exndbam_repository_TEST_dir/postinsttest_src1/profiles/profile");
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo1);
+
+ keys.reset(new Map<std::string, std::string>);
+ keys->insert("format", "exndbam");
+ keys->insert("location", "exndbam_repository_TEST_dir/postinsttest");
+ keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<Repository> exndbam_repo(ExndbamRepository::make_exndbam_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(0, exndbam_repo);
+
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ value_for<n::checks>(iaco_default),
+ value_for<n::debug_build>(iado_none),
+ value_for<n::destination>(exndbam_repo)
+ ));
+
+ UninstallAction uninstall_action;
+
+ TEST_CHECK(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
+
+ {
+ TestMessageSuffix suffix("install eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-0.1::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi paludis-1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("new slot", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-2::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed cat/pkg-2::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("downgrade eapi paludis-1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-1.1::installed cat/pkg-2::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0::installed cat/pkg-2::installed");
+ }
+ }
+ } pkg_postinst_phase_ordering_test;
}
diff --git a/paludis/repositories/e/exndbam_repository_TEST_setup.sh b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
index e3442ce..4ce00c8 100755
--- a/paludis/repositories/e/exndbam_repository_TEST_setup.sh
+++ b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
@@ -4,5 +4,61 @@
mkdir -p exndbam_repository_TEST_dir || exit 1
cd exndbam_repository_TEST_dir || exit 1
+mkdir -p distdir
+mkdir -p build
+mkdir -p root/etc
+
mkdir -p repo1/ || exit 1
+mkdir -p postinsttest postinsttest_src1/{eclass,profiles/profile,cat/pkg} || exit 1
+
+cat <<END > postinsttest_src1/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo postinsttest >postinsttest_src1/profiles/repo_name
+echo cat >postinsttest_src1/profiles/categories
+
+cat <<END >postinsttest_src1/cat/pkg/pkg-0.ebuild
+if [[ \${PV} == 0* ]]; then
+ EAPI=1
+else
+ EAPI=paludis-1
+fi
+KEYWORDS="test"
+if [[ \${PV} == 2* ]]; then
+ SLOT="2"
+else
+ SLOT="1"
+fi
+pkg_preinst() {
+ OTHER=\$(best_version "\${CATEGORY}/\${PN}:\${SLOT}")
+ if [[ -n \${OTHER} ]]; then
+ if [[ \${EAPI} == paludis-1 ]] || has_version "=\${CATEGORY}/\${PF}:\${SLOT}"; then
+ COMMAND=rmdir
+ else
+ COMMAND=mkdir
+ fi
+ else
+ COMMAND=:
+ fi
+}
+pkg_postinst() {
+ \${COMMAND} "\${ROOT}"/\${OTHER##*/} || die
+}
+pkg_postrm() {
+ if has_version "=\${CATEGORY}/\${PN}-0*:\${SLOT}" &&
+ ( has_version "<\${CATEGORY}/\${PF}:\${SLOT}" || has_version ">\${CATEGORY}/\${PF}:\${SLOT}" ); then
+ rmdir "\${ROOT}"/\${PF} || die
+ else
+ mkdir "\${ROOT}"/\${PF} || die
+ fi
+}
+END
+cp postinsttest_src1/cat/pkg/pkg-{0,0.1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,1.1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,2}.ebuild
+
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 0019e0c..fcd9511 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -413,6 +413,7 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
value_for<n::config_protect>(config_protect),
value_for<n::config_protect_mask>(config_protect_mask),
value_for<n::contents_file>(pkg_dir / "CONTENTS"),
+
value_for<n::environment>(_imp->params.environment),
value_for<n::package_id>(id),
value_for<n::root>(installed_root_key()->value())
@@ -850,6 +851,18 @@ VDBRepository::merge(const MergeParams & m)
if (is_replace)
perform_uninstall(is_replace, true);
+ if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
+ ->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> & replace_candidates(package_ids(m.package_id()->name()));
+ for (PackageIDSequence::ConstIterator it(replace_candidates->begin()),
+ it_end(replace_candidates->end()); it_end != it; ++it)
+ {
+ std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
+ if (candidate != is_replace && candidate->slot() == m.package_id()->slot())
+ perform_uninstall(candidate, false);
+ }
+ }
VDBPostMergeCommand post_merge_command(
make_named_values<VDBPostMergeCommandParams>(
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 3dcf67b..76ed1bd 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -751,6 +751,36 @@ namespace test_cases
read_cache(cache_contents);
TEST_CHECK_EQUAL(cache_contents.size(), 0U);
}
+
+ {
+ TestMessageSuffix suffix("install paludis-1", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat3/pkg1-1::namesincrtest_src",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSEntry> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade paludis-1", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat3/pkg1-2::namesincrtest_src",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSEntry> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
+ }
}
void read_cache(std::vector<FSEntry> & vec)
@@ -1062,6 +1092,28 @@ namespace test_cases
TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
}
+
+ {
+ TestMessageSuffix suffix("install paludis-1", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat2/pkg1-1::providesincrtest_src1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 1 virtual/moo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade paludis-1", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat2/pkg1-2::providesincrtest_src1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 2 virtual/moo\n");
+ }
}
std::string read_file(const FSEntry & f)
@@ -1180,5 +1232,189 @@ namespace test_cases
}
}
} reinstall_test;
+
+ struct PkgPostinstPhaseOrderingTest : TestCase
+ {
+ PkgPostinstPhaseOrderingTest() : TestCase("pkg_postinst phase ordering") { }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void run()
+ {
+ TestEnvironment env(FSEntry("vdb_repository_TEST_dir/root").realpath());
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "vdb_repository_TEST_dir/postinsttest_src1");
+ keys->insert("profiles", "vdb_repository_TEST_dir/postinsttest_src1/profiles/profile");
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo1);
+
+ keys.reset(new Map<std::string, std::string>);
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", "vdb_repository_TEST_dir/postinsttest");
+ keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ value_for<n::checks>(iaco_default),
+ value_for<n::debug_build>(iado_none),
+ value_for<n::destination>(vdb_repo)
+ ));
+
+ UninstallAction uninstall_action;
+
+ TEST_CHECK(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
+
+ {
+ TestMessageSuffix suffix("install eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-0.1::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(vdb_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi paludis-1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("new slot", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-2::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed cat/pkg-2::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("downgrade eapi paludis-1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-1.1::installed cat/pkg-2::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0::installed cat/pkg-2::installed");
+ }
+ }
+ } pkg_postinst_phase_ordering_test;
}
diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh
index d4a0737..ac36ddf 100755
--- a/paludis/repositories/e/vdb_repository_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh
@@ -355,7 +355,7 @@ pkg_config() {
}
END
-mkdir -p namesincrtest/.cache/names/installed namesincrtest_src/{eclass,profiles/profile,cat1/{pkg1,pkg2},cat2/pkg1} || exit 1
+mkdir -p namesincrtest/.cache/names/installed namesincrtest_src/{eclass,profiles/profile,cat1/{pkg1,pkg2},{cat2,cat3}/pkg1} || exit 1
echo paludis-2 >namesincrtest/.cache/names/installed/_VERSION_
echo installed >>namesincrtest/.cache/names/installed/_VERSION_
@@ -368,6 +368,7 @@ END
echo namesincrtest_src >namesincrtest_src/profiles/repo_name
echo cat1 >namesincrtest_src/profiles/categories
echo cat2 >>namesincrtest_src/profiles/categories
+echo cat3 >>namesincrtest_src/profiles/categories
cat <<END >namesincrtest_src/cat1/pkg1/pkg1-1.ebuild
KEYWORDS="test"
@@ -378,6 +379,13 @@ cp namesincrtest_src/cat1/pkg1/pkg1-{1,2}.ebuild
cp namesincrtest_src/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
cp namesincrtest_src/{cat1,cat2}/pkg1/pkg1-1.ebuild
+cat <<END >namesincrtest_src/cat3/pkg1/pkg1-1.ebuild
+EAPI=paludis-1
+KEYWORDS="test"
+SLOT="0"
+END
+cp namesincrtest_src/cat3/pkg1/pkg1-{1,2}.ebuild
+
mkdir -p providestest/{.cache,cat1/{pkg1,pkg2,pkg3}-{1,2}} || exit 1
for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/EAPI; do
echo 0 >${f}
@@ -399,7 +407,7 @@ echo 'disabled? ( virtual/foo ) virtual/bar' >providestest/cat1/pkg2-2/PROVIDE
echo 'disabled? ( virtual/foo )' >providestest/cat1/pkg3-1/PROVIDE
echo '' >providestest/cat1/pkg3-2/PROVIDE
-mkdir -p providesincrtest/.cache providesincrtest_src{1,2}/{eclass,profiles/profile,cat1/{pkg1,pkg2}} || exit 1
+mkdir -p providesincrtest/.cache providesincrtest_src{1,2}/{eclass,profiles/profile,{cat1,cat2}/{pkg1,pkg2}} || exit 1
echo paludis-3 >providesincrtest/.cache/provides
echo installed >>providesincrtest/.cache/provides
@@ -412,6 +420,7 @@ END
echo providesincrtest_src1 >providesincrtest_src1/profiles/repo_name
echo providesincrtest_src2 >providesincrtest_src2/profiles/repo_name
echo cat1 >providesincrtest_src1/profiles/categories
+echo cat2 >>providesincrtest_src1/profiles/categories
echo cat1 >providesincrtest_src2/profiles/categories
cat <<END >providesincrtest_src1/cat1/pkg1/pkg1-1.ebuild
@@ -430,6 +439,14 @@ SLOT="\${PV:0:1}"
PROVIDE="enabled? ( virtual/bar ) disabled? ( virtual/foo )"
END
+cat <<END >providesincrtest_src1/cat2/pkg1/pkg1-1.ebuild
+EAPI=paludis-1
+KEYWORDS="test"
+SLOT="0"
+PROVIDE="virtual/moo"
+END
+cp providesincrtest_src1/cat2/pkg1/pkg1-{1,2}.ebuild
+
mkdir -p reinstalltest reinstalltest_src{1,2}/{eclass,profiles/profile,cat/pkg} || exit 1
cat <<END > reinstalltest_src1/profiles/profile/make.defaults
@@ -449,3 +466,55 @@ SLOT="0"
END
cp reinstalltest_src1/cat/pkg/pkg-1.ebuild reinstalltest_src2/cat/pkg/pkg-1-r0.ebuild
+mkdir -p postinsttest postinsttest_src1/{eclass,profiles/profile,cat/pkg} || exit 1
+
+cat <<END > postinsttest_src1/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo postinsttest >postinsttest_src1/profiles/repo_name
+echo cat >postinsttest_src1/profiles/categories
+
+cat <<END >postinsttest_src1/cat/pkg/pkg-0.ebuild
+if [[ \${PV} == 0* ]]; then
+ EAPI=1
+else
+ EAPI=paludis-1
+fi
+KEYWORDS="test"
+if [[ \${PV} == 2* ]]; then
+ SLOT="2"
+else
+ SLOT="1"
+fi
+pkg_preinst() {
+ OTHER=\$(best_version "\${CATEGORY}/\${PN}:\${SLOT}")
+ if [[ -n \${OTHER} ]]; then
+ if [[ \${EAPI} == paludis-1 ]] || has_version "=\${CATEGORY}/\${PF}:\${SLOT}"; then
+ COMMAND=rmdir
+ else
+ COMMAND=mkdir
+ fi
+ else
+ COMMAND=:
+ fi
+}
+pkg_postinst() {
+ \${COMMAND} "\${ROOT}"/\${OTHER##*/} || die
+}
+pkg_postrm() {
+ if has_version "=\${CATEGORY}/\${PN}-0*:\${SLOT}" &&
+ ( has_version "<\${CATEGORY}/\${PF}:\${SLOT}" || has_version ">\${CATEGORY}/\${PF}:\${SLOT}" ); then
+ rmdir "\${ROOT}"/\${PF} || die
+ else
+ mkdir "\${ROOT}"/\${PF} || die
+ fi
+}
+END
+cp postinsttest_src1/cat/pkg/pkg-{0,0.1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,1.1}.ebuild
+cp postinsttest_src1/cat/pkg/pkg-{0,2}.ebuild
+