aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-04-11 13:41:42 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-04-11 13:41:42 +0000
commitee7a97748d549c206a9fc7d14c518a4802c8b088 (patch)
tree986a3972a03e3dd0f94bc4d6180145006051ba09
parentdcfd35b8ab06eb8c440f1aa5468702c00d9a5de4 (diff)
downloadpaludis-ee7a97748d549c206a9fc7d14c518a4802c8b088.tar.gz
paludis-ee7a97748d549c206a9fc7d14c518a4802c8b088.tar.xz
Fix reinstalling a package with an equivalent but textually different version.
-rw-r--r--paludis/repositories/e/vdb_repository.cc24
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc116
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_setup.sh20
3 files changed, 150 insertions, 10 deletions
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 9c86da7..41285c1 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -464,13 +464,13 @@ VDBRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id
}
if (only)
_imp->names_cache->remove(id->name());
+ }
- if (_imp->used_provides_cache || (! _imp->tried_provides_cache && load_provided_using_cache()))
- {
- _imp->provides_map->erase(std::make_pair(id->name(), id->version()));
- write_provides_cache();
- _imp->provides.reset();
- }
+ if (_imp->used_provides_cache || (! _imp->tried_provides_cache && load_provided_using_cache()))
+ {
+ _imp->provides_map->erase(std::make_pair(id->name(), id->version()));
+ write_provides_cache();
+ _imp->provides.reset();
}
}
@@ -824,12 +824,16 @@ VDBRepository::merge(const MergeParams & m)
if (is_replace)
{
- if ((vdb_dir.dirname() / ("-reinstalling-" + vdb_dir.basename())).exists())
- throw InstallActionError("Directory '" + stringify(vdb_dir.dirname() /
- ("-reinstalling-" + vdb_dir.basename())) + "' already exists, probably due to "
+ FSEntry old_vdb_dir(_imp->params.location);
+ old_vdb_dir /= stringify(is_replace->name().category);
+ old_vdb_dir /= (stringify(is_replace->name().package) + "-" + stringify(is_replace->version()));
+
+ if ((old_vdb_dir.dirname() / ("-reinstalling-" + old_vdb_dir.basename())).exists())
+ throw InstallActionError("Directory '" + stringify(old_vdb_dir.dirname() /
+ ("-reinstalling-" + old_vdb_dir.basename())) + "' already exists, probably due to "
"a previous failed upgrade. If it is safe to do so, remove this directory and try "
"again.");
- vdb_dir.rename(vdb_dir.dirname() / ("-reinstalling-" + vdb_dir.basename()));
+ old_vdb_dir.rename(old_vdb_dir.dirname() / ("-reinstalling-" + old_vdb_dir.basename()));
}
tmp_vdb_dir.rename(vdb_dir);
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 6da5e79..eb85098 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -975,6 +975,17 @@ namespace test_cases
}
{
+ TestMessageSuffix suffix("reinstall equivalent", true);
+ const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1.1::providesincrtest_src2",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1.1-r0 virtual/foo\n");
+ }
+
+ {
TestMessageSuffix suffix("downgrade", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1::providesincrtest_src1",
@@ -1066,5 +1077,110 @@ namespace test_cases
return ss.str();
}
} test_provides_cache_incremental;
+
+ struct ReinstallTest : TestCase
+ {
+ ReinstallTest() : TestCase("reinstall") { }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ 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/reinstalltest_src1");
+ keys->insert("profiles", "vdb_repository_TEST_dir/reinstalltest_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()));
+ tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env, keys));
+ env.package_database()->add_repository(1, repo1);
+
+ keys.reset(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "vdb_repository_TEST_dir/reinstalltest_src2");
+ keys->insert("profiles", "vdb_repository_TEST_dir/reinstalltest_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()));
+ tr1::shared_ptr<ERepository> repo2(make_ebuild_repository(&env, keys));
+ env.package_database()->add_repository(2, repo2);
+
+ 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/reinstalltest");
+ keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("vdb_repository_TEST_dir/root").realpath()));
+ tr1::shared_ptr<Repository> vdb_repo(VDBRepository::make_vdb_repository(&env, keys));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ InstallAction install_action(InstallActionOptions::named_create()
+ (k::debug_build(), iado_none)
+ (k::checks(), iaco_default)
+ (k::no_config_protect(), false)
+ (k::destination(), vdb_repo)
+ );
+
+ TEST_CHECK(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
+
+ {
+ TestMessageSuffix suffix("install", true);
+ const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::reinstalltest_src1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ 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("reinstall", true);
+ const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::reinstalltest_src1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ 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("reinstall equivalent", true);
+ const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::reinstalltest_src2",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ id->perform_action(install_action);
+ vdb_repo->invalidate();
+
+ 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-r0::installed");
+ }
+ }
+ } reinstall_test;
}
diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh
index cce58ec..f6978d7 100755
--- a/paludis/repositories/e/vdb_repository_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh
@@ -422,6 +422,7 @@ END
cp providesincrtest_src1/cat1/pkg1/pkg1-{1,1.1}.ebuild
cp providesincrtest_src1/cat1/pkg1/pkg1-{1,2}.ebuild
cp providesincrtest_src1/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
+cp providesincrtest_src1/cat1/pkg1/pkg1-1.1.ebuild providesincrtest_src2/cat1/pkg1/pkg1-1.1-r0.ebuild
cat <<END >providesincrtest_src2/cat1/pkg1/pkg1-1.ebuild
KEYWORDS="test"
@@ -429,3 +430,22 @@ SLOT="${PV:0:1}"
PROVIDE="enabled? ( virtual/bar ) disabled? ( virtual/foo )"
END
+mkdir -p reinstalltest reinstalltest_src{1,2}/{eclass,profiles/profile,cat/pkg} || exit 1
+
+cat <<END > reinstalltest_src1/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo reinstalltest_src1 >reinstalltest_src1/profiles/repo_name
+echo reinstalltest_src2 >reinstalltest_src2/profiles/repo_name
+echo cat >reinstalltest_src1/profiles/categories
+echo cat >reinstalltest_src2/profiles/categories
+
+cat <<END >reinstalltest_src1/cat/pkg/pkg-1.ebuild
+KEYWORDS="test"
+SLOT="0"
+END
+cp reinstalltest_src1/cat/pkg/pkg-1.ebuild reinstalltest_src2/cat/pkg/pkg-1-r0.ebuild
+