aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 15:10:52 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 15:10:52 +0100
commite4349bcd89b7056a4a47c051edb6005b477f556b (patch)
tree1c0babc9ce8ea4eef727a4651fcbaa07d49b82a9
parent39a39db092298018330339d5303a76c887abe0eb (diff)
downloadpaludis-e4349bcd89b7056a4a47c051edb6005b477f556b.tar.gz
paludis-e4349bcd89b7056a4a47c051edb6005b477f556b.tar.xz
Order fetches early, and clean up fetch deps
Fixes: ticket:898
-rw-r--r--.gitignore1
-rw-r--r--paludis/resolver/Makefile.am17
-rw-r--r--paludis/resolver/nag.cc17
-rw-r--r--paludis/resolver/orderer.cc14
-rw-r--r--paludis/resolver/resolver_TEST_continue_on_failure.cc10
-rw-r--r--paludis/resolver/resolver_TEST_fetches.cc146
-rwxr-xr-xpaludis/resolver/resolver_TEST_fetches_cleanup.sh9
-rwxr-xr-xpaludis/resolver/resolver_TEST_fetches_setup.sh38
8 files changed, 243 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index c3e0076..2bd6552 100644
--- a/.gitignore
+++ b/.gitignore
@@ -329,6 +329,7 @@ paludis-*.*.*.tar.bz2
/paludis/resolver/resolver_TEST_continue_on_failure
/paludis/resolver/resolver_TEST_cycles
/paludis/resolver/resolver_TEST_errors
+/paludis/resolver/resolver_TEST_fetches
/paludis/resolver/resolver_TEST_serialisation
/paludis/resolver/resolver_TEST_simple
/paludis/resolver/resolver_TEST_suggestions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 648b603..8ba96d0 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -112,6 +112,7 @@ TESTS = \
resolver_TEST_errors \
resolver_TEST_continue_on_failure \
resolver_TEST_uninstalls \
+ resolver_TEST_fetches \
$(virtuals_tests)
endif
@@ -127,7 +128,8 @@ check_SCRIPTS = \
resolver_TEST_any_setup.sh resolver_TEST_any_cleanup.sh \
resolver_TEST_errors_setup.sh resolver_TEST_errors_cleanup.sh \
resolver_TEST_continue_on_failure_setup.sh resolver_TEST_continue_on_failure_cleanup.sh \
- resolver_TEST_uninstalls_setup.sh resolver_TEST_uninstalls_cleanup.sh
+ resolver_TEST_uninstalls_setup.sh resolver_TEST_uninstalls_cleanup.sh \
+ resolver_TEST_fetches_setup.sh resolver_TEST_fetches_cleanup.sh
check_LIBRARIES = libpaludisresolvertest.a
@@ -265,6 +267,19 @@ resolver_TEST_uninstalls_LDADD = \
resolver_TEST_uninstalls_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_fetches_SOURCES = resolver_TEST_fetches.cc
+
+resolver_TEST_fetches_LDADD = \
+ libpaludisresolvertest.a \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ libpaludisresolver.a \
+ $(DYNAMIC_LD_LIBS)
+
+resolver_TEST_fetches_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+
use_existing-se.hh : use_existing.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/use_existing.se > $@ ; then rm -f $@ ; exit 1 ; fi
diff --git a/paludis/resolver/nag.cc b/paludis/resolver/nag.cc
index 3a25025..5ce720e 100644
--- a/paludis/resolver/nag.cc
+++ b/paludis/resolver/nag.cc
@@ -227,6 +227,19 @@ namespace
return node_data;
}
+
+ struct OrderingNowComparator
+ {
+ bool operator() (const NAGIndex & a, const NAGIndex & b) const
+ {
+ if (a.role() == nir_fetched && b.role() != nir_fetched)
+ return true;
+ if (b.role() == nir_fetched && a.role() != nir_fetched)
+ return false;
+
+ return a < b;
+ }
+ };
}
const std::tr1::shared_ptr<const SortedStronglyConnectedComponents>
@@ -279,7 +292,7 @@ NAG::sorted_strongly_connected_components() const
std::tr1::shared_ptr<SortedStronglyConnectedComponents> result(new SortedStronglyConnectedComponents);
Nodes done;
- std::set<NAGIndex> orderable_now;
+ std::set<NAGIndex, OrderingNowComparator> orderable_now;
for (StronglyConnectedComponentsByRepresentative::const_iterator c(sccs.begin()), c_end(sccs.end()) ;
c != c_end ; ++c)
if (scc_edges.end() == scc_edges.find(c->first))
@@ -287,7 +300,7 @@ NAG::sorted_strongly_connected_components() const
while (! orderable_now.empty())
{
- std::set<NAGIndex>::iterator ordering_now(orderable_now.begin());
+ std::set<NAGIndex, OrderingNowComparator>::iterator ordering_now(orderable_now.begin());
result->push_back(sccs.find(*ordering_now)->second);
done.insert(*ordering_now);
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 80ef112..7bc5bc7 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -742,8 +742,20 @@ namespace
case nir_fetched:
{
+ const std::tr1::shared_ptr<JobRequirements> requirements(new JobRequirements);
+
+ RecursedRequirements recursed;
+ populate_requirements(
+ resolved->nag(),
+ install_job_numbers,
+ index,
+ requirements,
+ false,
+ recursed
+ );
+
JobNumber fetch_job_n(resolved->job_lists()->execute_job_list()->append(make_shared_ptr(new FetchJob(
- make_shared_ptr(new JobRequirements),
+ requirements,
changes_to_make_decision.origin_id()->uniquely_identifying_spec()))));
fetch_job_numbers.insert(std::make_pair(index.resolvent(), fetch_job_n));
}
diff --git a/paludis/resolver/resolver_TEST_continue_on_failure.cc b/paludis/resolver/resolver_TEST_continue_on_failure.cc
index 826d2a8..b4d7ad0 100644
--- a/paludis/resolver/resolver_TEST_continue_on_failure.cc
+++ b/paludis/resolver/resolver_TEST_continue_on_failure.cc
@@ -139,24 +139,24 @@ namespace test_cases
TEST_CHECK_EQUAL(resolved->job_lists()->execute_job_list()->length(), 6);
- const InstallJob * const direct_dep_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
+ const InstallJob * const direct_dep_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
TEST_CHECK(direct_dep_job);
TEST_CHECK_EQUAL(join(direct_dep_job->requirements()->begin(), direct_dep_job->requirements()->end(), ", ", stringify_req),
"0 satisfied independent always");
- const InstallJob * const indirect_dep_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
+ const InstallJob * const indirect_dep_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(4)));
TEST_CHECK(indirect_dep_job);
TEST_CHECK_EQUAL(join(indirect_dep_job->requirements()->begin(), indirect_dep_job->requirements()->end(), ", ", stringify_req),
- "2 satisfied independent always");
+ "1 satisfied independent always");
const InstallJob * const target_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(5)));
TEST_CHECK(target_job);
if (direct_dep_installed)
TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "4 satisfied independent always, 3 independent, 1 independent");
+ "2 satisfied independent always, 4 independent, 3 independent");
else
TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "4 satisfied independent always, 1 satisfied, 3 independent, 1 independent");
+ "2 satisfied independent always, 3 satisfied, 4 independent, 3 independent");
}
} test_continue_on_failure_false(false), test_continue_on_failure_true(true);
}
diff --git a/paludis/resolver/resolver_TEST_fetches.cc b/paludis/resolver/resolver_TEST_fetches.cc
new file mode 100644
index 0000000..80ee61d
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_fetches.cc
@@ -0,0 +1,146 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/resolver_functions.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/suggest_restart.hh>
+#include <paludis/resolver/job_lists.hh>
+#include <paludis/resolver/job_list.hh>
+#include <paludis/resolver/job.hh>
+#include <paludis/resolver/job_requirements.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/map-impl.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/tribool.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/repository_factory.hh>
+#include <paludis/package_database.hh>
+
+#include <paludis/resolver/resolver_test.hh>
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+
+#include <list>
+#include <tr1/functional>
+#include <algorithm>
+#include <map>
+
+using namespace paludis;
+using namespace paludis::resolver;
+using namespace paludis::resolver::resolver_test;
+using namespace test;
+
+namespace
+{
+ struct ResolverFetchTestCase : ResolverTestCase
+ {
+ ResolverFetchTestCase(const std::string & s) :
+ ResolverTestCase("fetch", s, "exheres-0", "exheres")
+ {
+ }
+ };
+
+ UseExisting
+ use_existing_if_same(
+ const std::tr1::shared_ptr<const Resolution> &,
+ const PackageDepSpec &,
+ const std::tr1::shared_ptr<const Reason> &)
+ {
+ return ue_if_same;
+ }
+
+ std::string
+ stringify_req(const JobRequirement & r)
+ {
+ std::stringstream result;
+ result << r.job_number();
+ if (r.required_if()[jri_require_for_satisfied])
+ result << " satisfied";
+ if (r.required_if()[jri_require_for_independent])
+ result << " independent";
+ if (r.required_if()[jri_require_always])
+ result << " always";
+ return result.str();
+ }
+}
+
+namespace test_cases
+{
+ struct TestFetchDeps : ResolverFetchTestCase
+ {
+ TestFetchDeps() : ResolverFetchTestCase("fetch") { }
+
+ void run()
+ {
+ std::tr1::shared_ptr<const Resolved> resolved(get_resolved("fetch/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("fetch/fetch-dep"))
+ .change(QualifiedPackageName("fetch/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+
+ TEST_CHECK_EQUAL(resolved->job_lists()->execute_job_list()->length(), 4);
+
+ const FetchJob * const fetch_fetch_dep_job(simple_visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(0)));
+ TEST_CHECK(fetch_fetch_dep_job);
+ TEST_CHECK_EQUAL(join(fetch_fetch_dep_job->requirements()->begin(), fetch_fetch_dep_job->requirements()->end(), ", ", stringify_req),
+ "");
+
+ const InstallJob * const fetch_dep_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
+ TEST_CHECK(fetch_dep_job);
+ TEST_CHECK_EQUAL(join(fetch_dep_job->requirements()->begin(), fetch_dep_job->requirements()->end(), ", ", stringify_req),
+ "0 satisfied independent always");
+
+ const FetchJob * const fetch_target_job(simple_visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(2)));
+ TEST_CHECK(fetch_target_job);
+ TEST_CHECK_EQUAL(join(fetch_target_job->requirements()->begin(), fetch_target_job->requirements()->end(), ", ", stringify_req),
+ "1 satisfied, 1 independent");
+
+ const InstallJob * const target_job(simple_visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
+ TEST_CHECK(target_job);
+ TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
+ "2 satisfied independent always, 1 independent");
+ }
+ } test_fetch_dep;
+}
+
diff --git a/paludis/resolver/resolver_TEST_fetches_cleanup.sh b/paludis/resolver/resolver_TEST_fetches_cleanup.sh
new file mode 100755
index 0000000..dadf5d1
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_fetches_cleanup.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d resolver_TEST_fetch_dir ] ; then
+ rm -fr resolver_TEST_fetch_dir
+else
+ true
+fi
+
diff --git a/paludis/resolver/resolver_TEST_fetches_setup.sh b/paludis/resolver/resolver_TEST_fetches_setup.sh
new file mode 100755
index 0000000..ad3cd92
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_fetches_setup.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir resolver_TEST_fetch_dir || exit 1
+cd resolver_TEST_fetch_dir || exit 1
+
+mkdir -p build
+mkdir -p distdir
+mkdir -p installed
+
+mkdir -p repo/{profiles/profile,metadata}
+
+cd repo
+echo "repo" > profiles/repo_name
+: > metadata/categories.conf
+
+# fetch
+echo 'fetch' >> metadata/categories.conf
+
+mkdir -p 'packages/fetch/target'
+cat <<END > packages/fetch/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ fetch: fetch/fetch-dep
+ "
+END
+
+mkdir -p 'packages/fetch/fetch-dep'
+cat <<END > packages/fetch/fetch-dep/fetch-dep-1.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+END
+
+cd ..
+